Commit b8ea53d9 authored by Gabriel Monnerat's avatar Gabriel Monnerat

add function clean up the python environment. thanks luke

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@40311 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 404c24b7
......@@ -34,6 +34,7 @@ from filter import Filter
from os import environ, path
from interfaces.mimemapper import IMimemapper
from types import InstanceType
from utils import getCleanPythonEnvironment
from sys import executable as python_path
class MimeMapper(object):
......@@ -117,7 +118,7 @@ class MimeMapper(object):
stdout, stderr = Popen(' '.join(command),
stdout=PIPE,
close_fds=True,
shell=True).communicate()
shell=True, env=getCleanPythonEnvironment()).communicate()
exec(stdout)
for key, value in filter_dict.iteritems():
filter_name = key
......
......@@ -29,12 +29,34 @@
from socket import socket, error
from errno import EADDRINUSE
from time import sleep
from os import remove
from os import remove, environ
from shutil import rmtree
import logging
logger = logging.getLogger('Cloudooo')
PYTHON_ENVIRONMENT = [
'PYTHONHOME',
'PYTHONPATH',
'PYTHONSTARTUP',
'PYTHONY2K',
'PYTHONOPTIMIZE',
'PYTHONDEBUG',
'PYTHONDONTWRITEBYTECODE',
'PYTHONINSPECT',
'PYTHONNOUSERSITE',
'PYTHONNOUSERSITE',
'PYTHONUNBUFFERED',
'PYTHONVERBOSE'
]
def getCleanPythonEnvironment():
env = environ.copy()
# Clean python related environment variables
for k in PYTHON_ENVIRONMENT:
env.pop(k, None)
return env
def removeDirectory(path):
"""Remove directory"""
try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment