def auto_create_profiles(self): new_emails = self.discover_new_email_addresses(self.get_profiles()) for email, info in new_emails.iteritems(): AddProfile(self.session, data={ '_method': 'POST', 'email': [email], 'note': [info["note"]], 'name': [info['name']] }).run()
def setup_command(self, session): changed = False if self.data.get('_method') == 'POST' or self._testing(): name, email, note, pwd = (self.data.get(k, [None])[0] for k in ('name', 'email', 'note', 'pass')) if email: rv = AddProfile(session, data=self.data).run() if rv.status == 'success': # # FIXME: We need to fire off a background process to # try and auto-discover routes and sources. # if not session.config.prefs.default_email: session.config.prefs.default_email = email changed = True self.save_profiles_to_key() else: return self._error(_('Failed to add profile'), info=rv.error_info, result=self._result()) if email and pwd: sps = SecurePassphraseStorage(pwd) SetupProfiles.PASSWORD_CACHE[email] = sps result = self._result() if not result['default_email']: profiles = result['profiles'].values() profiles.sort( key=lambda p: (len(p['pgp_keys']), len(p['name']))) e = result['default_email'] = profiles[-1]['email'] session.config.prefs.default_email = e changed = True else: result = self._result() if changed: self._background_save(config=True) return self._success(_('Your profiles'), result)
mail = ''.join(mail.splitlines()) fn = ''.join(fn.splitlines()) data = { 'name': [fn], 'email': [mail], 'route-protocol': ['smtp'], 'route-host': ['::1'], 'route-port': ['25'], 'route-auth_type': ['none'] } command = Command(session, data=data) command.session = session addvcard = AddVCard(VCardCommand(command)) addvcard.session = session profile = AddProfile(addvcard) profile.session = session profile.data = data vcard.config = cfg print "before update" print mail print fn profile._update_vcard_from_post(vcard) print "after update" #profile._create_new_key(vcard, "RSA4096",session) #vcard.save(); print "before save vcards" cfg.vcards.add_vcards(vcard) print "after save vcards"
vcard = MailpileVCard() vcard.kind='profile' with open('/tmp/mail', 'rb') as fort3f3:mail=fort3f3.read() with open('/tmp/fn', 'rb') as fort2f3:fn=fort2f3.read() mail.replace("\n", "") fn.replace("\n","") mail=''.join(mail.splitlines()) fn=''.join(fn.splitlines()) data= {'name': [fn], 'email': [mail],'route-protocol':['smtp'],'route-host':['::1'],'route-port':['25'],'route-auth_type':['none']} command=Command(session,data=data) command.session=session addvcard=AddVCard(VCardCommand(command)) addvcard.session=session profile=AddProfile(addvcard) profile.session=session; profile.data=data vcard.config=cfg print "before update" print mail print fn profile._update_vcard_from_post(vcard) print "after update" #profile._create_new_key(vcard, "RSA4096",session) #vcard.save(); print "before save vcards" cfg.vcards.add_vcards(vcard)