コード例 #1
0
 def _load_public_config(self):
     self.pub_config = ConfigDict(_rules=CONFIG_RULES)
     try:
         conffile = os.path.join(self.workdir, 'mailpile.rc')
         with open(conffile) as fd:
             self.pub_config.parse_config(None, fd.read(), source=conffile)
         self.base_url = 'http://%s:%s%s/' % (self.pub_config.sys.http_host,
                                              self.pub_config.sys.http_port,
                                              self.pub_config.sys.http_path)
     except:
         import traceback
         sys.stderr.write(traceback.format_exc())
コード例 #2
0
ファイル: autotag.py プロジェクト: pparent76/Omb-Mailpile
def autotag_configs(config):
    done = []
    for at_config in config.prefs.autotag:
        yield at_config
        done.append(at_config.match_tag)
    for tid, tag_info in config.tags.iteritems():
        auto_tagging = tag_info.auto_tag
        if (tid not in done
                and auto_tagging.lower() not in ('', 'off', 'false')):
            at_config = ConfigDict(_rules=AUTO_TAG_CONFIG)
            at_config.match_tag = tid
            at_config.tagger = auto_tagging
            yield at_config
コード例 #3
0
ファイル: autotag.py プロジェクト: mindriot101/Mailpile
def autotag_configs(config):
    done = []
    for at_config in config.prefs.autotag:
        yield at_config
        done.append(at_config.match_tag)
    for tid, tag_info in config.tags.iteritems():
        auto_tagging = tag_info.auto_tag
        if (tid not in done and
                auto_tagging.lower() not in ('', 'off', 'false')):
            at_config = ConfigDict(_rules=AUTO_TAG_CONFIG)
            at_config.match_tag = tid
            at_config.tagger = auto_tagging
            yield at_config
コード例 #4
0
class MailpileState(object):
    def __init__(self):
        self.base_url = 'http://localhost:33411/'
        self.workdir = DEFAULT_WORKDIR()
        self.secret = GetUserSecret(self.workdir)
        self.pub_config = None
        self.is_running = None

    def check_if_running(self):
        # FIXME: This is rather slow. We should refactor upstream to speed
        #        up or include our own custom parser if that is infeasible.
        wd_lock_path = LOCK_PATHS()[1]
        wd_lock = fasteners.InterProcessLock(wd_lock_path)
        try:
            if wd_lock.acquire(blocking=False):
                wd_lock.release()
                return False
            else:
                return True
        except (OSError, IOError):
            return False

    def _load_public_config(self):
        self.pub_config = ConfigDict(_rules=CONFIG_RULES)
        try:
            conffile = os.path.join(self.workdir, 'mailpile.rc')
            with open(conffile) as fd:
                self.pub_config.parse_config(None, fd.read(), source=conffile)
            self.base_url = 'http://%s:%s%s/' % (self.pub_config.sys.http_host,
                                                 self.pub_config.sys.http_port,
                                                 self.pub_config.sys.http_path)
        except:
            import traceback
            sys.stderr.write(traceback.format_exc())

    def discover(self, argv):
        self._load_public_config()
        self.is_running = self.check_if_running()
        self.http_port = self.pub_config.sys.http_port

        # Check if we have a screen session?

        return self
コード例 #5
0
ファイル: autotag.py プロジェクト: BjarniRunar/Mailpile
def autotag_configs(config):
    done = []
    for at_config in config.prefs.autotag:
        yield at_config
        done.append(at_config.match_tag)

    taggers = [k for k in TAGGERS.keys() if k != '_default']
    if not taggers:
        return

    for tid, tag_info in config.tags.iteritems():
        auto_tagging = (tag_info.auto_tag or '')
        if (tid not in done and auto_tagging.lower() not in AUTO_TAG_DISABLED):
            at_config = ConfigDict(_rules=AUTO_TAG_CONFIG)
            at_config.match_tag = tid
            if auto_tagging not in taggers:
                auto_tagging = taggers[0]
            at_config.tagger = auto_tagging
            at_config.trainer = auto_tagging
            yield at_config
コード例 #6
0
ファイル: autotag.py プロジェクト: DaLynX/Mailpile
def autotag_configs(config):
    done = []
    for at_config in config.prefs.autotag:
        yield at_config
        done.append(at_config.match_tag)

    taggers = [k for k in TAGGERS.keys() if k != '_default']
    if not taggers:
        return

    for tid, tag_info in config.tags.iteritems():
        auto_tagging = (tag_info.auto_tag or '')
        if (tid not in done and
                auto_tagging.lower() not in AUTO_TAG_DISABLED):
            at_config = ConfigDict(_rules=AUTO_TAG_CONFIG)
            at_config.match_tag = tid
            if auto_tagging not in taggers:
                auto_tagging = taggers[0]
            at_config.tagger = auto_tagging
            at_config.trainer = auto_tagging
            yield at_config
コード例 #7
0
                'process_new': (_('Is a potential source of new mail'), bool,
                                True),
                'apply_tags': (_('Tags applied to messages'), str, []),
                'max_mailboxes': (_('Max mailboxes to add'), int, 100),
            }),
            'mailbox': (_('Mailboxes'), {
                'name': (_('The name of this mailbox'), str, ''),
                'path': (_('Mailbox source path'), str, ''),
                'policy':
                (_('Mailbox policy'),
                 ['unknown', 'ignore', 'read', 'move', 'sync',
                  'inherit'], 'inherit'),
                'local': (_('Local mailbox path'), 'bin', ''),
                'process_new': (_('Is a source of new mail'), bool, True),
                'primary_tag': (_('A tag representing this mailbox'), str, ''),
                'apply_tags': (_('Tags applied to messages'), str, []),
            }, {})
        },
        {}
    ]
}

if __name__ == "__main__":
    import mailpile.config.defaults
    from mailpile.config.base import ConfigDict

    print '%s' % (ConfigDict(
        _name='mailpile',
        _comment='Base configuration',
        _rules=mailpile.config.defaults.CONFIG_RULES).as_config_bytes(), )