parameters: (scons_env, cmd, error='ignore', **kw)
return_statement: return pobj
docstring: Wrapper for subprocess which pulls from construction env.
  
      Use for calls to subprocess which need to interpolate values from
      an SCons construction environment into the environment passed to
      subprocess.  Adds an an error-handling argument.  Adds ability
      to specify std{in,out,err} with "'devnull'" tag.
docstring_summary: Wrapper for subprocess which pulls from construction env.
docstring_tokens: Wrapper for subprocess which pulls from construction env .
function: def _subproc(scons_env, cmd, error='ignore', **kw):
      """Wrapper for subprocess which pulls from construction env.
  
      Use for calls to subprocess which need to interpolate values from
      an SCons construction environment into the environment passed to
      subprocess.  Adds an an error-handling argument.  Adds ability
      to specify std{in,out,err} with "'devnull'" tag.
      """
      # TODO: just uses subprocess.DEVNULL now, we can drop the "devnull"
      # string now - it is a holdover from Py2, which didn't have DEVNULL.
      for stream in 'stdin', 'stdout', 'stderr':
          io = kw.get(stream)
          if is_String(io) and io == 'devnull':
              kw[stream] = DEVNULL
  
      # Figure out what shell environment to use
      ENV = kw.get('env', None)
      if ENV is None: ENV = get_default_ENV(scons_env)
  
      # Ensure that the ENV values are all strings:
      new_env = {}
      for key, value in ENV.items():
          if is_List(value):
              # If the value is a list, then we assume it is a path list,
              # because that's a pretty common list-like value to stick
              # in an environment variable:
              value = SCons.Util.flatten_sequence(value)
              new_env[key] = os.pathsep.join(map(str, value))
          else:
              # It's either a string or something else.  If it's a string,
              # we still want to call str() because it might be a *Unicode*
              # string, which makes subprocess.Popen() gag.  If it isn't a
              # string or a list, then we just coerce it to a string, which
              # is the proper way to handle Dir and File instances and will
              # produce something reasonable for just about everything else:
              new_env[key] = str(value)
      kw['env'] = new_env
  
      try:
          pobj = subprocess.Popen(cmd, **kw)
      except EnvironmentError as e:
          if error == 'raise': raise
          # return a dummy Popen instance that only returns error
          class dummyPopen:
              def __init__(self, e): self.exception = e
              def communicate(self, input=None): return ('', '')
              def wait(self): return -self.exception.errno
              stdin = None
              class f:
                  def read(self): return ''
                  def readline(self): return ''
                  def __iter__(self): return iter(())
              stdout = stderr = f()
          pobj = dummyPopen(e)
      finally:
          # clean up open file handles stored in parent's kw
          for k, v in kw.items():
              if inspect.ismethod(getattr(v, 'close', None)):
                  v.close()
  
      return pobj
function_tokens: def _subproc ( scons_env , cmd , error = 'ignore' , * * kw ) : # TODO: just uses subprocess.DEVNULL now, we can drop the "devnull" # string now - it is a holdover from Py2, which didn't have DEVNULL. for stream in 'stdin' , 'stdout' , 'stderr' : io = kw . get ( stream ) if is_String ( io ) and io == 'devnull' : kw [ stream ] = DEVNULL # Figure out what shell environment to use ENV = kw . get ( 'env' , None ) if ENV is None : ENV = get_default_ENV ( scons_env ) # Ensure that the ENV values are all strings: new_env = { } for key , value in ENV . items ( ) : if is_List ( value ) : # If the value is a list, then we assume it is a path list, # because that's a pretty common list-like value to stick # in an environment variable: value = SCons . Util . flatten_sequence ( value ) new_env [ key ] = os . pathsep . join ( map ( str , value ) ) else : # It's either a string or something else.  If it's a string, # we still want to call str() because it might be a *Unicode* # string, which makes subprocess.Popen() gag.  If it isn't a # string or a list, then we just coerce it to a string, which # is the proper way to handle Dir and File instances and will # produce something reasonable for just about everything else: new_env [ key ] = str ( value ) kw [ 'env' ] = new_env try : pobj = subprocess . Popen ( cmd , * * kw ) except EnvironmentError as e : if error == 'raise' : raise # return a dummy Popen instance that only returns error class dummyPopen : def __init__ ( self , e ) : self . exception = e def communicate ( self , input = None ) : return ( '' , '' ) def wait ( self ) : return - self . exception . errno stdin = None class f : def read ( self ) : return '' def readline ( self ) : return '' def __iter__ ( self ) : return iter ( ( ) ) stdout = stderr = f ( ) pobj = dummyPopen ( e ) finally : # clean up open file handles stored in parent's kw for k , v in kw . items ( ) : if inspect . ismethod ( getattr ( v , 'close' , None ) ) : v . close ( ) return pobj