def _error(self, message, info=None, result=None): global LOGIN_FAILURES LOGIN_FAILURES.append(int(time.time())) return Command._error(self, message, info=info, result=self._result(result))
def _idx(self, **kwargs): return self.session.search_index or Command._idx(self)
def _success(self, message, result=None): return Command._success(self, message, result=self._result(result))
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)
def state_as_query_args(self): try: return self._search_state except (AttributeError, NameError): return Command.state_as_query_args(self)
def cache_id(self, *args, **kwargs): if self._emails: return '' return Command.cache_id(self, *args, **kwargs)
def _starting(self): Command._starting(self) session, idx = self.session, self._idx() self._search_args = args = [] self.context = self.data.get('context', [None])[0] if self.context: args += self.session.searched def nq(t): p = t[0] if (t and t[0] in '-+') else '' t = t[len(p):] if t.startswith('tag:') or t.startswith('in:'): try: t = 'in:%s' % session.config.get_tag(t.split(':')[1]).slug except (IndexError, KeyError, TypeError): pass return p+t args += [a for a in list(nq(a) for a in self.args) if a not in args] for q in self.data.get('q', []): ext = [nq(a) for a in q.split()] args.extend([a for a in ext if a not in args]) # Query refinements... qrs = [] for qr in self.data.get('qr', []): qrs.extend(nq(a) for a in qr.split()) args.extend(qrs) for order in self.data.get('order', []): session.order = order num = def_num = session.config.prefs.num_results d_start = int(self.data.get('start', [0])[0]) d_end = int(self.data.get('end', [0])[0]) if d_start and d_end: args[:0] = ['@%s' % d_start] num = d_end - d_start + 1 elif d_start: args[:0] = ['@%s' % d_start] elif d_end: args[:0] = ['@%s' % (d_end - num + 1)] start = 0 while args and args[0].startswith('@'): spoint = args.pop(0)[1:] try: start = int(spoint) - 1 except ValueError: raise UsageError(_('Weird starting point: %s') % spoint) session.order = session.order or session.config.prefs.default_order self._start = start self._num = num self._search_state = { 'q': [q for q in args if q not in qrs], 'qr': qrs, 'order': [session.order], 'start': [str(start + 1)] if start else [], 'end': [str(start + num)] if (num != def_num) else [] } if self.context: self._search_state['context'] = [self.context]
def _starting(self): Command._starting(self) session, idx = self.session, self._idx() self._search_args = args = [] self._email_views = self.data.get("view", []) self._email_view_pairs = dict((m.split("/")[0], m.split("/")[-1]) for m in self._email_views) self._emails = [] self.context = self.data.get("context", [None])[0] if self.context: args += self.session.searched def nq(t): p = t[0] if (t and t[0] in "-+") else "" t = t[len(p) :] if t.startswith("tag:") or t.startswith("in:"): try: raw_tag = session.config.get_tag(t.split(":")[1]) if raw_tag and raw_tag.hasattr(slug): t = "in:%s" % raw_tag.slug except (IndexError, KeyError, TypeError): pass return p + t args += [a for a in list(nq(a) for a in self.args) if a not in args] for q in self.data.get("q", []): ext = [nq(a) for a in q.split()] args.extend([a for a in ext if a not in args]) # Query refinements... qrs = [] for qr in self.data.get("qr", []): qrs.extend(nq(a) for a in qr.split()) args.extend(qrs) for order in self.data.get("order", []): session.order = order num = def_num = session.config.prefs.num_results d_start = int(self.data.get("start", [0])[0]) d_end = int(self.data.get("end", [0])[0]) if d_start and d_end: args[:0] = ["@%s" % d_start] num = d_end - d_start + 1 elif d_start: args[:0] = ["@%s" % d_start] elif d_end: args[:0] = ["@%s" % (d_end - num + 1)] start = 0 self._default_position = True while args and args[0].startswith("@"): spoint = args.pop(0)[1:] try: start = int(spoint) - 1 self._default_position = False except ValueError: raise UsageError(_("Weird starting point: %s") % spoint) session.order = session.order or session.config.prefs.default_order self._start = start self._num = num self._search_state = { "q": [q for q in args if q not in qrs], "qr": qrs, "order": [session.order], "start": [str(start + 1)] if start else [], "view": self._email_views, "end": [str(start + num)] if (num != def_num) else [], } if self.context: self._search_state["context"] = [self.context]
def cache_id(self, *args, **kwargs): if self._emails: return "" return Command.cache_id(self, *args, **kwargs)
def __init__(self, *args, **kwargs): Command.__init__(self, *args, **kwargs) self._email_views = [] self._email_view_pairs = {} self._emails = []
def cache_id(self, *args, **kwargs): if self._emails or self.session.search_index: return '' return Command.cache_id(self, *args, **kwargs)
def _error(self, message, info=None, result=None): return Command._error(self, message, info=info, result=self._result(result))
def state_as_query_args(self): return Command.state_as_query_args(self)
def _starting(self): Command._starting(self) session, idx = self.session, self._idx() self._search_args = args = [] self._email_views = self.data.get('view', []) self._email_view_pairs = dict( (m.split('/')[0], m.split('/')[-1]) for m in self._email_views) self._emails = [] self.context = self.data.get('context', [None])[0] if self.context: args += self.session.searched def nq(t): p = t[0] if (t and t[0] in '-+') else '' t = t[len(p):] if t.startswith('tag:') or t.startswith('in:'): try: raw_tag = session.config.get_tag(t.split(':')[1]) if raw_tag and raw_tag.hasattr(slug): t = 'in:%s' % raw_tag.slug except (IndexError, KeyError, TypeError): pass return p + t args += [a for a in list(nq(a) for a in self.args) if a not in args] for q in self.data.get('q', []): ext = [nq(a) for a in q.split()] args.extend([a for a in ext if a not in args]) # Query refinements... qrs = [] for qr in self.data.get('qr', []): qrs.extend(nq(a) for a in qr.split()) args.extend(qrs) for order in self.data.get('order', []): session.order = order num = def_num = session.config.prefs.num_results d_start = int(self.data.get('start', [0])[0]) d_end = int(self.data.get('end', [0])[0]) if d_start and d_end: args[:0] = ['@%s' % d_start] num = d_end - d_start + 1 elif d_start: args[:0] = ['@%s' % d_start] elif d_end: args[:0] = ['@%s' % (d_end - num + 1)] start = 0 self._default_position = True while args and args[0].startswith('@'): spoint = args.pop(0)[1:] try: start = int(spoint) - 1 self._default_position = False except ValueError: raise UsageError(_('Weird starting point: %s') % spoint) session.order = session.order or session.config.prefs.default_order self._start = start self._num = num self._search_state = { 'q': [q for q in args if q not in qrs], 'qr': qrs, 'order': [session.order], 'start': [str(start + 1)] if start else [], 'view': self._email_views, 'end': [str(start + num)] if (num != def_num) else [] } if self.context: self._search_state['context'] = [self.context]
session.main = True config.clean_tempfile_dir() config.load(session) session.config=cfg 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)