How to use the huey.contrib.simple.CommandError function in huey

To help you get started, we’ve selected a few huey examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github coleifer / huey / huey / contrib / simple.py View on Github external
def respond(self, data):
        if not isinstance(data, list):
            try:
                data = data.split()
            except:
                raise CommandError('Unrecognized request type.')

        if not isinstance(data[0], basestring):
            raise CommandError('First parameter must be command name.')

        command = data[0].upper()
        if command not in self._commands:
            raise CommandError('Unrecognized command: %s' % command)
        else:
            logger.debug('Received %s', decode(command))

        return self._commands[command](*data[1:])
github coleifer / huey / huey / contrib / simple.py View on Github external
def respond(self, data):
        if not isinstance(data, list):
            try:
                data = data.split()
            except:
                raise CommandError('Unrecognized request type.')

        if not isinstance(data[0], basestring):
            raise CommandError('First parameter must be command name.')

        command = data[0].upper()
        if command not in self._commands:
            raise CommandError('Unrecognized command: %s' % command)
        else:
            logger.debug('Received %s', decode(command))

        return self._commands[command](*data[1:])
github coleifer / huey / huey / contrib / simple.py View on Github external
def respond(self, data):
        if not isinstance(data, list):
            try:
                data = data.split()
            except:
                raise CommandError('Unrecognized request type.')

        if not isinstance(data[0], basestring):
            raise CommandError('First parameter must be command name.')

        command = data[0].upper()
        if command not in self._commands:
            raise CommandError('Unrecognized command: %s' % command)
        else:
            logger.debug('Received %s', decode(command))

        return self._commands[command](*data[1:])
github coleifer / huey / huey / contrib / simple.py View on Github external
def execute(self, *args):
        self._protocol.write_response(self._fh, args)
        resp = self._protocol.handle_request(self._fh)
        if isinstance(resp, Error):
            raise CommandError(resp.message)
        return resp
github coleifer / huey / huey / contrib / simple.py View on Github external
def _decode_timestamp(self, timestamp):
        fmt = '%Y-%m-%d %H:%M:%S'
        if b'.' in timestamp:
            fmt = fmt + '.%f'
        try:
            return datetime.datetime.strptime(decode(timestamp), fmt)
        except ValueError:
            raise CommandError('Timestamp must be formatted Y-m-d H:M:S')
github coleifer / huey / huey / contrib / simple.py View on Github external
def __init__(self, message):
        self.message = message
        super(CommandError, self).__init__()