parameters: (command, cwd=None)
docstring: Run a given command and report the execution.
  
      :param command: array of tokens
      :param cwd: the working directory where the command will be executed
      :return: output of the command
docstring_summary: Run a given command and report the execution.
docstring_tokens: Run a given command and report the execution .
function: def run_command(command, cwd=None):
      """ Run a given command and report the execution.
  
      :param command: array of tokens
      :param cwd: the working directory where the command will be executed
      :return: output of the command
      """
      def decode_when_needed(result):
          """ check_output returns bytes or string depend on python version """
          return result.decode('utf-8') if isinstance(result, bytes) else result
  
      try:
          directory = os.path.abspath(cwd) if cwd else os.getcwd()
          logging.debug('exec command %s in %s', command, directory)
          output = subprocess.check_output(command,
                                           cwd=directory,
                                           stderr=subprocess.STDOUT)
          return decode_when_needed(output).splitlines()
      except subprocess.CalledProcessError as ex:
          ex.output = decode_when_needed(ex.output).splitlines()
          raise ex
function_tokens: def run_command ( command , cwd = None ) : def decode_when_needed ( result ) : """ check_output returns bytes or string depend on python version """ return result . decode ( 'utf-8' ) if isinstance ( result , bytes ) else result try : directory = os . path . abspath ( cwd ) if cwd else os . getcwd ( ) logging . debug ( 'exec command %s in %s' , command , directory ) output = subprocess . check_output ( command , cwd = directory , stderr = subprocess . STDOUT ) return decode_when_needed ( output ) . splitlines ( ) except subprocess . CalledProcessError as ex : ex . output = decode_when_needed ( ex . output ) . splitlines ( ) raise ex