def get_mint_client(args): email = args.mint_email password = args.mint_password if not email: email = input('Mint email: ') if not password: password = keyring.get_password(KEYRING_SERVICE_NAME, email) if not password: password = getpass.getpass('Mint password: '******'Missing Mint email or password.') exit(1) asyncSpin = AsyncProgress(Spinner('Logging into Mint ')) mint_client = Mint.create(email, password) # On success, save off password to keyring. keyring.set_password(KEYRING_SERVICE_NAME, email, password) asyncSpin.finish() return mint_client
def get_mint_client(args): email = args.mint_email password = args.mint_password if not email: email = os.getenv('MINT_EMAIL', None) if not email: email = input('Mint email: ') # This was causing my grief. Let's let it rest for a while. # if not password: # password = keyring.get_password(KEYRING_SERVICE_NAME, email) if not password: password = getpass.getpass('Mint password: '******'Missing Mint email or password.') exit(1) asyncSpin = AsyncProgress(Spinner('Logging into Mint ')) mint_client = Mint.create(email, password) # On success, save off password to keyring. keyring.set_password(KEYRING_SERVICE_NAME, email, password) asyncSpin.finish() return mint_client
def get_mintapi(self): if self.mintapi: return self.mintapi email = self.email password = self.password if not email: email = input('Mint email: ') if not password: password = getpass.getpass('Mint password: '******'Missing Mint email or password.') exit(1) logger.info('Logging into Mint') logger.info('You may be asked for an auth code at the command line! ' 'Be sure to press ENTER after typing the 6 digit code.') mint_client = Mint.create(email, password, mfa_method=self.mfa_method, session_path=self.session_path, headless=self.headless, wait_for_sync=self.wait_for_sync) def close_mint_client(): if mint_client: mint_client.close() atexit.register(close_mint_client) self.mintapi = mint_client return mint_client
def get_mintapi(self): if self.mintapi: return self.mintapi email = self.email password = self.password if not email: email = input('Mint email: ') if not password: password = getpass.getpass('Mint password: '******'Missing Mint email or password.') exit(1) logger.info('You may be asked for an auth code at the command line! ' 'Be sure to press ENTER after typing the 6 digit code.') login_progress = self.progress_factory('Logging into Mint', 0) # The cwd when installed on a users system is typically not writable. # HACK: Pass through desired download location once that's supported. cwd = os.getcwd() os.chdir(os.path.expanduser("~")) mint_client = Mint.create(email, password, mfa_method=self.mfa_method, mfa_input_callback=self.mfa_input_callback, session_path=self.session_path, headless=self.headless, wait_for_sync=self.wait_for_sync) os.chdir(cwd) login_progress.finish() def close_mint_client(): if mint_client: mint_client.close() atexit.register(close_mint_client) self.mintapi = mint_client return mint_client
def main(): options = parse_arguments(sys.argv[1:]) # Try to get the e-mail and password from the arguments email = options.email password = options.password imap_account = options.imap_account imap_password = options.imap_password mfa_method = options.mfa_method validate_file_extensions(options) if not email: # If the user did not provide an e-mail, prompt for it email = input("Mint e-mail: ") password = handle_password("mintapi", "Mint password: "******"email" and imap_account: imap_password = handle_password( "mintapi_imap", "IMAP password: "******"None": session_path = None else: session_path = options.session_path mint = Mint( email, password, mfa_method=mfa_method, mfa_token=options.mfa_token, session_path=session_path, headless=options.headless, imap_account=imap_account, imap_password=imap_password, imap_server=options.imap_server, imap_folder=options.imap_folder, wait_for_sync=not options.no_wait_for_sync, wait_for_sync_timeout=options.wait_for_sync_timeout, use_chromedriver_on_path=options.use_chromedriver_on_path, chromedriver_download_path=options.chromedriver_download_path, ) atexit.register(mint.close) # Ensure everything is torn down. if options.imap_test: mfa_code = get_email_code( imap_account, imap_password, options.imap_server, imap_folder=options.imap_folder, delete=False, ) print("MFA CODE:", mfa_code) sys.exit() data = None if options.accounts and options.budgets: try: accounts = make_accounts_presentable( mint.get_accounts(get_detail=options.accounts_ext)) except Exception: accounts = None try: budgets = mint.get_budgets() except Exception: budgets = None data = {"accounts": accounts, "budgets": budgets} elif options.budgets: try: data = mint.get_budgets() except Exception: data = None elif options.budget_hist: try: data = mint.get_budgets(hist=12) except Exception: data = None elif options.accounts: try: data = make_accounts_presentable( mint.get_accounts(get_detail=options.accounts_ext)) except Exception: data = None elif options.transactions: data = mint.get_transactions( start_date=options.start_date, end_date=options.end_date, include_investment=options.include_investment, ) elif options.extended_transactions: data = mint.get_detailed_transactions( start_date=options.start_date, end_date=options.end_date, include_investment=options.include_investment, remove_pending=options.show_pending, skip_duplicates=options.skip_duplicates, ) elif options.categories: data = mint.get_categories() elif options.investments: data = mint.get_investment_data() elif options.net_worth: data = mint.get_net_worth() elif options.credit_score: data = mint.get_credit_score() elif options.credit_report: data = mint.get_credit_report( details=True, exclude_inquiries=options.exclude_inquiries, exclude_accounts=options.exclude_accounts, exclude_utilization=options.exclude_utilization, ) attention_msg = None if options.attention: attention_msg = mint.get_attention() output_data(options, data, attention_msg)