Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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:])
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:])
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:])
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
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')
def __init__(self, message):
self.message = message
super(CommandError, self).__init__()