def dispatch(self, request): if not isinstance(request.method, basestring) or not isinstance( request.params, (tuple, list, dict)): request.error(-32600, 'Invalid Request') return method = getattr(self.handler, 'rpc_' + request.method, None) if method is None: request.error(-32601, 'Method not found') return token = None if isinstance(request.params, dict): token = request.params.get('token') del request.params['token'] elif len(request.params) > 0: token = request.params[0] params = request.params[1:] if not isinstance(token, basestring): request.error(-32000, 'No token provided') return error = self.handler.authenticate(token, method) if error is not None: request.error(*error) return try: if isinstance(params, dict): request.result(method(**params)) else: request.result(method(*params)) except: request.error(-32603, PythonUtil.describeException())
def process(self, invoker, target, incantation): self.currentInvoker = invoker self.currentTarget = target word, args = (incantation.split(' ', 1) + [''])[:2] try: return self.doWord(word, args) except MagicError as e: return e.message except Exception: return PythonUtil.describeException(backTrace=1) finally: self.currentInvoker = None self.currentTarget = None
def dispatch(self, request): """ Handle a JSON-RPC 2.0 request. """ if (not isinstance(request.method, basestring)) or \ (not isinstance(request.params, (tuple, list, dict))): request.error(-32600, 'Invalid Request') return # Grab the method from the handler: method = getattr(self.handler, 'rpc_' + request.method, None) if method is None: request.error(-32601, 'Method not found') return # Find the token in the params, authenticate it, and then remove it # from the params: token = None if isinstance(request.params, dict): token = request.params.get('token') del request.params['token'] elif len(request.params) > 0: token = request.params[0] params = request.params[1:] if not isinstance(token, basestring): request.error(-32000, 'No token provided') return error = self.handler.authenticate(token, method) if error is not None: # Authentication wasn't successful. Send the error: request.error(*error) return # Finally, attempt to call the method: try: if isinstance(params, dict): request.result(method(**params)) else: request.result(method(*params)) except: request.error(-32603, PythonUtil.describeException())
localconfig = '' if args.base_channel: localconfig += 'air-base-channel %s\n' % args.base_channel if args.max_channels: localconfig += 'air-channel-allocation %s\n' % args.max_channels if args.stateserver: localconfig += 'air-stateserver %s\n' % args.stateserver if args.astron_ip: localconfig += 'air-connect %s\n' % args.astron_ip if args.eventlogger_ip: localconfig += 'eventlog-host %s\n' % args.eventlogger_ip loadPrcFileData('Command-line', localconfig) from otp.ai.AIBaseGlobal import * from toontown.uberdog.ToontownUberRepository import ToontownUberRepository simbase.air = ToontownUberRepository(config.GetInt('air-base-channel', 400000000), config.GetInt('air-stateserver', 4002)) host = config.GetString('air-connect', '127.0.0.1') port = 7100 if ':' in host: host, port = host.split(':', 1) port = int(port) simbase.air.connect(host, port) try: run() except SystemExit: raise except Exception: info = PythonUtil.describeException() simbase.air.writeServerEvent('uberdog-exception', simbase.air.getAvatarIdFromSender(), simbase.air.getAccountIdFromSender(), info) raise
def setExceptionInfo(self): info = PythonUtil.describeException() self.notify.info('Client exception: %s' % info) self.sendUpdate('setExceptionInfo', [info]) self.cr.flush()
cr.music = music del music base.initNametagGlobals() base.cr = cr loader.endBulkLoad('init') from otp.friends import FriendManager from otp.distributed.OtpDoGlobals import * cr.generateGlobalObject(OTP_DO_ID_FRIEND_MANAGER, 'FriendManager') if not launcher.isDummy(): base.startShow(cr, launcher.getGameServer()) else: base.startShow(cr) backgroundNodePath.reparentTo(hidden) backgroundNodePath.removeNode() del backgroundNodePath del backgroundNode del tempLoader version.cleanup() del version base.loader = base.loader __builtin__.loader = base.loader autoRun = ConfigVariableBool('toontown-auto-run', 1) if autoRun: try: run() except SystemExit: raise except: from toontown.toonbase import ToonPythonUtil as PythonUtil print PythonUtil.describeException() raise
from otp.friends import FriendManager from otp.distributed.OtpDoGlobals import * cr.generateGlobalObject(OTP_DO_ID_FRIEND_MANAGER, 'FriendManager') if not launcher.isDummy(): base.startShow(cr, launcher.getGameServer()) else: base.startShow(cr) backgroundNodePath.reparentTo(hidden) backgroundNodePath.removeNode() del backgroundNodePath del backgroundNode del tempLoader version.cleanup() del version base.loader = base.loader __builtin__.loader = base.loader autoRun = ConfigVariableBool('toontown-auto-run', 1) if autoRun: try: base.run() except SystemExit: raise except: from toontown.toonbase import ToonPythonUtil as PythonUtil print PythonUtil.describeException() from raven import Client Client( 'https://*****:*****@sentry.io/185896' ).captureMessage(message=PythonUtil.describeException()) raise