[Pythonmac-SIG] py2app run errors
William Kyngesburye
woklist at kyngchaos.com
Fri Aug 11 01:24:22 CEST 2006
On Aug 10, 2006, at 5:26 PM, Bob Ippolito wrote:
> 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).
>
Like I said, just getting my feet wet.
>>>> 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
>
Well, some progress. I switched back to the spawn method - I didn't
realize that the args behaves exactly like in exec, where the command
and name (argv[0]) are repeated. I was doing spawnlp('open', '-a',
'Terminal.app', shellrun). So, now I have spawn finally opening the
shell file in a new Terminal window.
Now the environment vars aren't making it into the Terminal window.
I guess that makes sense - the environment set by spawn/exec is for
the command it's running, 'open', not the file that open is telling
Terminal to open. I can't use that egginstaller method of writing a
script, this application will likely be running without admin
privileges, so wouldn't be able to write to the app package.
Any ideas on getting environment vars into the new Terminal window?
I can't use args for the shell script - it already uses args for
something completely different for when it's run from a command
line. Although, that already doesn't apply to when it's run as a Mac
app like this. hmm...
Maybe this is too much work to use Python as an open-source Mac app
wrapper for a shell script (starts as a shell script, at least). In
the future, though, the app will have a Python GUI that I may want to
wrap like this. That'll be easier.
-----
William Kyngesburye <kyngchaos at kyngchaos.com>
http://www.kyngchaos.com/
"I ache, therefore I am. Or in my case - I am, therefore I ache."
- Marvin
More information about the Pythonmac-SIG
mailing list