code: def run_command(
      commands,
      args,
      cwd=None,
      verbose=False,
      hide_stderr=False,
      env=None,
  ):
      """Call the given command(s)."""
      assert isinstance(commands, list)
      p = None
      for c in commands:
          try:
              dispcmd = str([c] + args)
              # remember shell=False, so use git.cmd on windows, not just git
              p = subprocess.Popen(
                  [c] + args,
                  cwd=cwd,
                  env=env,
                  stdout=subprocess.PIPE,
                  stderr=(subprocess.PIPE if hide_stderr else None),
              )
              break
          except EnvironmentError:
              e = sys.exc_info()[1]
              if e.errno == errno.ENOENT:
                  continue
              if verbose:
                  print("unable to run %s" % dispcmd)
                  print(e)
              return None, None
      else:
          if verbose:
              print("unable to find command, tried %s" % (commands,))
          return None, None
      stdout = p.communicate()[0].strip()
      if sys.version_info[0] >= 3:
          stdout = stdout.decode()
      if p.returncode != 0:
          if verbose:
              print("unable to run %s (error)" % dispcmd)
              print("stdout was %s" % stdout)
          return None, p.returncode
      return stdout, p.returncode
  
imports: from __future__ import print_function
  import errno
  import json
  import os
  import re
  import subprocess
  import sys
label_desc: Use image node_id 4 for calling a global function with example usage: run_command(commands, args, cwd, verbose, hide_stderr, env) and returns: stdout,  p, None,  None, None,  p, None,  None