示例#1
0
 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))
示例#2
0
 def _idx(self, **kwargs):
     return self.session.search_index or Command._idx(self)
示例#3
0
 def _success(self, message, result=None):
     return Command._success(self, message, result=self._result(result))
示例#4
0
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)
示例#5
0
 def state_as_query_args(self):
     try:
         return self._search_state
     except (AttributeError, NameError):
         return Command.state_as_query_args(self)
示例#6
0
 def cache_id(self, *args, **kwargs):
     if self._emails:
         return ''
     return Command.cache_id(self, *args, **kwargs)
示例#7
0
    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]
示例#8
0
文件: auth.py 项目: Videl/Mailpile
 def _success(self, message, result=None):
     return Command._success(self, message, result=self._result(result))
示例#9
0
    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]
示例#10
0
 def cache_id(self, *args, **kwargs):
     if self._emails:
         return ""
     return Command.cache_id(self, *args, **kwargs)
示例#11
0
 def __init__(self, *args, **kwargs):
     Command.__init__(self, *args, **kwargs)
     self._email_views = []
     self._email_view_pairs = {}
     self._emails = []
示例#12
0
 def cache_id(self, *args, **kwargs):
     if self._emails or self.session.search_index:
         return ''
     return Command.cache_id(self, *args, **kwargs)
示例#13
0
 def _idx(self, **kwargs):
     return self.session.search_index or Command._idx(self)
示例#14
0
 def cache_id(self, *args, **kwargs):
     if self._emails or self.session.search_index:
         return ''
     return Command.cache_id(self, *args, **kwargs)
示例#15
0
 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))
示例#16
0
文件: auth.py 项目: Videl/Mailpile
 def _error(self, message, info=None, result=None):
     return Command._error(self, message,
                           info=info, result=self._result(result))
示例#17
0
 def state_as_query_args(self):
     return Command.state_as_query_args(self)
示例#18
0
 def __init__(self, *args, **kwargs):
     Command.__init__(self, *args, **kwargs)
     self._email_views = []
     self._email_view_pairs = {}
     self._emails = []
示例#19
0
 def state_as_query_args(self):
     try:
         return self._search_state
     except (AttributeError, NameError):
         return Command.state_as_query_args(self)
示例#20
0
    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]
示例#21
0
 def _error(self, message, info=None, result=None):
     return Command._error(self,
                           message,
                           info=info,
                           result=self._result(result))
示例#22
0
 def state_as_query_args(self):
     return Command.state_as_query_args(self)
示例#23
0
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)