def run(self): if not self.account: self.quit() return trys = 0 new_groups = None old_groups = list(map(unicode,self.groups.allKeys())) while trys < 4: trys += 1 new_groups = get_group(self.account.service, self.account.name) if new_groups is not None: break if new_groups is None: self.end() return for group in new_groups: id = unicode(group['nickname']) if self.groups.contains(id): #print id, "(found)" if id in old_groups: old_groups.remove(id) else: #print id, "(new)" self.app.updates.add_timer( "group", self.account.service, self.account.name, id) dump = json.dumps(clean_urls(group)) self.groups.setValue(id, dump) for id in old_groups: #print id, "(lost)" self.app.updates.remove_timer( "group", self.account.service, self.account.name, id) self.groups.remove(id) #print "groups list up-to-date. (%s)" % self.user self.end()
def run(self): if not self.service or not self.user: self.quit() return trys = 0 page = -1 new_friends = None try: friendscount = api_call(self.service, 'users/show', {'id': self.user})['friends_count'] except Exception as e: print "[ERROR]", e self.end() return old_friends = list(map(unicode,self.friends.allKeys())) while friendscount > 0: page = next_page(self.account.type, page, new_friends) #print "Fetching from friends page %i, %i updates remaining (%s)" % \ # (page, friendscount, self.service),"[%i]"%trys new_friends = get_friends( self.account.type, self.service, self.user, page) stop = False friendscount -= len(new_friends) if len(new_friends) == 0: trys += 1 for friend in new_friends: id = unicode(friend['screen_name']) if self.friends.contains(id): #print id, "(found)", self.service stop = True if id in old_friends: old_friends.remove(id) else: #print id, "(new)", self.service self.app.updates.add_timer("user",self.service,self.user,id) dump = json.dumps(clean_urls(friend)) self.friends.setValue(id, dump) if stop or trys > 3: break #self.yieldCurrentThread() for id in old_friends: #print id, "(lost)", self.service self.app.updates.remove_timer("user", self.service, self.user, id) self.friends.remove(id) #print "friends list up-to-date. (%s)" % self.service self.end()
def run(self): if not self.service or not self.user: self.quit() return trys = 0 page = -1 new_friends = None try: friendscount = api_call(self.service, 'users/show', {'id': self.user})['friends_count'] except: print_exc() self.end() return while friendscount > 0: page = next_page(self.service, page, new_friends) print "Fetching from friends page %i, %i updates remaining (%s)" % \ (page, friendscount, self.service),"[%i]"%trys new_friends = get_friends(self.service, self.user, page) stop = False friendscount -= len(new_friends) if len(new_friends) == 0: trys += 1 for friend in new_friends: id = str(friend['screen_name']) if self.friends.contains(id): print id, "(found)", self.service stop = True else: print id, "(new)", self.service dump = json.dumps(friend) self.friends.setValue(id, dump) if stop or trys > 3: break #self.yieldCurrentThread() print "friends list up-to-date. (%s)" % self.service self.end()
def run(self): if not self.user: self.quit() return trys = 0 new_groups = None while trys < 4: trys += 1 new_groups = get_group(self.user) if new_groups is not None: break if new_groups is None: self.end() return for group in new_groups: id = str(group['nickname']) if self.groups.contains(id): print id, "(found)" else: print id, "(new)" dump = json.dumps(clean_urls(group)) self.groups.setValue(id, dump) print "groups list up-to-date. (%s)" % self.user self.end()