def run(self): while (self.__halt == False): select.select([self._sock],[],[self._sock]) r = "" try: r = self._sock.recv(1024) if (r == ""): self.OnDisconnect() break except socket.error, (n, e): if n==10035: #no data pass else: self.OnDisconnect() self.OnError(n, e) break; self.__buf.push(r) l = self.__buf.pop() while l != "": #we have a full line we can process now try: self.OnRecvStr(l) except: import traceback import sys import StringIO f = StringIO.StringIO() traceback.print_exc(file=f) f = f.getvalue() try: self.TellClient(f) except: pass #i dont have an TellClient method f = f.split("\n") for l in f: wol_logging.log(wol_logging.CRITICAL, "except", l) print '-'*60 print '-'*60 print '-'*60 print "Exception in %s" %(repr(self)) print '\n'.join(f) print '-'*60 print '-'*60 print '-'*60 self._sock.close() self.OnDisconnect() self.halt() l = self.__buf.pop()
def __init__(self, name, game_mgr): Channel.__init__(self, name, game_mgr) global maxgid self.gid = maxgid maxgid += 1 self.gameopt = "" self.topic = "" gdata = { } gdata["name"] = name gdata["2"] = "0" gdata["playercount"] = "8" gdata["clientgame"] = "41" gdata["5"] = "0" gdata["6"] = "0" gdata["tournament"] = "0" gdata["8"] = "0" self.gdata = gdata wol_logging.log(wol_logging.DEBUG, "game", "Game Instance Created (%s)"%(repr(self)))
def senddata(self, str): try: self._sock.setblocking(1) self._sock.sendall(str) if str[-2:] != "\r\n": print "!!! Error no newline: %s"%(str) self.debug(wol_logging.DEBUG, "raw.out", str.strip()) self._sock.setblocking(0) except Exception, e: if (e[0] == 10054): #Connection reset by peer self.debug(wol_logging.DEBUG, "connection", "Connection reset by peer") self.Disconnect() else: import StringIO import traceback f = StringIO.StringIO() traceback.print_exc(file=f) f = f.getvalue() wol_logging.log(wol_logging.ERROR, "out", f) raise e
def __del__(self): wol_logging.log(wol_logging.DEBUG, "user", "User Instance Destroyed (%s)"%(repr(self)))
def __del__(self): wol_logging.log(wol_logging.DEBUG, "game", "Game Instance Destroyed (%s)"%(repr(self)))
def __del__(self): wol_logging.log(wol_logging.DEBUG, "chan", "Channel Instance Destroyed (%s)"%(repr(self)))