import subprocess
import string

class Command(object):

  def execute(self, command: str):
    cliArgs = self.parseCliArgs(command)

    process = subprocess.Popen(cliArgs, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    output, err = process.communicate()
    if process.returncode != 0:
      return False

    return output.decode("utf-8").strip()

  def parseCliArgs(self, command: str):
    rawArgs = command.split(" ")

    parsedArgs = []
    tmpString = False
    isSingle = False
    isDouble = False
    for arg in rawArgs:
      # handle  strings in single quotes
      if arg.startswith("'") and isSingle == False and isDouble == False:
        isSingle = True
        tmpString = arg

      elif arg.endswith("'") and isSingle == True:
        arg = "%s %s" % (tmpString, arg)
        parsedArgs.append(arg)
        isSingle = False
        tmpString = False

      # handle strings in double quotes
      elif arg.startswith('"') and isDouble == False and isSingle == False:
        isDouble = True
        tmpString = arg

      elif arg.endswith('"') and isDouble == True:
        arg = "%s %s" % (tmpString, arg)
        parsedArgs.append(arg)
        isDouble = False
        tmpString = False

      # extend current string
      elif tmpString != False:
        tmpString = "%s %s" % (tmpString, arg)

      else:
        parsedArgs.append(arg)

    return parsedArgs
import subprocess
import string

from pprint import pprint

class Command(object):

  def execute(self, command: str):
    cliArgs = self.parseCliArgs(command)

    pprint(cliArgs)

    process = subprocess.Popen(cliArgs, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    output, err = process.communicate()
    if process.returncode != 0:
      return False

    return output.decode("utf-8").strip()

  def parseCliArgs(self, command: str):
    rawArgs = command.split(" ")

    parsedArgs = []
    tmpString = False
    isSingle = False
    isDouble = False
    for arg in rawArgs:
      # handle  strings in single quotes
      if arg.startswith("'") and isSingle == False and isDouble == False:
        isSingle = True
        tmpString = arg

      elif arg.endswith("'") and isSingle == True:
        arg = "%s %s" % (tmpString, arg)
        parsedArgs.append(arg)
        isSingle = False
        tmpString = False

      # handle strings in double quotes
      elif arg.startswith('"') and isDouble == False and isSingle == False:
        isDouble = True
        tmpString = arg

      elif arg.endswith('"') and isDouble == True:
        arg = "%s %s" % (tmpString, arg)
        parsedArgs.append(arg)
        isDouble = False
        tmpString = False

      # extend current string
      elif tmpString != False:
        tmpString = "%s %s" % (tmpString, arg)

      else:
        parsedArgs.append(arg)

    return parsedArgs
Add some debug for debian box
Add some debug for debian box

  import subprocess
  import string
+ 
+ from pprint import pprint
  
  class Command(object):
  
    def execute(self, command: str):
      cliArgs = self.parseCliArgs(command)
+ 
+     pprint(cliArgs)
  
      process = subprocess.Popen(cliArgs, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
      output, err = process.communicate()
      if process.returncode != 0:
        return False
  
      return output.decode("utf-8").strip()
  
    def parseCliArgs(self, command: str):
      rawArgs = command.split(" ")
  
      parsedArgs = []
      tmpString = False
      isSingle = False
      isDouble = False
      for arg in rawArgs:
        # handle  strings in single quotes
        if arg.startswith("'") and isSingle == False and isDouble == False:
          isSingle = True
          tmpString = arg
  
        elif arg.endswith("'") and isSingle == True:
          arg = "%s %s" % (tmpString, arg)
          parsedArgs.append(arg)
          isSingle = False
          tmpString = False
  
        # handle strings in double quotes
        elif arg.startswith('"') and isDouble == False and isSingle == False:
          isDouble = True
          tmpString = arg
  
        elif arg.endswith('"') and isDouble == True:
          arg = "%s %s" % (tmpString, arg)
          parsedArgs.append(arg)
          isDouble = False
          tmpString = False
  
        # extend current string
        elif tmpString != False:
          tmpString = "%s %s" % (tmpString, arg)
  
        else:
          parsedArgs.append(arg)
  
      return parsedArgs
Add some debug for debian box
## Code Before:
import subprocess
import string

class Command(object):

  def execute(self, command: str):
    cliArgs = self.parseCliArgs(command)

    process = subprocess.Popen(cliArgs, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    output, err = process.communicate()
    if process.returncode != 0:
      return False

    return output.decode("utf-8").strip()

  def parseCliArgs(self, command: str):
    rawArgs = command.split(" ")

    parsedArgs = []
    tmpString = False
    isSingle = False
    isDouble = False
    for arg in rawArgs:
      # handle  strings in single quotes
      if arg.startswith("'") and isSingle == False and isDouble == False:
        isSingle = True
        tmpString = arg

      elif arg.endswith("'") and isSingle == True:
        arg = "%s %s" % (tmpString, arg)
        parsedArgs.append(arg)
        isSingle = False
        tmpString = False

      # handle strings in double quotes
      elif arg.startswith('"') and isDouble == False and isSingle == False:
        isDouble = True
        tmpString = arg

      elif arg.endswith('"') and isDouble == True:
        arg = "%s %s" % (tmpString, arg)
        parsedArgs.append(arg)
        isDouble = False
        tmpString = False

      # extend current string
      elif tmpString != False:
        tmpString = "%s %s" % (tmpString, arg)

      else:
        parsedArgs.append(arg)

    return parsedArgs
## Instruction:
Add some debug for debian box
## Code After:
import subprocess
import string

from pprint import pprint

class Command(object):

  def execute(self, command: str):
    cliArgs = self.parseCliArgs(command)

    pprint(cliArgs)

    process = subprocess.Popen(cliArgs, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    output, err = process.communicate()
    if process.returncode != 0:
      return False

    return output.decode("utf-8").strip()

  def parseCliArgs(self, command: str):
    rawArgs = command.split(" ")

    parsedArgs = []
    tmpString = False
    isSingle = False
    isDouble = False
    for arg in rawArgs:
      # handle  strings in single quotes
      if arg.startswith("'") and isSingle == False and isDouble == False:
        isSingle = True
        tmpString = arg

      elif arg.endswith("'") and isSingle == True:
        arg = "%s %s" % (tmpString, arg)
        parsedArgs.append(arg)
        isSingle = False
        tmpString = False

      # handle strings in double quotes
      elif arg.startswith('"') and isDouble == False and isSingle == False:
        isDouble = True
        tmpString = arg

      elif arg.endswith('"') and isDouble == True:
        arg = "%s %s" % (tmpString, arg)
        parsedArgs.append(arg)
        isDouble = False
        tmpString = False

      # extend current string
      elif tmpString != False:
        tmpString = "%s %s" % (tmpString, arg)

      else:
        parsedArgs.append(arg)

    return parsedArgs