def doRequestRemoteID(self, arg): if isinstance(arg, str): idurl = arg identitycache.immediatelyCaching(idurl).addCallbacks( lambda src: self.automat('remote-id-received', idurl), lambda x: self.automat('remote-id-failed', x)) else: for idurl in arg[1]: if idurl == misc.getLocalID(): continue if idurl not in arg[0]: identitycache.immediatelyCaching(idurl).addCallbacks( lambda src: self.automat('remote-id-received', idurl), lambda x: self.automat('remote-id-failed', x))
def update_contacts(): lg.out(10, 'http_node.update_contacts ') global _Contacts _Contacts.clear() def update_contact(x, idurl): add_contact(idurl) def failed(x, idurl): lg.out(10, 'http_node.update_contacts.failed NETERROR ' + idurl) contacts_list = contacts.getContactIDs() contacts_list.append(settings.CentralID()) contacts_list.append(settings.MoneyServerID()) contacts_list.append(settings.MarketServerID()) for idurl in contacts_list: lg.out(10, 'http_node.update_contacts want ' + idurl) if idurl == misc.getLocalID(): continue ident = contacts.getContact(idurl) if ident is None: d = identitycache.immediatelyCaching(idurl) d.addCallback(update_contact, idurl) d.addErrback(failed, idurl) continue update_contact('', idurl)
def update_contacts(): dhnio.Dprint(10, 'transport_http.update_contacts ') global _Contacts _Contacts.clear() def update_contact(x, idurl): add_contact(idurl) def failed(x, idurl): dhnio.Dprint(10, 'transport_http.update_contacts.failed NETERROR ' + idurl) contacts_list = contacts.getContactIDs() contacts_list.append(settings.CentralID()) contacts_list.append(settings.MoneyServerID()) contacts_list.append(settings.MarketServerID()) for idurl in contacts_list: dhnio.Dprint(10, 'transport_http.update_contacts want ' + idurl) if idurl == misc.getLocalID(): continue ident = contacts.getContact(idurl) if ident is None: d = identitycache.immediatelyCaching(idurl) d.addCallback(update_contact, idurl) d.addErrback(failed, idurl) continue update_contact('', idurl)
def add_identity2db(idlist): def _add_ok(src, idurl): # words = src.split('\n', 1) # if len(words) < 1: # dhnio.Dprint(1, 'transport_ssh.add_key ERROR wrong data') # return # ident = identitycache.FromCache(words[0].strip()) ident = identitycache.FromCache(idurl) if ident == '' or ident is None: dhnio.Dprint(1, 'transport_ssh.add_key ERROR still not in the cache') return add_key(ident.getIDURL(),ident.publickey) def _add_fail(x, idurl): dhnio.Dprint(10, 'transport_ssh.add_key WARNING adding ssh key for ' + idurl) for idurl in idlist: if idurl.strip() == '': continue ident = identitycache.FromCache(idurl) if ident == '' or ident is None: d = identitycache.immediatelyCaching(idurl) d.addCallback(_add_ok, idurl) d.addErrback(_add_fail, idurl) continue add_key(ident.getIDURL(),ident.publickey)
def _request_remote_id(idurl): print '+++++ REQUEST ID FROM SERVER', idurl return identitycache.immediatelyCaching(idurl)