Example #1
0
 def setMagicWord(self, word, avId, zoneId):
     try:
         self.doMagicWord(word, avId, zoneId)
     except:
         response = PythonUtil.describeException(backTrace=1)
         self.notify.warning('Ignoring error in magic word:\n%s' % response)
         self.setMagicWordResponse(response)
    def setMagicWord(self, word, avId, zoneId, signature):
        senderId = self.air.getAvatarIdFromSender()

        sender = self.air.doId2do.get(senderId, None)
        if sender:
            if senderId == avId:
                sender = "%s/%s(%s)" % (sender.accountName, sender.name,
                                        senderId)
            else:
                sender = "%s/%s(%s) (for %d)" % (sender.accountName,
                                                 sender.name, senderId, avId)
        else:
            sender = "Unknown avatar %d" % (senderId)

        self.notify.info("%s (%s) just said the magic word: %s" %
                         (sender, signature, word))
        self.air.writeServerEvent('magic-word', senderId,
                                  "%s|%s|%s" % (sender, signature, word))
        if avId in self.air.doId2do:
            av = self.air.doId2do[avId]

            try:
                self.doMagicWord(word, av, zoneId, senderId)
            except:
                response = PythonUtil.describeException(backTrace=1)
                self.notify.warning("Ignoring error in magic word:\n%s" %
                                    response)
                self.down_setMagicWordResponse(senderId, response)
        else:
            self.notify.info("Don't know avatar %d." % (avId))
 def setMagicWord(self, word, avId, zoneId):
     try:
         self.doMagicWord(word, avId, zoneId)
     except:
         response = PythonUtil.describeException(backTrace=1)
         self.notify.warning("Ignoring error in magic word:\n%s" % response)
         self.setMagicWordResponse(response)
Example #4
0
 def setExceptionInfo(self):
     """
     In the case of the client leaving for a Python exception, we
     also follow up the above message with this one, which just
     sends a text string describing the exception for the AI log.
     """
     info = PythonUtil.describeException()
     self.notify.info("Client exception: %s" % (info))
     self.sendUpdate("setExceptionInfo", [info])
     self.cr.flush()
Example #5
0
    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, True)
        except Exception:
            return (PythonUtil.describeException(backTrace=1), True)
        finally:
            self.currentInvoker = None
            self.currentTarget = None
Example #6
0
    def __got_post(self):
        self.set_terminator(None)

        # Since we now have the *full* request, we can now decide if we want to
        # throw out the request based on headers and junk.
        if self.server.auth is not None:
            if self.headers.get('authorization') != 'Basic ' + self.server.auth:
                return self.demand('HTTPError', 401)

        if self.server.path != self.path:
            return self.demand('HTTPError', 404)

        self.id = None

        try:
            request = json.loads(self.data)
        except ValueError:
            return self.demand('JSONError', -32700, 'Parse error')

        if 'method' not in request or 'params' not in request:
            return self.demand('JSONError', -32600, 'Invalid Request')

        self.id = request.get('id')

        if not isinstance(request['method'], basestring) or \
           not isinstance(request['params'], (tuple, list, dict)):
            return self.demand('JSONError', -32600, 'Invalid Request')

        method = getattr(self.server.handler, 'rpc_' + str(request['method']), None)
        params = request['params']
        if not method:
            return self.demand('JSONError', -32601, 'Method not found')

        request = RPCRequest(self)
        try:
            if isinstance(params, dict):
                result = method(request, **params)
            else:
                result = method(request, *params)
        except Exception:
            self.demand('JSONError', -1, PythonUtil.describeException())
        else:
            if result != request: # Returning "request" signifies deference.
                if request.active:
                    request.result(result)
    def startCustomService(self, ip, port, baseChannel, stateServer):
        from otp.ai.AIBaseGlobal import *
        from pirates.uberdog.PiratesUberRepository import PiratesUberRepository
        simbase.air = PiratesUberRepository(baseChannel, stateServer)
        host = config.GetString('air-connect', ip)
        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 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())
    def dispatch(self, request):
        """
        Handle a JSON-RPC 2.0 request.
        """
        if (not isinstance(request.method, str)) 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, str):
            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())
Example #10
0
 def setExceptionInfo(self):
     info = PythonUtil.describeException()
     self.notify.info('Client exception: %s' % info)
     self.sendUpdate('setExceptionInfo', [info])
     self.cr.flush()
if args.stateserver: localconfig += 'air-stateserver %s\n' % args.stateserver
if args.district_name: localconfig += 'district-name %s\n' % args.district_name
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.ai.ToontownAIRepository import ToontownAIRepository
simbase.air = ToontownAIRepository(config.GetInt('air-base-channel', 401000000),
                                   config.GetInt('air-stateserver', 4002),
                                   config.GetString('district-name', 'Devhaven'))
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('ai-exception', avId=simbase.air.getAvatarIdFromSender(), accId=simbase.air.getAccountIdFromSender(), exception=info)
    with open(config.GetString('ai-crash-log-name', 'ai-crash.txt'), 'w+') as file:
        file.write(info + "\n")
    raise
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 direct.showbase import PythonUtil
        print PythonUtil.describeException()
        raise
Example #13
0
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)

class game:
    name = 'uberDog'
    process = 'server'
__builtins__.game = game

from otp.ai.AIBaseGlobal import *

from toontown.uberdog.ToontownUberRepository import ToontownUberRepository
simbase.air = ToontownUberRepository(config.GetInt('air-base-channel', 400000000),
                                     config.GetInt('air-stateserver', 10000))
host = config.GetString('air-connect', '127.0.0.1')
port = 7199
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
Example #14
0
 def setExceptionInfo(self):
     info = PythonUtil.describeException()
     self.notify.info('Client exception: %s' % info)
     self.sendUpdate('setExceptionInfo', [info])
     self.cr.flush()
Example #15
0
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:
        base.run()
    except SystemExit:
        raise
    except:
        from direct.showbase import PythonUtil
        print PythonUtil.describeException()
        raise
Example #16
0
backgroundNodePath.removeNode()
del backgroundNodePath
del backgroundNode
del tempLoader
# tempLoaderOther.destroy()
# del tempLoaderOther
version.cleanup()
del version

# replace the direct loader with the toontown one
base.loader = base.loader
builtins.loader = base.loader

autoRun = ConfigVariableBool('toontown-auto-run', 1)

if autoRun and launcher.isDummy():
    # This try .. except block exists solely to test the logic of
    # PythonUtil.describeException.  It's not at all necessary, and is
    # useful only to those debugging that function; remove it if it
    # bugs you.
    try:
        run()

    except SystemExit:
        raise

    except:
        from direct.showbase import PythonUtil
        print((PythonUtil.describeException()))
        raise