[Zoo-discuss] Python service doesn't see Environment variable

Fenoy Gerald gerald.fenoy at geolabs.fr
Wed Dec 17 23:24:35 PST 2014


Dear Steve,
for defining environment variables prior to run your service you should use a specific section in your main.cfg file. This section should be named [env] then you can define any key value pair, so for defining tmpdir as an environment variable you simply have to add the following to your main.cfg:

[env]
TMPDIR=/your/tmp/dir

Obviously you should replace « /your/tmp/dir » by a real path.

Please also note that there is already a default tmpdir variable but it is not defined as an environment variable but can be accessed easilly from any service. It is located in the [main] section and is named tmpDir. So to access it from your service code you may use something like : conf["main"]["tmpDir"] .

I hope this helps,
Best regards,

> Le 17 déc. 2014 à 20:21, Steve.Toutant at inspq.qc.ca a écrit :
> 
> I want my python process to access some environment variables 
> in a console launching this command works 
> python -c 'import os; print os.environ["TMPDIR"]' 
> 
> But when zoo execute the python process it returns an error. Same using getenv() 
> 
> To create the environment variable I created a .sh in /etc/profile.d/ 
> and it contains export TMPDIR="/tmp" 
> 
> How can I fix this please? 
> thanks
> _______________________________________________
> Zoo-discuss mailing list
> Zoo-discuss at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/zoo-discuss
> 



Gérald Fenoy
http://wiki.osgeo.org/wiki/User:Djay



More information about the Zoo-discuss mailing list