Commits

Anonymous committed d93d4ef

'add the ability to pass an environment to ChapPy.AthenaApp'

  • Participants
  • Parent commits 480f04a
  • Tags AthenaCommon-02-18-14

Comments (0)

Files changed (2)

+2012-03-29  Sebastien Binet  <binet@cern.ch>
+
+	* tagging AthenaCommon-02-18-14
+	* add the ability to pass an environment to ChapPy.AthenaApp
+	* M python/ChapPy.py
+
 2012-02-16 Martin Woudstra <martin.woudstra@cern.ch>
 	* tagging AthenaCommon-02-18-13
 	* python/ConfiguredFactory.py: fix crash in printout if not running at VERBOSE output level

File python/ChapPy.py

             ] )
         return s
         
-    def run( self, monitor = sys.stdout ):
+    def run( self, monitor = sys.stdout, env = None ):
 
+        if env is None:
+            import os
+            env = dict(os.environ)
+            pass
+        
         sc, out = commands.getstatusoutput( "which athena.py" )
         if sc != 0:
             raise RuntimeError, "Could not fetch athena.py executable: %s" % out
 
         p = subprocess.Popen( args = ["/bin/sh"] + cmd,
                               stdout = self.logFile,
-                              stderr = self.logFile )
+                              stderr = self.logFile,
+                              env = env )
         monitor.write(" :::running [")
         monitor.flush()
         while p.poll() == None:
             return
         raise TypeError('unexpected type %s'%type(o))
     
-    def run(self, stdout=None):
+    def run(self, stdout=None, env=None):
         import os
         import subprocess as sub
+        if env is None:
+            env=dict(os.environ)
         athena_exe = sub.Popen(['which', 'athena.py'],
-                               stdout=sub.PIPE).communicate()[0].strip()
+                               stdout=sub.PIPE,
+                               env=env).communicate()[0].strip()
         
         athena_exe = os.path.expanduser(os.path.expandvars(athena_exe))
         athena_exe = os.path.realpath(athena_exe)
         cmd = [athena_exe] + self._cmdlineargs + [self._jobo.name]
         return sub.call(cmd,
                         stdout=stdout,
-                        stderr=sub.STDOUT)
+                        stderr=sub.STDOUT,
+                        env=env)