[Erp5-report] r39234 luke - /erp5/trunk/utils/erp5.recipe.standaloneinstance/src/erp5/recip...

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Oct 15 15:51:09 CEST 2010


Author: luke
Date: Fri Oct 15 15:51:05 2010
New Revision: 39234

URL: http://svn.erp5.org?rev=39234&view=rev
Log:
 - cleanup python environment
Recipe is calling another python in new process. Unfortunately during
buildout invocation things specific to buildout are set in environment,
which affects behaviour of invoked interpreter. So that is why it is
needed to clean environment from python related parameters (like
PYTHONPATH)

Modified:
    erp5/trunk/utils/erp5.recipe.standaloneinstance/src/erp5/recipe/standaloneinstance/__init__.py

Modified: erp5/trunk/utils/erp5.recipe.standaloneinstance/src/erp5/recipe/standaloneinstance/__init__.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.standaloneinstance/src/erp5/recipe/standaloneinstance/__init__.py?rev=39234&r1=39233&r2=39234&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.recipe.standaloneinstance/src/erp5/recipe/standaloneinstance/__init__.py [utf8] (original)
+++ erp5/trunk/utils/erp5.recipe.standaloneinstance/src/erp5/recipe/standaloneinstance/__init__.py [utf8] Fri Oct 15 15:51:05 2010
@@ -22,6 +22,28 @@ import subprocess
 class WithMinusTemplate(Template):
   idpattern = '[_a-z][-_a-z0-9]*'
 
+PYTHON_ENVIRONMENT = [
+  'PYTHONHOME',
+  'PYTHONPATH',
+  'PYTHONSTARTUP',
+  'PYTHONY2K',
+  'PYTHONOPTIMIZE',
+  'PYTHONDEBUG',
+  'PYTHONDONTWRITEBYTECODE',
+  'PYTHONINSPECT',
+  'PYTHONNOUSERSITE',
+  'PYTHONNOUSERSITE',
+  'PYTHONUNBUFFERED',
+  'PYTHONVERBOSE'
+]
+
+def getCleanPythonEnvironment():
+  env = os.environ.copy()
+  # Clean python related environment variables
+  for k in PYTHON_ENVIRONMENT:
+    env.pop(k, None)
+  return env
+
 class Recipe(plone.recipe.zope2instance.Recipe):
   def __init__(self, buildout, name, options):
     instancehome = options.get('instancehome')
@@ -214,7 +236,7 @@ class Recipe(plone.recipe.zope2instance.
     argv.extend([bt for bt in options.get('bt5', '').split('\n') if bt])
 
     popen = subprocess.Popen(argv, stdout=subprocess.PIPE,
-        stderr=subprocess.STDOUT)
+        stderr=subprocess.STDOUT, env=getCleanPythonEnvironment())
     result = popen.communicate()[0]
     if popen.returncode is None or popen.returncode != 0:
       raise zc.buildout.UserError("""Issues during initalising ERP5 Site.




More information about the Erp5-report mailing list