def need_update(type, *ids): if not ids: return [] ids = list(set(ids)) if type == 'item': ids = [ids[i] for i, wc in enumerate(WC.contains(*ids)) if not wc] if not ids: return [] thehash = LC.gethash(type) tsnow = time.mktime(time.gmtime()) if len(ids) == 1: lastchecks = [thehash.hget(ids[0])] else: lastchecks = thehash.hmget(*ids) needs = [] for i, lastcheck in enumerate(lastchecks): # if there's no lastcheck, or lastcheck happened some time ago # try call on_update with id, if succeeded, update lastcheck in redis if type == 'item': if lastcheck: if str(lastcheck).find('.') > 0: lastcheck = float(lastcheck) #print "get:", bin(int(lastcheck)), len(bin(int(lastcheck))) - 2 if debouncing.can_update(lastcheck): needs.append(ids[i]) else: if lastcheck is None or float(lastcheck) + 86400 * 7 < tsnow: needs.append(ids[i]) return needs
def need_update(type, *ids): if not ids: return [] ids = list(set(ids)) if type == 'item': ids = [ ids[i] for i, wc in enumerate(WC.contains(*ids)) if not wc ] if not ids: return [] thehash = LC.gethash(type) tsnow = time.mktime(time.gmtime()) if len(ids) == 1: lastchecks = [thehash.hget(ids[0])] else: lastchecks = thehash.hmget(*ids) needs = [] for i, lastcheck in enumerate(lastchecks): # if there's no lastcheck, or lastcheck happened some time ago # try call on_update with id, if succeeded, update lastcheck in redis if type == 'item': if lastcheck: if str(lastcheck).find('.') > 0: lastcheck = float(lastcheck) #print "get:", bin(int(lastcheck)), len(bin(int(lastcheck))) - 2 if debouncing.can_update(lastcheck): needs.append(ids[i]) else: if lastcheck is None or float(lastcheck) + 86400*7 < tsnow: needs.append(ids[i]) return needs
def unchange_days(self, num): for i in range(1, num+1): time.time = partial(later_time, i) if can_update(self.sbin): info = {'num_instock':self.instock} self.sbin = get_update_bin(self.sbin, info) print "{} to__crawl".format(i) else: print "{} deboucing".format(i)