Ejemplo n.º 1
0
    def getInfo(self,playerId,isRetry=False):
        if not self.sqlAvailable:
            return FriendInfo(playerName="NotFound")

        cursor = MySQLdb.cursors.DictCursor(self.db)
        try:
            cursor.execute("USE `%s`"%self.dbname)
            cursor.execute(sbSQL.getInfoSELECT,(playerId))
            info = cursor.fetchone()

            if info is None:
                return FriendInfo(playerName="NotFound")
            else:
                return FriendInfo(avatarName = info['avatarName'],
                                  playerName = info['playerName'],
                                  openChatEnabledYesNo = info['openChatEnabledYesNo'],
                                  location = info['location'],
                                  sublocation = info['sublocation'],
                                  timestamp = info['lastupdate'])
            
        except _mysql_exceptions.OperationalError as e:
            if isRetry == True:
                self.log.error("Error on getInfo retry, giving up:\n%s" % str(e))
                return FriendInfo(playerName="NotFound")
            elif e[0] == SERVER_GONE_ERROR or e[0] == SERVER_LOST:
                self.reconnect()
                return self.getInfo(playerId,True)
            else:
                self.log.error("Unknown error on getInfo, retrying:\n%s" % str(e))
                self.reconnect()
                return self.getInfo(playerId,True)
        except Exception as e:
            self.log.error("Unknown error on getInfo, giving up:\n%s" % str(e))
            return FriendInfo(playerName="NotFound")
Ejemplo n.º 2
0
    def avatarOnlinePlusAccountInfo(self,avatarId,accountId,playerName,
                                    playerNameApproved,openChatEnabled,
                                    createFriendsWithChat,chatCodeCreation):
        assert self.notify.debugCall()

        if accountId in [-1, 0]:
            return

        self.log.debug("Account online.  Info: %d, %d, %s, %s, %s, %s, %s"%(avatarId,
                                                                            accountId,
                                                                            playerName,
                                                                            playerNameApproved,
                                                                            openChatEnabled,
                                                                            createFriendsWithChat,
                                                                            chatCodeCreation))

        if playerName == "Guest":
            accountInfo = FriendInfo(avatarName="%d"%avatarId,
                                     playerName="%s%d" % (playerName,accountId),
                                     onlineYesNo=1,
                                     openChatEnabledYesNo=openChatEnabled,
                                     avatarId=avatarId,
                                     location=self.locationName,
                                     sublocation="")
        else:
            accountInfo = FriendInfo(avatarName="%d"%avatarId,
                                     playerName=playerName,
                                     onlineYesNo=1,
                                     openChatEnabledYesNo=openChatEnabled,
                                     avatarId=avatarId,
                                     location=self.locationName,
                                     sublocation="")
        # Don't have my avatar name yet, asyncrequest it
        context = self.air.allocateContext()
        dclassName = "DistributedAvatarUD"
        self.air.contextToClassName[context] = dclassName
        self.acceptOnce("doFieldResponse-%s"%context,self.recvAvatarName,[accountId,accountInfo])
        self.air.queryObjectField(dclassName,"setName",avatarId,context)
Ejemplo n.º 3
0
 def __init__(self, *args, **kw):
     FriendInfo.__init__(self, *args, **args)
     self.bandId = None
 def __init__(self, *args, **kw):
     FriendInfo.__init__(self, *args, **kw)
     self.bandId = None
Ejemplo n.º 5
0
        except _mysql_exceptions.OperationalError, e:
            if isRetry == True:
                self.log.error("Error on getInfo retry, giving up:\n%s" %
                               str(e))
                return FriendInfo(playerName="NotFound")
            elif e[0] == SERVER_GONE_ERROR or e[0] == SERVER_LOST:
                self.reconnect()
                return self.getInfo(playerId, True)
            else:
                self.log.error("Unknown error on getInfo, retrying:\n%s" %
                               str(e))
                self.reconnect()
                return self.getInfo(playerId, True)
        except Exception, e:
            self.log.error("Unknown error on getInfo, giving up:\n%s" % str(e))
            return FriendInfo(playerName="NotFound")

    def setInfo(self, playerId, info, isRetry=False):
        if not self.sqlAvailable:
            return
        cursor = MySQLdb.cursors.DictCursor(self.db)
        rows = 0
        try:
            cursor.execute("USE `%s`" % self.dbname)
            cursor.execute(
                sbSQL.setInfoREPLACE,
                (playerId, info.avatarName, info.playerName,
                 info.openChatEnabledYesNo, info.location, info.sublocation))

            self.db.commit()