def _raise_smart_server_error(error_tuple): """Raise exception based on tuple received from smart server Specific error translation is handled by bzrlib.remote._translate_error """ if error_tuple[0] == 'UnknownMethod': raise errors.UnknownSmartMethod(error_tuple[1]) raise errors.ErrorFromSmartServer(error_tuple)
def dispatch_command(self, cmd, args): """Deprecated compatibility method.""" # XXX XXX try: command = self._commands.get(cmd) except LookupError: raise errors.UnknownSmartMethod(cmd) self._command = command(self._backing_transport, self._root_client_path) self._run_handler_code(self._command.execute, args, {})
def args_received(self, args): cmd = args[0] args = args[1:] try: command = self._commands.get(cmd) except LookupError: raise errors.UnknownSmartMethod(cmd) self._command = command(self._backing_transport) self._run_handler_code(self._command.execute, args, {})
def _translate_error(error_tuple): # Many exceptions need some state from the requestor to be properly # translated (e.g. they need a branch object). So this only translates a # few errors, and the rest are turned into a generic ErrorFromSmartServer. error_name = error_tuple[0] error_args = error_tuple[1:] if error_name == 'UnknownMethod': raise errors.UnknownSmartMethod(error_args[0]) if error_name == 'LockContention': raise errors.LockContention('(remote lock)') elif error_name == 'LockFailed': raise errors.LockFailed(*error_args[:2]) else: raise errors.ErrorFromSmartServer(error_tuple)
def args_received(self, args): cmd = args[0] args = args[1:] try: command = self._commands.get(cmd) except LookupError: if 'hpss' in debug.debug_flags: self._trace('hpss unknown request', cmd, repr(args)[1:-1]) raise errors.UnknownSmartMethod(cmd) if 'hpss' in debug.debug_flags: from bzrlib.smart import vfs if issubclass(command, vfs.VfsRequest): action = 'hpss vfs req' else: action = 'hpss request' self._trace(action, '%s %s' % (cmd, repr(args)[1:-1])) self._command = command(self._backing_transport, self._root_client_path, self._jail_root) self._run_handler_code(self._command.execute, args, {})