gump-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sam Ruby <ru...@apache.org>
Subject Re: Python scripts' base dir
Date Thu, 24 Apr 2003 13:17:10 GMT
Nicola Ken Barozzi wrote:
> 
> I have made the new python scripts assume that the user cds into the 
> python dir before running the scripts.
> 
> I'm trying to run orphans.py, but it assumes that it's run in the base 
> gump dir.
> 
> What should we decide to do? IMHO it's better to assume that we are in 
> the python dir, so that I can put the scripts in the PATH...

Since the first parameter of gumpview is the workspace, it makes sense 
to me that this script would normally be run in that directory.

In general, however, I prefer that scripts not require that the user be 
in any particular directory in order to run.  I typically run commands 
like "build xml-axis" from whatever directory I am in.

Instead of assuming, why not do something like the following:

     cmdpath=os.path.abspath(sys.argv[0])
     basedir=cmdpath[:cmdpath.rfind('/')]
     if basedir not in sys.path: sys.path.insert(0, basedir)

- Sam Ruby



Mime
View raw message