code: def execute(cmd, cwd=None):
      
      try:
          lines = subprocess \
              .check_output(cmd, cwd=cwd, stderr=DEVNULL) \
              .splitlines()
      except subprocess.CalledProcessError:
          return None
      else:
          if lines:
              return decode(lines[0].strip())
          else:
              return None
docs: Execute a command and return it's output.