[GRASS-user] Problems with GRASS python code in osgeo4w

Glynn Clements glynn at gclements.plus.com
Mon Jul 13 18:36:49 EDT 2009


Moskovitz, Bob wrote:

> > Okay, so Python is working fine.
> 
> If python is working, can you explain why my first example
> ( C:\Temp\printargs.py this is a test ) only prints out sys.argv[0]
> ?

Sorry, I overlooked that one.

> I believe that my problem has nothing to do with g.parser. I
> believe that the arguments to a python script are being stripped
> when you rely on ftype.

Okay; I think I know what's going on.

It appears that assoc and ftype set the registry keys:

	HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.py
	HKEY_LOCAL_MACHINE\SOFTWARE\Classes\python.file\Shell\Open\Command

[or py_auto_file, if that's what you use.]

The shell uses:

	HKEY_CLASSES_ROOT\.py
	HKEY_CLASSES_ROOT\Python.File\shell\open\command

which are "virtual" keys which refer to either:

	HKEY_CURRENT_USER\Software\Classes\Python.File\shell\open\command
	HKEY_CURRENT_USER\Software\Classes\.py

or the above HKLM keys, with the HKCU versions taking precedence. So
you can't use assoc/ftype to change the file associations if the HKCU
keys exist.

The confusion arose because both sets of keys were set to exactly the
same thing on my system.

FWIW, you do need the %* at the end of the command. If I remove that
from the HKCU keys, the arguments cease to be passed.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list