On 8/10/06, William Kyngesburye <[EMAIL PROTECTED]> wrote: > On Aug 10, 2006, at 3:07 PM, Bob Ippolito wrote: > > > > > On Aug 10, 2006, at 12:25 PM, William Kyngesburye wrote: > > > >> I have a python script that sets a couple environment vars and runs a > >> shell script in a Terminal window. It works when run from a Terminal > >> with 'python doshell.py'. But when packaged into an app with py2app > >> I get errors. > >> > >> Here's a simplified version (doshell.py): > >> > >> #!/usr/bin/env python > >> > >> import sys > >> import os > >> > >> base = os.path.dirname(sys.argv[0]) > > > > This should probably be os.path.dirname(__file__) > > > hmm, none of the reference I have mention this one. I guess it means > the same as argv[0] - the path/name of the script?
argv[0] and the name of the script aren't necessarily the same thing. __file__ is the file of the script (all modules have a __file__ attribute). > >> # options used by myshell.sh (can't use args) > >> os.environ['STARTBASE'] = base > >> os.environ['MYOPTION'] = 'shelloption' > >> > >> shellrun = base + '/myshell.sh' > >> > >> os.execlp('open', 'open', '-a', 'Terminal.app', shellrun) > > > > Probably should specify /usr/bin/open instead of just open. > > > Same error (changed command to os.execl). What you really should do at this point is print out your environment variables to make sure they're the right thing. If the environment variables aren't the problem, then you probably forgot to include the shell script in your app. When I want to open something in Terminal I generate a temporary script on the fly, rather than having some static script with parameters wedged in with environment variables. There's even an example of this technique in the py2app source: http://svn.pythonmac.org/py2app/py2app/trunk/examples/EggInstaller/EggInstaller.py -bob _______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig