code: def execute(cmd, verbose=True):
      if verbose:
          print("CMD> %s" % cmd)
      p = subprocess.Popen(
          [cmd],
          shell=True,
          stdout=subprocess.PIPE,
          stderr=subprocess.STDOUT,
          stdin=subprocess.PIPE,
          universal_newlines=True,
      )
  
      if not verbose:
          # use p.communicate instead of p.wait to avoid such situation:
          # pipe is filled and the child process is blocked.
          out, err = p.communicate()
          if p.returncode != 0:
              raise Exception("errorcode: {}".format(p.returncode))
          return out
  
      buf = []
  
      while p.poll() is None:
          line = p.stdout.readline().strip()
          if verbose:
              print(line)
          buf.append(line)
  
      for li in p.stdout:
          line = li.strip()
          if verbose:
              print(line)
          buf.append(line)
  
      if p.returncode != 0:
          if verbose:
              print(line)
          raise Exception("errorcode: %s" % p.returncode)
  
      return "\n".join(buf)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import copy
  import os
  import re
  import subprocess
  import random
  import tempfile
  from utils import util
label_desc: Use image node_id 1 for calling a global function with example usage: execute(cmd, verbose) and returns: str, out