Launchd sanitizing python environment
Hello, I'm a relative noob to launchd. Thanks in advance for any help. 10.5.8 , plist run as a User LaunchAgent I am running gimp batch jobs via a wrapping python script. When I run the wrapper from the command line (bash), all is well. When I schedule it via launchd, the environment appears to become sanitized and gimp cannot be found.(I'm comparing environments by issuing the "env" command from the wrapper script.) I can set, for instance, the $PATH via the plist <EnvironmentVariables> key,(which will then find gimp) but then other dependant environment variables cannot be found, such as the display. Since the display (and others) are /tmp/ items, they cannot be "hard-wired" into the plist. As gimp requires a host of helpers(X11, GTK+, GEGL, PANGO etc), debuging these one env variable at a time seems monumental. Is there a way to just run the job as if it were from the user's shell? Perhaps I've overlooked some basic concept? thanks, -hc -- View this message in context: http://old.nabble.com/Launchd-sanitizing-python-environment-tp26799801p26799... Sent from the Launchd mailing list archive at Nabble.com.
On Dec 18, 2009, at 1:59 PM, Heath Carlisle wrote:
Hello, I'm a relative noob to launchd. Thanks in advance for any help.
10.5.8 , plist run as a User LaunchAgent
I am running gimp batch jobs via a wrapping python script.
When I run the wrapper from the command line (bash), all is well. When I schedule it via launchd, the environment appears to become sanitized and gimp cannot be found.(I'm comparing environments by issuing the "env" command from the wrapper script.)
I can set, for instance, the $PATH via the plist <EnvironmentVariables> key,(which will then find gimp) but then other dependant environment variables cannot be found, such as the display. Since the display (and others) are /tmp/ items, they cannot be "hard-wired" into the plist.
As gimp requires a host of helpers(X11, GTK+, GEGL, PANGO etc), debuging these one env variable at a time seems monumental.
Is there a way to just run the job as if it were from the user's shell? Perhaps I've overlooked some basic concept?
Use `launchctl setenv <name> <value>` from within your Python script. See launchctl(1) for more. -- Damien Sorresso BSD Engineering Apple Inc.
Thanks, But - won't this still require me to set the environment variable one at a time? Can I not pass the entire user environment to launchd? I'm running the job as a User LaunchAgent, so I don't understand why this would not be the default behavior. Damien Sorresso wrote:
Use `launchctl setenv <name> <value>` from within your Python script.
See launchctl(1) for more. -- Damien Sorresso BSD Engineering Apple Inc.
_______________________________________________ launchd-dev mailing list launchd-dev@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/launchd-dev
-- View this message in context: http://old.nabble.com/Launchd-sanitizing-python-environment-tp26799801p26850... Sent from the Launchd mailing list archive at Nabble.com.
On Dec 18, 2009, at 3:01 PM, Heath Carlisle wrote:
Thanks, But - won't this still require me to set the environment variable one at a time? Can I not pass the entire user environment to launchd? I'm running the job as a User LaunchAgent, so I don't understand why this would not be the default behavior.
What you perceive as "the user environment" can come from a bunch of different places. If you're running it from a bash shell, the environment can come from .bash_profile and your terminal emulator. launchd isn't aware of either of those things. On Snow Leopard, you can add the needed environment variables to ~/.MacOSX/environment.plist, and launchd will pick it up for Aqua session jobs. -- Damien Sorresso BSD Engineering Apple Inc.
Solved, thanks. The (Leopard 10.5.8) solution was to add an "initialization" script that runs via launchd at boot time to pass the needed values to the (launchd) environment. After that, all other scripts run via launchd are aware of these variables. -heath carlisle Damien Sorresso wrote:
On Dec 18, 2009, at 3:01 PM, Heath Carlisle wrote:
Thanks, But - won't this still require me to set the environment variable one at a time? Can I not pass the entire user environment to launchd? I'm running the job as a User LaunchAgent, so I don't understand why this would not be the default behavior.
What you perceive as "the user environment" can come from a bunch of different places. If you're running it from a bash shell, the environment can come from .bash_profile and your terminal emulator. launchd isn't aware of either of those things.
On Snow Leopard, you can add the needed environment variables to ~/.MacOSX/environment.plist, and launchd will pick it up for Aqua session jobs. -- Damien Sorresso BSD Engineering Apple Inc.
_______________________________________________ launchd-dev mailing list launchd-dev@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/launchd-dev
-- View this message in context: http://old.nabble.com/Launchd-sanitizing-python-environment-tp26799801p26989... Sent from the Launchd mailing list archive at Nabble.com.
participants (2)
-
Damien Sorresso
-
Heath Carlisle