def Main(args): # Bootstrap translations until we've loaded everything else translation = gettext.translation("mailpile", getLocaleDirectory(), fallback=True) translation.install(unicode=True) try: # Create our global config manager and the default (CLI) session config = ConfigManager(rules=mailpile.defaults.CONFIG_RULES) session = Session(config) session.config.load(session) session.main = True session.ui = UserInteraction(config) if sys.stdout.isatty(): session.ui.palette = ANSIColors() except AccessError, e: sys.stderr.write("Access denied: %s\n" % e) sys.exit(1)
def _check_profiles(self, config): session = Session(config) session.ui = SilentInteraction(config) session.ui.block() data = ListProfiles(session).run().result okay = routes = bad = 0 for rid, ofs in data["rids"].iteritems(): profile = data["profiles"][ofs] if profile.get('email', None): okay += 1 route_id = profile.get('x-mailpile-profile-route', '') if route_id: if route_id in config.routes: routes += 1 else: bad += 1 else: bad += 1 return (routes > 0) and (okay > 0) and (bad == 0)
def _check_profiles(self, config): session = Session(config) session.ui = SilentInteraction(config) session.ui.block() data = ListProfiles(session).run().result okay = routes = bad = 0 for rid, ofs in data["rids"].iteritems(): profile = data["profiles"][ofs] if profile.get('email', None): okay += 1 route_id = profile.get('x-mailpile-profile-route', '') if route_id: if route_id in config.routes: routes += 1 else: bad += 1 else: bad += 1 return (routes > 0) and (okay > 0) and (bad == 0)
def Main(args): # Bootstrap translations until we've loaded everything else translation = gettext.translation("mailpile", getLocaleDirectory(), fallback=True) translation.install(unicode=True) try: # Create our global config manager and the default (CLI) session config = ConfigManager(rules=mailpile.defaults.CONFIG_RULES) session = Session(config) session.config.load(session) session.main = True session.ui = UserInteraction(config) if sys.stdout.isatty(): session.ui.palette = ANSIColors() except AccessError, e: sys.stderr.write('Access denied: %s\n' % e) sys.exit(1)
def do_GET(self, post_data={}, suppress_body=False): (scheme, netloc, path, params, query, frag) = urlparse(self.path) query_data = parse_qs(query) cmd = self.parse_pqp(path, query_data, post_data, self.server.session.config) session = Session(self.server.session.config) session.ui = HtmlUI() index = session.config.get_index(session) if cmd: try: for arg in cmd.split(' /'): args = arg.strip().split() Action(session, args[0], ' '.join(args[1:])) body = session.ui.render_html() title = 'The biggest pile of mail EVAR!' except UsageError, e: body = 'Oops: %s' % e title = 'Ouch, too much mail, urgle, *choke*'
infiles = outfiles = [] try: infiles = sys.argv[1:-1] outpath = sys.argv[-1] except: pass if ((not infiles or not outpath) or (os.path.exists(outpath) and not os.path.isdir(outpath)) or (len(infiles) > 1 and not os.path.isdir(outpath))): sys.stderr.write(__doc__) sys.exit(1) # Basic app bootstrapping config = ConfigManager(rules=CONFIG_RULES) session = Session(config) session.ui = UserInteraction(config) # Get the password, verify it, decrypt config fails = 0 for tries in range(1, 4): try: VerifyAndStorePassphrase(config, passphrase=session.ui.get_password( _('Your password: '******'Incorrect, try again?') fails = tries if fails == tries: sys.exit(1)