+ def hookchan(self, chan, handler):
+ try:
+ self.chanhandlers[chan].append(handler)
+ except:
+ self.chanhandlers[chan] = [handler]
+ def unhookchan(self, chan, handler):
+ if chan in self.chanhandlers and handler in self.chanhandlers[chan]:
+ self.chanhandlers[chan].remove(handler)
+ def haschanhook(self, chan):
+ return chan in self.chanhandlers and len(self.chanhandlers[chan]) != 0
+ def getchanhook(self, chan):
+ return self.chanhandlers[chan]
+
+
+class MyCursor(MySQLdb.cursors.DictCursor):
+ def execute(self, *args, **kwargs):
+ print "%09.3f [SQL] [#] MyCursor.execute(self, %s, %s)" % (time.time() % 100000, ', '.join([repr(i) for i in args]), ', '.join([str(key)+"="+repr(kwargs[key]) for key in kwargs]))
+ try:
+ super(self.__class__, self).execute(*args, **kwargs)
+ except MySQLdb.MySQLError as e:
+ print "%09.3f [SQL] [!] MySQL error! %r" % (time.time() % 100000, e)
+ dbsetup()
+ return False
+ return True