def run(self): cache = Cache() lastCall = 0 wait = 300 # time between 2 requests in ms while True: try: # Block waiting for addChatEntry() to enqueue something chatEntry = self.queue.get() if not self.active: return charname = chatEntry.message.user logging.debug("AvatarFindThread getting avatar for %s" % charname) avatar = None if charname == "VINTEL": with open(resourcePath("vi/ui/res/logo_small.png"), "rb") as f: avatar = f.read() if not avatar: avatar = cache.getAvatar(charname) if avatar: logging.debug("AvatarFindThread found cached avatar for %s" % charname) if not avatar: diffLastCall = time.time() - lastCall if diffLastCall < wait: time.sleep((wait - diffLastCall) / 1000.0) avatar = evegate.getAvatarForPlayer(charname) lastCall = time.time() if avatar: cache.putAvatar(charname, avatar) if avatar: logging.debug("AvatarFindThread emit avatar_update for %s" % charname) self.emit(SIGNAL("avatar_update"), chatEntry, avatar) except Exception as e: logging.error("Error in AvatarFindThread : %s", e)
def run(self): cache = Cache() lastCall = 0 wait = 300 # time between 2 requests in ms while True: try: # Block waiting for addChatEntry() to enqueue something chatEntry = self.queue.get() charname = chatEntry.message.user avatar = None if charname == "VINTEL": with open(resourcePath("vi/ui/res/logo_small.png"), "rb") as f: avatar = f.read() if not avatar: avatar = cache.getAvatar(charname) if not avatar: diffLastCall = time.time() - lastCall if diffLastCall < wait: time.sleep((wait - diffLastCall) / 1000.0) avatar = evegate.getAvatarForPlayer(charname) lastCall = time.time() if avatar: cache.putAvatar(charname, avatar) if avatar: self.emit(SIGNAL("avatar_update"), chatEntry, avatar) except Exception as e: print "An error in the AvatarFindThread : {0}".format(str(e))
def run(self): cache = Cache() lastCall = 0 wait = 500 # time between 2 requests in ms while True: try: # Block waiting for addChatEntry() to enqueue something chatEntry = self.queue.get() if not self.active: return charname = chatEntry.message.user logging.debug("AvatarFindThread getting avatar for %s" % charname) avatar = None if charname == "SPYGLASS": with open( resourcePath( os.path.join("vi", "ui", "res", "logo_small.png")), "rb", ) as f: avatar = f.read() if avatar is None: avatar = cache.getAvatar(charname) if avatar: logging.debug( "AvatarFindThread found cached avatar for %s" % charname) if avatar is None: diffLastCall = time.time() - lastCall if diffLastCall < wait: time.sleep((wait - diffLastCall) / 1000.0) avatar = evegate.getAvatarForPlayer(charname) lastCall = time.time() if avatar is None: cache.removeAvatar(charname) else: cache.putAvatar(charname, avatar) if avatar: logging.debug( "AvatarFindThread emit avatar_update for %s" % charname) self.avatar_update.emit(chatEntry, avatar) else: logging.warning( "AvatarFindThread unable to find avatar for %s" % charname) except Exception as e: logging.error("Error in AvatarFindThread : %s", e)
def run(self): cache = Cache() lastCall = 0 wait = 300 # time between 2 requests in ms while True: try: # Block waiting for addChatEntry() to enqueue something chatEntry = self.queue.get() if not self.active: return charname = chatEntry.message.user logging.debug("AvatarFindThread getting avatar for %s" % charname) avatar = None if charname == "VINTEL": with open( resource_filename(__name__, "ui/res/logo_small.png"), "rb") as f: avatar = f.read() if not avatar: avatar = cache.getAvatar(charname) if avatar: logging.debug( "AvatarFindThread found cached avatar for %s" % charname) if not avatar: diffLastCall = time.time() - lastCall if diffLastCall < wait: time.sleep((wait - diffLastCall) / 1000.0) avatar = evegate.getAvatarForPlayer(charname) lastCall = time.time() if avatar: cache.putAvatar(charname, avatar) if avatar: logging.debug( "AvatarFindThread emit avatar_update for %s" % charname) self.avatar_update.emit(chatEntry, avatar) except Exception as e: logging.error("Error in AvatarFindThread : %s", e)