def general_command(self, worksheet_uuid, command):
        # Tokenize
        if isinstance(command, basestring):
            args = shlex.split(command)
        else:
            args = list(command)

        # Ensure command always starts with 'cl'
        if args[0] == 'cl':
            args = args[1:]

        cli, output_buffer = self._create_cli(worksheet_uuid)
        exception = None
        structured_result = None
        try:
            structured_result = cli.do_command(args)
        except SystemExit:  # as exitcode:
            # this should not happen under normal circumstances
            pass
        except BaseException as e:
            exception = str(e)

        output_str = output_buffer.getvalue()
        output_buffer.close()

        return {
            'structured_result': structured_result,
            'output': output_str,
            'exception': exception
        }
Helper to invoke handlemsg() using raw (packed) message bytes.
dataset/ETHPy150Open codalab/codalab-cli/codalab/rest/legacy.py/BundleService.general_command--crossover with--dataset/ETHPy150Open coreemu/core/daemon/core/broker.py/CoreBroker.handlerawmsg