def run_command(self, command, timeout=0):
        """
        Run system command and parse output
        """
        result = Result()
        lg.debug("Plugin %s: executing command %s" % (self.name, command))

        try:
            stdout, stderr, returncode = smoker.util.command.execute(
                command, timeout=timeout)
        except smoker.util.command.ExecutionTimeout as e:
            raise PluginExecutionTimeout(e)
        except Exception as e:
            lg.exception(e)
            raise PluginExecutionError(
                "Can't execute command %s: %s" % (command, e))

        if returncode:
            status = 'ERROR'
        else:
            status = 'OK'

        # Run parser or parse output from stdin
        if self.params['Parser']:
            try:
                result = self.run_parser(stdout, stderr)
            except Exception as e:
                # Error result
                result.set_status('ERROR')
                result.add_error(re.sub('^\n', '', stderr.strip()))
                result.add_error('Parser run failed: %s' % e)
                result.add_info(re.sub('^\n', '', stdout.strip()))
        else:
            # Try to parse JSON output
            json = None
            try:
                json = simplejson.loads(stdout)
            except:
                pass

            if json:
                # Output is JSON, check it has valid status or raise exception
                if json.has_key('status') and json['status'] in [ 'OK', 'ERROR', 'WARN' ]:
                    try:
                        result.set_result(json, validate=True)
                    except __HOLE__ as e:
                        raise PluginMalformedOutput("Invalid JSON structure: %s" % e)
                else:
                    raise PluginMalformedOutput("Missing status in JSON output: %s" % json)
            else:
                # Output is not JSON, use stdout/stderr and return value
                lg.debug("Plugin %s: using non-JSON output" % self.name)
                result.set_status(status)
                if stderr:
                    result.add_error(re.sub('^\n', '', stderr.strip()))
                if stdout:
                    result.add_info(re.sub('^\n', '', stdout.strip()))

        return result
dataset/ETHPy150Open gooddata/smoker/smoker/server/plugins/__init__.py/PluginWorker.run_command