def getenviron(self, state=True):
     ''' Get an environment suitable for a subprocess.Popen call.
         This is the current process environment with some session-specific
         variables.
     '''
     env = os.environ.copy()
     env['SESSION'] = "%s" % self.sessionid
     env['SESSION_SHORT'] = "%s" % self.shortsessionid()
     env['SESSION_DIR'] = "%s" % self.sessiondir
     env['SESSION_NAME'] = "%s" % self.name
     env['SESSION_FILENAME'] = "%s" % self.filename
     env['SESSION_USER'] = "******" % self.user
     env['SESSION_NODE_COUNT'] = "%s" % self.node_count
     if state:
         env['SESSION_STATE'] = "%s" % self.getstate()
     try:
         readfileintodict(os.path.join(CORE_CONF_DIR, "environment"), env)
     except IOError:
         pass
     if self.user:
         try:
             readfileintodict(
                 os.path.join('/home', self.user, ".core", "environment"),
                 env)
         except IOError:
             pass
     return env
Exemplo n.º 2
0
 def getenviron(self, state=True):
     ''' Get an environment suitable for a subprocess.Popen call.
         This is the current process environment with some session-specific
         variables.
     '''
     env = os.environ.copy()
     env['SESSION'] = "%s" % self.sessionid
     env['SESSION_SHORT'] = "%s" % self.shortsessionid()
     env['SESSION_DIR'] = "%s" % self.sessiondir
     env['SESSION_NAME'] = "%s" % self.name
     env['SESSION_FILENAME'] = "%s" % self.filename
     env['SESSION_USER'] = "******" % self.user
     env['SESSION_NODE_COUNT'] = "%s" % self.node_count
     if state:
         env['SESSION_STATE'] = "%s" % self.getstate()
     try:
         readfileintodict(os.path.join(CORE_CONF_DIR, "environment"), env)
     except IOError:
         pass
     if self.user:
         try:
             readfileintodict(os.path.join('/home', self.user, ".core",
                              "environment"), env)
         except IOError:
             pass
     return env