[issue7936] sys.argv contains only scriptname

2010-09-14 Thread Bill Hayes

Bill Hayes  added the comment:

I found this page while encountering the same problem (only one argument, the 
scriptname, being passed in from the command line), and wanted to post the 
following workaround.  I'm running Vista and using Python 2.6.
In summary I had to have 'python' at the beginning of the command line.
I found:
this did not work:  c:\>django-admin startproject mysite
this DID work:  c:\>python django-admin startproject mysite

Before finding this fix:
I had tried the 'ftype Python.File' and 'assoc .py' commands mentioned in other 
posts above and gotten the equivalent of 'not found'.
I actually found the correct info in the registry under HKEY_CURRENT_USER, but 
'ftype' and 'assoc' don't appear to read from there.
I modified the registry under HKEY_LOCAL_MACHINE, and then I was getting the 
responses that were claimed to be needed in msg99369 above, but this did NOT 
fix the problem.
It was after the above that I found the solution - use 'python' at the 
beginning of the command line and all args are passed in.
(I did not go back and remove the registry edits that I made to prove 
conclusively that they are not part of the solution, but I doubt that they are.)

--
nosy: +bill_sanjose

___
Python tracker 
<http://bugs.python.org/issue7936>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7936] sys.argv contains only scriptname

2011-01-13 Thread Bill Hayes

Bill Hayes  added the comment:

I finally found a solution from a page on StackOverflow.
I had to add the two characters  %*
to the end of the Data value for the Windows registry key:
  HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command
So the Data value is now:
   "C:\Python26\python.exe" "%1" %*
just as it appears above including the two sets of double quotes.

I had modified or added six other keys but only the one above solved the 
problem.
I am running Python 2.6 under MS Windows Vista Home Premium 32 bit.
For completeness I tested potential fixes as follows:
I had a program show_args.py which had the two lines:
  import sys
  print 'argv length is ', len(sys.argv)
In order for show_args.py to receive args from the command line invocation 
(before I did the registry fix) I had to explicitly call the python 
interpreter, so ...

Before the fix:
C:\...>python show_args.py aaa bbb ccc
argv length is 4
C:\...>show_args.py aaa bbb ccc
argv length is 1

After the fix:
C:\...>show_args.py aaa bbb ccc
argv length is 4

In hindsight I should have searched the registry for python paths that didn't 
have the ending %*.

Very briefly, for those unfamiliar with Windows' RegEdit:
Click the Start button and enter   regeditin the Search box and the 
Regedit.exe name will appear in the list above - click it.
Repeatedly do Edit/Find   python.exe   
until you find a python path of the form: ...\python.exe" "%1"
instead of the form ...\python.exe" "%1" %*
In the right pane of Regedit, under Name click the word (Default), it will turn 
blue, then select Edit/Modify...
Simply add a space and the two chars  %* to the end of the entry in the Value 
data box, then click OK.
Changes take effect immediately; you don't have to reboot or re-open your 
prompt window, but if you are using IDLE or another IDE you probably have to 
close and restart it.

--
versions: +Python 2.6 -Python 3.1

___
Python tracker 
<http://bugs.python.org/issue7936>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com