parameters: (self, context, command,
                 shell=False, capture=False, silent=False,
                 ignore_dry_run=False, return_status=False,
                 ignore_interrupt_signal=False)
return_statement: return ''
docstring: This is the only method that launches external programs.
  
      It is a thin wrapper around subprocess.Popen that handles cr specific
      issues. The command is expanded in the context, so that context variables
      are substituted.
      Args:
        context: the cr context to run under.
        command: the command to run.
        shell: whether to run the command using the shell.
        capture: controls wether the output of the command is captured.
        ignore_dry_run: Normally, if the context is in dry run mode the command is
          printed but not executed. This flag overrides that behaviour, causing
          the command to be run anyway.
        return_status: switches the function to returning the status code rather
          the output.
        ignore_interrupt_signal: Ignore the interrupt signal (i.e., Ctrl-C) while
          the command is running. Useful for letting interactive programs manage
          Ctrl-C by themselves.
      Returns:
        the status if return_status is true, or the output if capture is true,
        otherwise nothing.
docstring_summary: This is the only method that launches external programs.
docstring_tokens: This is the only method that launches external programs .
function: def _Execute(self, context, command,
                 shell=False, capture=False, silent=False,
                 ignore_dry_run=False, return_status=False,
                 ignore_interrupt_signal=False):
      """This is the only method that launches external programs.
  
      It is a thin wrapper around subprocess.Popen that handles cr specific
      issues. The command is expanded in the context, so that context variables
      are substituted.
      Args:
        context: the cr context to run under.
        command: the command to run.
        shell: whether to run the command using the shell.
        capture: controls wether the output of the command is captured.
        ignore_dry_run: Normally, if the context is in dry run mode the command is
          printed but not executed. This flag overrides that behaviour, causing
          the command to be run anyway.
        return_status: switches the function to returning the status code rather
          the output.
        ignore_interrupt_signal: Ignore the interrupt signal (i.e., Ctrl-C) while
          the command is running. Useful for letting interactive programs manage
          Ctrl-C by themselves.
      Returns:
        the status if return_status is true, or the output if capture is true,
        otherwise nothing.
      """
      with context.Trace():
        command = [context.Substitute(arg) for arg in command if arg]
      trail = context.trail
      if not command:
        print 'Empty command passed to execute'
        exit(1)
      if context.verbose:
        print ' '.join(command)
        if context.verbose >= _TRAIL_VERBOSITY:
          print 'Command expanded the following variables:'
          for key, value in trail:
            print '   ', key, '=', value
      if ignore_dry_run or not context.dry_run:
        out = None
        if capture:
          out = subprocess.PIPE
        elif silent:
          out = open(os.devnull, "w")
        try:
          p = subprocess.Popen(
              command, shell=shell,
              env={k: str(v) for k, v in context.exported.items()},
              stdout=out)
        except OSError:
          print 'Failed to exec', command
          # Don't log the trail if we already have
          if context.verbose < _TRAIL_VERBOSITY:
            print 'Variables used to build the command were:'
            for key, value in trail:
              print '   ', key, '=', value
          exit(1)
        try:
          if ignore_interrupt_signal:
            signal.signal(signal.SIGINT, signal.SIG_IGN)
          output, _ = p.communicate()
        finally:
          if ignore_interrupt_signal:
            signal.signal(signal.SIGINT, signal.SIG_DFL)
          if silent:
            out.close()
        if return_status:
          return p.returncode
        if p.returncode != 0:
          print 'Error {0} executing command {1}'.format(p.returncode, command)
          exit(p.returncode)
        return output or ''
      return ''
function_tokens: def _Execute ( self , context , command , shell = False , capture = False , silent = False , ignore_dry_run = False , return_status = False , ignore_interrupt_signal = False ) : with context . Trace ( ) : command = [ context . Substitute ( arg ) for arg in command if arg ] trail = context . trail if not command : print 'Empty command passed to execute' exit ( 1 ) if context . verbose : print ' ' . join ( command ) if context . verbose >= _TRAIL_VERBOSITY : print 'Command expanded the following variables:' for key , value in trail : print '   ' , key , '=' , value if ignore_dry_run or not context . dry_run : out = None if capture : out = subprocess . PIPE elif silent : out = open ( os . devnull , "w" ) try : p = subprocess . Popen ( command , shell = shell , env = { k : str ( v ) for k , v in context . exported . items ( ) } , stdout = out ) except OSError : print 'Failed to exec' , command # Don't log the trail if we already have if context . verbose < _TRAIL_VERBOSITY : print 'Variables used to build the command were:' for key , value in trail : print '   ' , key , '=' , value exit ( 1 ) try : if ignore_interrupt_signal : signal . signal ( signal . SIGINT , signal . SIG_IGN ) output , _ = p . communicate ( ) finally : if ignore_interrupt_signal : signal . signal ( signal . SIGINT , signal . SIG_DFL ) if silent : out . close ( ) if return_status : return p . returncode if p . returncode != 0 : print 'Error {0} executing command {1}' . format ( p . returncode , command ) exit ( p . returncode ) return output or '' return ''