Ejemplo n.º 1
0
    def main(self):
        yield self.initComponents()

        while 1:
            if self.dataReady("control"):
                mes = self.recv("control")
                
                if isinstance(mes, shutdownMicroprocess) or \
                        isinstance(mes, producerFinished):
                    self.send(producerFinished(), "signal")
                    break

            if self.dataReady("inbox"):
                feed = self.recv('inbox')
                for entry in feed.entries:
                    for link in entry.links:
                        if link.rel == 'edit-media' and link.type == 'application/xml':
                            profile_name = urlparse(link.href)[2].rsplit('/', -1)[-1]
                            pwd = ProfileManager.set_profile_password(self.base_dir, profile_name)
                            profile = ProfileManager.load_profile(self.base_dir, self.atompub, profile_name)
                            Client.register_jabber_user(self.atompub, profile_name.lower(), pwd, profile)

                            params = {'url': link.href, 'method': 'DELETE'}
                            self.send(params, '_request') 
                            
                            continue
                
            if not self.anyReady():
                self.pause()
  
            yield 1