def testConnection(self):
        import mailindicator.config as config
        config.load()

        try:
            username = os.environ['username']
        except KeyError:
            raise Exception('Missing required username')
        try:
            userpassword = os.environ['userpassword']
        except KeyError:
            raise Exception('Missing required userpassword')

        fetcher = GMailFeedFetcher('GMAIL', username=username, userpassword=userpassword)
        mails = fetcher.fetchmail()
        print(mails)
Example #2
0
def main():
    """Main function"""

    args = _parse_cmdline()

    if args.debug:
        logging.set_level(logging.DEBUG)
    elif args.quiet:
        logging.set_level(logging.NONE)
    else:
        logging.set_level(logging.INFO)

    if args.file:
        config.load(args.file)
    else:
        config.load()

    logging.info("Mailindicator started.")

    mailboxes = config.mailboxes
    monitors = []

    if len(mailboxes) > 0:
        status_icon = StatusIcon()

        for mailbox in mailboxes:
            mb_monitor = MailboxMonitor(status_icon,
                                        mailbox.label,
                                        mailbox.sleep_time,
                                        mailbox.fetcher.fetchmail)
            mb_monitor.start()
            monitors.append(mb_monitor)

        status_icon.set_monitors(monitors)

        Gdk.threads_init()
        Gtk.main()