def process(self): def getTime(): return time.strftime('20%y-%m-%d %H:%M:%S', time.localtime()) def getUrl(targetday=self.today): return urlhead + str(self.cache.get(targetday)) def getMaybe(): backup = copy.deepcopy(self.maybe) backup.sort() backup.reverse() self.result += u'\t 可能的url: ' first = True for mid in backup: if mid >= max(self.cache.values()): if first: first = False self.result += u'\t' + urlhead + str(mid) if self.returnMaybe: self.maybeUrl = urlhead + str(mid) else: self.result += '\t' + str(mid) else: self.maybe.remove(mid) if not self.maybe: self.result += 'None' else: menulog.debug(self.result) if self.gotoid: return urlhead + str(self.today) try: db = dbm.open('datafile', 'r') self.startId = eval(db['startId']) self.lastQuery = eval(db['lastQuery']) self.cache = eval(db['cache']) self.maybe = eval(db['maybe']) db.close() except (IOError, KeyError): msg = u'未找到缓存数据' menulog.debug(msg) return msg if self.today in self.cache.keys(): # 缓存里有就直接返回url menulog.info('find cache @%s' % getTime()) return getUrl() else: # 缓存中查不到 menulog.info('cache not found @%s' % getTime()) if self.result == u'未找到菜单': getMaybe() if self.returnMaybe and self.maybeUrl: return self.maybeUrl else: self.result += u'\t下次刷新:约%d秒后' % (self.lastQuery + frequency - self.now) self.result += u'\t日期:%s' % self.today return self.result
def process(self): def getTime(): return time.strftime('20%y-%m-%d %H:%M:%S', time.localtime()) def getUrl(targetday = self.today): return urlhead + str(self.cache.get(targetday)) def getMaybe(): backup = copy.deepcopy(self.maybe) backup.sort() backup.reverse() self.result += u'\t 可能的url: ' first = True for mid in backup: if mid >= max(self.cache.values()): if first: first = False self.result += u'\t' + urlhead+ str(mid) if self.returnMaybe: self.maybeUrl = urlhead+ str(mid) else: self.result += '\t' + str(mid) else: self.maybe.remove(mid) if not self.maybe: self.result += 'None' else: menulog.debug(self.result) try: f = file('record.pkl', 'rb') self.startId = pickle.load(f) self.lastQuery = pickle.load(f) self.cache = pickle.load(f) self.maybe = pickle.load(f) f.close() except (IOError, EOFError): msg = u'未找到缓存数据' menulog.debug(msg) return msg if self.today in self.cache.keys(): # 缓存里有就直接返回url menulog.info('find cache @%s'% getTime()) return getUrl() else: # 缓存中查不到 print self.returnMaybe menulog.info('cache not found @%s'% getTime()) if self.result == u'未找到菜单': getMaybe() if self.returnMaybe and self.maybeUrl: return self.maybeUrl else: self.result += u'\t下次刷新:约%d秒后'% (self.lastQuery + frequency - self.now) return self.result
def process(self): def getTime(): return time.strftime('20%y-%m-%d %H:%M:%S', time.localtime()) def getUrl(targetday=self.today): return urlhead + str(self.cache.get(targetday)) def getMaybe(): backup = copy.deepcopy(self.maybe) backup.sort() backup.reverse() self.result += u'\t 可能的url: ' first = True for mid in backup: if mid >= max(self.cache.values()): if first: first = False self.result += u'\t' + urlhead + str(mid) if self.returnMaybe: self.maybeUrl = urlhead + str(mid) else: self.result += '\t' + str(mid) else: self.maybe.remove(mid) if not self.maybe: self.result += 'None' else: menulog.debug(self.result) try: f = file('record.pkl', 'rb') self.startId = pickle.load(f) self.lastQuery = pickle.load(f) self.cache = pickle.load(f) self.maybe = pickle.load(f) f.close() except (IOError, EOFError): msg = u'未找到缓存数据' menulog.debug(msg) return msg if self.today in self.cache.keys(): # 缓存里有就直接返回url menulog.info('find cache @%s' % getTime()) return getUrl() else: # 缓存中查不到 print self.returnMaybe menulog.info('cache not found @%s' % getTime()) if self.result == u'未找到菜单': getMaybe() if self.returnMaybe and self.maybeUrl: return self.maybeUrl else: self.result += u'\t下次刷新:约%d秒后' % (self.lastQuery + frequency - self.now) return self.result
def getMaybe(): backup = copy.deepcopy(self.maybe) backup.sort() backup.reverse() self.result += u'\t 可能的url: ' first = True for mid in backup: if mid >= max(self.cache.values()): if first: first = False self.result += u'\t' + urlhead+ str(mid) if self.returnMaybe: self.maybeUrl = urlhead+ str(mid) else: self.result += '\t' + str(mid) else: self.maybe.remove(mid) if not self.maybe: self.result += 'None' else: menulog.debug(self.result)
def getMaybe(): backup = copy.deepcopy(self.maybe) backup.sort() backup.reverse() self.result += u'\t 可能的url: ' first = True for mid in backup: if mid >= max(self.cache.values()): if first: first = False self.result += u'\t' + urlhead + str(mid) if self.returnMaybe: self.maybeUrl = urlhead + str(mid) else: self.result += '\t' + str(mid) else: self.maybe.remove(mid) if not self.maybe: self.result += 'None' else: menulog.debug(self.result)