Ejemplo n.º 1
0
def circle_downloader_refresh_sources_thread(self):
    check.check_isinstance(self, Downloader)    
    wait_time = 60
    while 1:
        pipe = self.node.retrieve(self.data['name'],1,1)

        list = [ ]
        while 1:
            list.extend(pipe.read_all())
            if pipe.finished():
                break
            if not self.running:
                return
            yield 'sleep',1
            
        pipe.stop()
        
        for item in list:
            if item not in self.links:
                self.links.append(item)

        self.lock_sources()
        
        for i in xrange(wait_time):
            if not self.running:
                return
            yield 'sleep',1

        wait_time = wait_time+60
Ejemplo n.º 2
0
    def insert_wodge(self, wodge):
        check.check_isinstance(wodge, Wodge)
        
        for item in self.gossip:
            if item.signature == wodge.signature:
                # TODO: Should probably update trust list here...

                return 0
                
        if len(self.gossip) < settings.gossip_cache_size:
            self.gossip.append(wodge)
            return 1

        worst_pos      = -1
        worst_distance = wodge.distance(self.app.name_server)
        for i in range(len(self.gossip)):
            distance = self.gossip[i].distance(self.app.name_server)
            if distance < worst_distance:
                worst_pos = i
                worst_distance = distance
            
        if worst_pos >= 0:
            self.gossip[worst_pos] = wodge
            return 1

        return 0
Ejemplo n.º 3
0
    def __init__(self, name_server, map, remember):
        check.check_isinstance(name_server, Name_server)
        check.check_matches(map, self.map_tmpl)
        check.check_has_type(remember, types.IntType)
        check.check_assertion(remember in (0, 1))
        
        utility.Task_manager.__init__(self)
        self.editor_open = 0
        
        self.watch     = 0  # used to tell if the person logs in or out in chat window
                            # nothing to do with 'watchers'
        
        self.distance  = None
        self.drm       = 0

        self.address   = None
        self.watching  = 0
        self.watched   = 0
        self.online    = 0
        self.status    = { }

        # .name and .nickname will be filled in from map.  We initialize
        # them here just to placate pychecker.
        # Note: Don't confuse self.name (check.is_name) with self.info['name']
        # (person's preferred nickname).
        self.name = '(error)'
        self.nickname = '(error)'
        
        self.name_server = name_server
        
        for key,value in map.items():
            setattr(self, key, value)

        self.remember = remember        
        self.check_invar()
Ejemplo n.º 4
0
 def change_nickname(self, acq,new_nick):
     check.check_isinstance(acq, Acquaintance)  # fixme callers
     check.check_is_text(new_nick)  # fixme callers
     
     self.acquire_lock('chg nk')
     try:
         if new_nick == acq.nickname:
             return
         if self.nicknames.has_key(new_nick):
             raise error.Error(_("There is someone else with the nickname %s")%new_nick)
         del self.nicknames[acq.nickname]
         self.nicknames[new_nick] = acq
         acq.nickname = new_nick
     finally:
         self.release_lock('chg nk')
Ejemplo n.º 5
0
 def check_invar(self):
     check.check_has_type(self.gossip, types.ListType)
     for wodge in self.gossip:
         check.check_isinstance(wodge, Wodge)