Beispiel #1
0
    def command(self):
        session, config = self.session, self.session.config

        session.interactive = True
        if sys.stdout.isatty() and sys.platform[:3] != "win":
            session.ui.term = ANSIColors()

        # Ensure we have a working GnuPG
        self._gnupg().common_args(will_send_passphrase=True)

        # Create and start the rest of the threads, load the index.
        if config.loaded_config:
            Load(session, '').run(quiet=True)
        else:
            config.prepare_workers(session, daemons=True)

        # Note: We do *not* update the MOTD on startup, to keep things
        #       fast, and to avoid leaking our IP on setup, before Tor
        #       has been configured.
        splash = HelpSplash(session, 'help', []).run()
        motd = MessageOfTheDay(session, 'motd', ['--noupdate']).run()
        session.ui.display_result(splash)
        print  # FIXME: This is a hack!
        session.ui.display_result(motd)

        Interact(session)

        return self._success(_('Ran interactive shell'))
Beispiel #2
0
    def command(self):
        session, config = self.session, self.session.config

        session.interactive = True
        if sys.stdout.isatty() and sys.platform != "win32":
            session.ui.term = ANSIColors()

        # Create and start the rest of the threads, load the index.
        if config.loaded_config:
            Load(session, '').run(quiet=True)
        else:
            config.prepare_workers(session, daemons=True)

        session.ui.display_result(HelpSplash(session, 'help', []).run())
        Interact(session)

        return self._success(_('Ran interactive shell'))
Beispiel #3
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)
Beispiel #4
0
            opts, args = getopt.getopt(args, shorta, longa)
            for opt, arg in opts:
                session.ui.display_result(Action(
                    session, opt.replace('-', ''), arg.decode('utf-8')))
            if args:
                session.ui.display_result(Action(
                    session, args[0], ' '.join(args[1:]).decode('utf-8')))

        except (getopt.GetoptError, UsageError), e:
            session.error(unicode(e))

        if not opts and not args:
            # Create and start the rest of the threads, load the index.
            session.interactive = session.ui.interactive = True
            if sys.stdout.isatty():
                session.ui.term = ANSIColors()

            config.prepare_workers(session, daemons=True)
            Load(session, '').run(quiet=True)
            session.ui.display_result(HelpSplash(session, 'help', []).run())
            Interact(session)

    except KeyboardInterrupt:
        pass

    finally:
        if session.interactive and config.sys.debug:
            session.ui.display_result(Action(session, 'ps', ''))
            if readline:
                readline.write_history_file(session.config.history_file())