parameters: (cmd, shell=True)
return_statement: return std, err_msg
docstring: execute cmd
          :param cmd: cmd str
          :param shell: execute shell mode, True or False
          :return: execute result
docstring_summary: execute cmd
          :param cmd: cmd str
          :param shell: execute shell mode, True or False
          :return: execute result
docstring_tokens: execute cmd : param cmd : cmd str : param shell : execute shell mode True or False : return : execute result
function: def execute_cmd(cmd, shell=True):
          """
          execute cmd
          :param cmd: cmd str
          :param shell: execute shell mode, True or False
          :return: execute result
          """
          if not shell:
              cmd_list = [cmd.strip() for cmd in cmd.split("|")]
              proc = Popen(cmd_list[0].split(), stdout=PIPE, stderr=PIPE, shell=shell)
              if len(cmd_list) > 1:
                  for i in range(1, len(cmd_list)):
                      proc = Popen(cmd_list[i].split(), stdin=proc.stdout, stdout=PIPE, stderr=PIPE,
                                   shell=shell)
          else:
              proc = Popen(cmd, stdout=PIPE, stderr=PIPE, shell=shell)
          std, err_msg = proc.communicate()
          if proc.returncode != 0:
              raise Exception("Failed to execute command: %s, \nError: %s." % (cmd, str(err_msg)))
          return std, err_msg
function_tokens: def execute_cmd ( cmd , shell = True ) : if not shell : cmd_list = [ cmd . strip ( ) for cmd in cmd . split ( "|" ) ] proc = Popen ( cmd_list [ 0 ] . split ( ) , stdout = PIPE , stderr = PIPE , shell = shell ) if len ( cmd_list ) > 1 : for i in range ( 1 , len ( cmd_list ) ) : proc = Popen ( cmd_list [ i ] . split ( ) , stdin = proc . stdout , stdout = PIPE , stderr = PIPE , shell = shell ) else : proc = Popen ( cmd , stdout = PIPE , stderr = PIPE , shell = shell ) std , err_msg = proc . communicate ( ) if proc . returncode != 0 : raise Exception ( "Failed to execute command: %s, \nError: %s." % ( cmd , str ( err_msg ) ) ) return std , err_msg