import os

from ..quokka import ExternalProcess, PluginException


class ConsoleApplication(ExternalProcess):

    def __init__(self, conf):
        super(ConsoleApplication, self).__init__()
        self.quokka = conf.quokka
        self.plugin = conf.plugin_kargs

    def start(self):
        binary = self.plugin['binary']
        if not binary or not os.path.exists(binary):
            raise PluginException('%s not found.' % binary)

        params = self.plugin['params']
        environ = self.set_environ(self.quokka['environ'])

        cmd = [binary]
        if params:
            cmd.append(params)

        self.process = self.open(cmd, environ)

import os
import shlex

from ..quokka import ExternalProcess, PluginException


class ConsoleApplication(ExternalProcess):

    def __init__(self, conf):
        super(ConsoleApplication, self).__init__()
        self.quokka = conf.quokka
        self.plugin = conf.plugin_kargs

    def start(self):
        binary = self.plugin['binary']
        if not binary or not os.path.exists(binary):
            raise PluginException('%s not found.' % binary)

        params = self.plugin['params']
        environ = self.set_environ(self.quokka['environ'])

        cmd = [binary]
        if params:
            cmd.extend(shlex.split(params))

        self.process = self.open(cmd, environ)

Use shlex to split parameters
Use shlex to split parameters

  import os
+ import shlex
  
  from ..quokka import ExternalProcess, PluginException
  
  
  class ConsoleApplication(ExternalProcess):
  
      def __init__(self, conf):
          super(ConsoleApplication, self).__init__()
          self.quokka = conf.quokka
          self.plugin = conf.plugin_kargs
  
      def start(self):
          binary = self.plugin['binary']
          if not binary or not os.path.exists(binary):
              raise PluginException('%s not found.' % binary)
  
          params = self.plugin['params']
          environ = self.set_environ(self.quokka['environ'])
  
          cmd = [binary]
          if params:
-             cmd.append(params)
+             cmd.extend(shlex.split(params))
  
          self.process = self.open(cmd, environ)
  
Use shlex to split parameters
## Code Before:
import os

from ..quokka import ExternalProcess, PluginException


class ConsoleApplication(ExternalProcess):

    def __init__(self, conf):
        super(ConsoleApplication, self).__init__()
        self.quokka = conf.quokka
        self.plugin = conf.plugin_kargs

    def start(self):
        binary = self.plugin['binary']
        if not binary or not os.path.exists(binary):
            raise PluginException('%s not found.' % binary)

        params = self.plugin['params']
        environ = self.set_environ(self.quokka['environ'])

        cmd = [binary]
        if params:
            cmd.append(params)

        self.process = self.open(cmd, environ)

## Instruction:
Use shlex to split parameters
## Code After:
import os
import shlex

from ..quokka import ExternalProcess, PluginException


class ConsoleApplication(ExternalProcess):

    def __init__(self, conf):
        super(ConsoleApplication, self).__init__()
        self.quokka = conf.quokka
        self.plugin = conf.plugin_kargs

    def start(self):
        binary = self.plugin['binary']
        if not binary or not os.path.exists(binary):
            raise PluginException('%s not found.' % binary)

        params = self.plugin['params']
        environ = self.set_environ(self.quokka['environ'])

        cmd = [binary]
        if params:
            cmd.extend(shlex.split(params))

        self.process = self.open(cmd, environ)
