diff --git a/direct/src/distributed/AstronClientRepository.py b/direct/src/distributed/AstronClientRepository.py index aa33ec96b2f..cd15eda6c5b 100644 --- a/direct/src/distributed/AstronClientRepository.py +++ b/direct/src/distributed/AstronClientRepository.py @@ -1,10 +1,10 @@ """AstronClientRepository module: contains the AstronClientRepository class""" +from panda3d.direct import STUint16, STUint32 from direct.directnotify import DirectNotifyGlobal -from ClientRepositoryBase import ClientRepositoryBase -from MsgTypes import * from direct.distributed.PyDatagram import PyDatagram -from pandac.PandaModules import STUint16, STUint32 +from .ClientRepositoryBase import ClientRepositoryBase +from .MsgTypes import * class AstronClientRepository(ClientRepositoryBase): """ diff --git a/direct/src/distributed/AstronDatabaseInterface.py b/direct/src/distributed/AstronDatabaseInterface.py index 32939aead0d..351873bbfca 100644 --- a/direct/src/distributed/AstronDatabaseInterface.py +++ b/direct/src/distributed/AstronDatabaseInterface.py @@ -1,9 +1,9 @@ -from pandac.PandaModules import * -from MsgTypes import * +from panda3d.core import * from direct.directnotify import DirectNotifyGlobal -from ConnectionRepository import ConnectionRepository -from PyDatagram import PyDatagram -from PyDatagramIterator import PyDatagramIterator +from .MsgTypes import * +from .ConnectionRepository import ConnectionRepository +from .PyDatagram import PyDatagram +from .PyDatagramIterator import PyDatagramIterator class AstronDatabaseInterface: """ @@ -57,7 +57,7 @@ def createObject(self, databaseId, dclass, fields={}, callback=None): dg.addUint32(ctx) dg.addUint16(dclass.getNumber()) dg.addUint16(fieldCount) - dg.appendData(fieldPacker.getString()) + dg.appendData(fieldPacker.getBytes()) self.air.send(dg) def handleCreateObjectResp(self, di): @@ -149,7 +149,7 @@ def handleQueryObjectResp(self, msgType, di): unpacker = DCPacker() unpacker.setUnpackData(di.getRemainingBytes()) fields = {} - for x in xrange(fieldCount): + for x in range(fieldCount): fieldId = unpacker.rawUnpackInt16() field = dclass.getFieldByIndex(fieldId) @@ -239,7 +239,7 @@ def updateObject(self, databaseId, doId, dclass, newFields, oldFields=None, call dg.addUint32(doId) if fieldCount != 1: dg.addUint16(fieldCount) - dg.appendData(fieldPacker.getString()) + dg.appendData(fieldPacker.getBytes()) self.air.send(dg) if oldFields is None and callback is not None: @@ -276,7 +276,7 @@ def handleUpdateObjectResp(self, di, multi): unpacker = DCPacker() unpacker.setUnpackData(di.getRemainingBytes()) fields = {} - for x in xrange(fieldCount): + for x in range(fieldCount): fieldId = unpacker.rawUnpackInt16() field = self.air.getDcFile().getFieldByIndex(fieldId) diff --git a/direct/src/distributed/AstronInternalRepository.py b/direct/src/distributed/AstronInternalRepository.py index ba06142a9f5..a2a34652819 100644 --- a/direct/src/distributed/AstronInternalRepository.py +++ b/direct/src/distributed/AstronInternalRepository.py @@ -1,14 +1,15 @@ -from pandac.PandaModules import * -from MsgTypes import * +import collections + +from panda3d.core import * from direct.showbase import ShowBase # __builtin__.config from direct.task.TaskManagerGlobal import * # taskMgr from direct.directnotify import DirectNotifyGlobal -from ConnectionRepository import ConnectionRepository -from PyDatagram import PyDatagram -from PyDatagramIterator import PyDatagramIterator -from AstronDatabaseInterface import AstronDatabaseInterface -from NetMessenger import NetMessenger -import collections +from .MsgTypes import * +from .ConnectionRepository import ConnectionRepository +from .PyDatagram import PyDatagram +from .PyDatagramIterator import PyDatagramIterator +from .AstronDatabaseInterface import AstronDatabaseInterface +from .NetMessenger import NetMessenger # Helper functions for logging output: def msgpack_length(dg, length, fix, maxfix, tag8, tag16, tag32): @@ -33,7 +34,7 @@ def msgpack_encode(dg, element): dg.addUint8(0xc2) elif element is True: dg.addUint8(0xc3) - elif isinstance(element, (int, long)): + elif isinstance(element, int): if -32 <= element < 128: dg.addInt8(element) elif 128 <= element < 256: @@ -71,7 +72,7 @@ def msgpack_encode(dg, element): msgpack_length(dg, len(element), 0x90, 0x10, None, 0xdc, 0xdd) for v in element: msgpack_encode(dg, v) - elif isinstance(element, basestring): + elif isinstance(element, str): # 0xd9 is str 8 in all recent versions of the MsgPack spec, but somehow # Logstash bundles a MsgPack implementation SO OLD that this isn't # handled correctly so this function avoids it too @@ -206,7 +207,7 @@ def addPostRemove(self, dg): dg2 = PyDatagram() dg2.addServerControlHeader(CONTROL_ADD_POST_REMOVE) dg2.addUint64(self.ourChannel) - dg2.addString(dg.getMessage()) + dg2.addBlob(dg.getMessage()) self.send(dg2) def clearPostRemove(self): @@ -407,7 +408,7 @@ def handleGetObjectResp(self, di): unpacker.setUnpackData(di.getRemainingBytes()) # Required: - for i in xrange(dclass.getNumInheritedFields()): + for i in range(dclass.getNumInheritedFields()): field = dclass.getInheritedField(i) if not field.isRequired() or field.asMolecularField(): continue unpacker.beginUnpack(field) @@ -416,7 +417,7 @@ def handleGetObjectResp(self, di): # Other: other = unpacker.rawUnpackUint16() - for i in xrange(other): + for i in range(other): field = dclass.getFieldByIndex(unpacker.rawUnpackUint16()) unpacker.beginUnpack(field) fields[field.getName()] = field.unpackArgs(unpacker) @@ -521,7 +522,7 @@ def sendActivate(self, doId, parentId, zoneId, dclass=None, fields=None): dg.addServerHeader(doId, self.ourChannel, STATESERVER_OBJECT_SET_FIELDS) dg.addUint32(doId) dg.addUint16(fieldCount) - dg.appendData(fieldPacker.getString()) + dg.appendData(fieldPacker.getBytes()) self.send(dg) # Now slide it into the zone we expect to see it in (so it # generates onto us with all of the fields in place)