예제 #1
0
def main_menu():
    while 1:
        menu_title("Main\nEdit %s to\nchange descriptions or ofx options" %
                   GlobalConfig.file_name)

        accounts = GlobalConfig.accounts()
        for idx, account in enumerate(accounts):
            menu_item(idx, account.long_description())

        menu_item('A', 'Add an account')
        if accounts:
            menu_item('D', 'Download all combined')

        menu_item('Q', 'Quit')

        choice = prompt().lower()
        if choice == 'a':
            add_account_menu()
        elif choice == 'd':
            if not accounts:
                print("no accounts on file")
            else:
                ofxdata = combined_download(accounts, days=DOWNLOAD_DAYS)
                wrote = write_and_handle_download(
                    ofxdata,
                    'combined_download.ofx'
                )
                print("wrote: %s" % wrote)
        elif choice in ['q', '']:
            return
        elif int(choice) < len(accounts):
            account = accounts[int(choice)]
            view_account_menu(account)
예제 #2
0
파일: cli.py 프로젝트: cgiacofei/ofxclient
def main_menu(args):
    while 1:
        menu_title("Main\nEdit %s to\nchange descriptions or ofx options" %
                   GlobalConfig.file_name)

        accounts = GlobalConfig.accounts()
        for idx, account in enumerate(accounts):
            menu_item(idx, account.long_description())

        menu_item('A', 'Add an account')
        if accounts:
            menu_item('D', 'Download all combined')

        menu_item('Q', 'Quit')

        choice = prompt().lower()
        if choice == 'a':
            add_account_menu(args)
        elif choice == 'd':
            if not accounts:
                print("no accounts on file")
            else:
                ofxdata = combined_download(accounts, days=args.download_days)
                wrote = write_and_handle_download(ofxdata,
                                                  'combined_download.ofx')
                print("wrote: %s" % wrote)
        elif choice in ['q', '']:
            return
        elif int(choice) < len(accounts):
            account = accounts[int(choice)]
            view_account_menu(account, args)
예제 #3
0
def run():
    accounts = GlobalConfig.accounts()
    account_ids = [a.local_id() for a in accounts]

    parser = argparse.ArgumentParser(prog='ofxclient')
    parser.add_argument('-a', '--account', choices=account_ids)
    parser.add_argument('-d', '--download', type=argparse.FileType('wb', 0))
    parser.add_argument('-o', '--open', action='store_true')
    parser.add_argument('-v', '--verbose', action='store_true')
    args = parser.parse_args()

    if args.verbose:
        logging.basicConfig(level=logging.DEBUG)

    if args.download:
        if accounts:
            if args.account:
                a = GlobalConfig.account(args.account)
                ofxdata = a.download(days=DOWNLOAD_DAYS)
            else:
                ofxdata = combined_download(accounts, days=DOWNLOAD_DAYS)
            args.download.write(ofxdata.read())
            if args.open:
                open_with_ofx_handler(args.download.name)
            sys.exit(0)
        else:
            print("no accounts configured")

    main_menu()
예제 #4
0
def run():
    accounts = GlobalConfig.accounts()
    account_ids = [a.local_id() for a in accounts]

    parser = argparse.ArgumentParser(prog='ofxclient')
    parser.add_argument('-a', '--account', choices=account_ids)
    parser.add_argument('-d', '--download', type=argparse.FileType('wb', 0))
    parser.add_argument('-o', '--open', action='store_true')
    parser.add_argument('-v', '--verbose', action='store_true')
    args = parser.parse_args()

    if args.verbose:
        logging.basicConfig(level=logging.DEBUG)

    if args.download:
        if accounts:
            if args.account:
                a = GlobalConfig.account(args.account)
                ofxdata = a.download(days=DOWNLOAD_DAYS)
            else:
                ofxdata = combined_download(accounts, days=DOWNLOAD_DAYS)
            args.download.write(ofxdata.read())
            if args.open:
                open_with_ofx_handler(args.download.name)
            sys.exit(0)
        else:
            print("no accounts configured")

    main_menu()
예제 #5
0
파일: cli.py 프로젝트: ridler77/ofxclient
def main_menu(args):
    while 1:
        menu_title("Main\nEdit %s to\nchange descriptions or ofx options" % GlobalConfig.file_name)

        accounts = GlobalConfig.accounts()
        for idx, account in enumerate(accounts):
            menu_item(idx, account.long_description())

        menu_item("A", "Add an account")
        if accounts:
            menu_item("D", "Download all combined")

        menu_item("Q", "Quit")

        choice = prompt().lower()
        if choice == "a":
            add_account_menu(args)
        elif choice == "d":
            if not accounts:
                print("no accounts on file")
            else:
                ofxdata = combined_download(accounts, days=args.download_days)
                wrote = write_and_handle_download(ofxdata, "combined_download.ofx")
                print("wrote: %s" % wrote)
        elif choice in ["q", ""]:
            return
        elif int(choice) < len(accounts):
            account = accounts[int(choice)]
            view_account_menu(account, args)
예제 #6
0
 def download(self, account_id, filename_arbitrary, days=60):
     downloaded = None
     if account_id == 'combined':
         accounts = GlobalConfig.accounts()
         downloaded = combined_download(accounts, days=int(days))
     else:
         account = GlobalConfig.account(account_id)
         downloaded = account.download(days=int(days))
     cherrypy.response.headers['Content-Type'] = 'application/vnd.intu.QFX'
     cherrypy.lib.caching.expires(secs=0, force=True)
     return downloaded.read()
예제 #7
0
 def download(self,account_id,filename_arbitrary,days=60):
     downloaded = None
     if account_id == 'combined':
         accounts = GlobalConfig.accounts()
         downloaded = combined_download(accounts,days=int(days))
     else:
         account    = GlobalConfig.account(account_id)
         downloaded = account.download(days=int(days))
     cherrypy.response.headers['Content-Type'] = 'application/vnd.intu.QFX'
     cherrypy.lib.caching.expires(secs=0,force=True)
     return downloaded.read()
예제 #8
0
    def download_(self, sender):
        guid = sender._.representedObject

        outfile = open( os.path.expanduser( os.path.join('~', 'Downloads', 'ofxclient_%s.ofx' % guid) ), 'w' )
        if guid == 'combined':
            accounts = GlobalConfig.accounts()
            ofxdata = combined_download(accounts, days=30)
        else:
            account = GlobalConfig.account(guid)
            ofxdata = account.download(days=30)
        outfile.write(ofxdata.read())
        outfile.close()
        open_with_ofx_handler(outfile.name)
예제 #9
0
파일: cli.py 프로젝트: cgiacofei/ofxclient
def run():
    global GlobalConfig

    parser = argparse.ArgumentParser(prog='ofxclient')
    parser.add_argument('-a', '--account')
    parser.add_argument('-d', '--download', type=argparse.FileType('wb', 0))
    parser.add_argument('-o', '--open', action='store_true')
    parser.add_argument('-v', '--verbose', action='store_true')
    parser.add_argument('-c', '--config', help='config file path')
    parser.add_argument('--download-days',
                        default=DOWNLOAD_DAYS,
                        type=int,
                        help='number of days to download (default: %s)' %
                        DOWNLOAD_DAYS)
    parser.add_argument(
        '--ofx-version',
        default=DEFAULT_OFX_VERSION,
        type=int,
        help='ofx version to use for new accounts (default: %s)' %
        DEFAULT_OFX_VERSION)
    args = parser.parse_args()

    if args.config:
        GlobalConfig = OfxConfig(file_name=args.config)
    else:
        GlobalConfig = OfxConfig()

    accounts = GlobalConfig.accounts()
    account_ids = [a.local_id() for a in accounts]

    if args.verbose:
        logging.basicConfig(level=logging.DEBUG)

    if args.download:
        if accounts:
            if args.account:
                a = GlobalConfig.account(args.account)
                ofxdata = a.download(days=args.download_days)
            else:
                ofxdata = combined_download(accounts, days=args.download_days)
            if IS_PYTHON_2:
                args.download.write(ofxdata.read())
            else:
                args.download.write(ofxdata.read().encode())
            if args.open:
                open_with_ofx_handler(args.download.name)
            sys.exit(0)
        else:
            print("no accounts configured")

    main_menu(args)
예제 #10
0
파일: cli.py 프로젝트: ridler77/ofxclient
def run():
    global GlobalConfig

    parser = argparse.ArgumentParser(prog="ofxclient")
    parser.add_argument("-a", "--account")
    parser.add_argument("-d", "--download", type=argparse.FileType("wb", 0))
    parser.add_argument("-o", "--open", action="store_true")
    parser.add_argument("-v", "--verbose", action="store_true")
    parser.add_argument("-c", "--config", help="config file path")
    parser.add_argument(
        "--download-days",
        default=DOWNLOAD_DAYS,
        type=int,
        help="number of days to download (default: %s)" % DOWNLOAD_DAYS,
    )
    parser.add_argument(
        "--ofx-version",
        default=DEFAULT_OFX_VERSION,
        type=int,
        help="ofx version to use for new accounts (default: %s)" % DEFAULT_OFX_VERSION,
    )
    args = parser.parse_args()

    if args.config:
        GlobalConfig = OfxConfig(file_name=args.config)
    else:
        GlobalConfig = OfxConfig()

    accounts = GlobalConfig.accounts()
    account_ids = [a.local_id() for a in accounts]

    if args.verbose:
        logging.basicConfig(level=logging.DEBUG)

    if args.download:
        if accounts:
            if args.account:
                a = GlobalConfig.account(args.account)
                ofxdata = a.download(days=args.download_days)
            else:
                ofxdata = combined_download(accounts, days=args.download_days)
            args.download.write(ofxdata.read())
            if args.open:
                open_with_ofx_handler(args.download.name)
            sys.exit(0)
        else:
            print("no accounts configured")

    main_menu(args)
예제 #11
0
    def download_(self, sender):
        guid = sender._.representedObject

        outfile = open(
            os.path.expanduser(
                os.path.join('~', 'Downloads', 'ofxclient_%s.ofx' % guid)),
            'w')
        if guid == 'combined':
            accounts = GlobalConfig.accounts()
            ofxdata = combined_download(accounts, days=30)
        else:
            account = GlobalConfig.account(guid)
            ofxdata = account.download(days=30)
        outfile.write(ofxdata.read())
        outfile.close()
        open_with_ofx_handler(outfile.name)
예제 #12
0
파일: cli.py 프로젝트: captin411/ofxclient
def run():
    global GlobalConfig

    parser = argparse.ArgumentParser(prog='ofxclient')
    parser.add_argument('-a', '--account')
    parser.add_argument('-d', '--download', type=argparse.FileType('wb', 0))
    parser.add_argument('-o', '--open', action='store_true')
    parser.add_argument('-v', '--verbose', action='store_true')
    parser.add_argument('-c', '--config', help='config file path')
    parser.add_argument('--download-days', default=DOWNLOAD_DAYS, type=int, help='number of days to download (default: %s)' % DOWNLOAD_DAYS)
    parser.add_argument('--ofx-version', default=DEFAULT_OFX_VERSION, type=int, help='ofx version to use for new accounts (default: %s)' % DEFAULT_OFX_VERSION)
    args = parser.parse_args()

    if args.config:
        GlobalConfig = OfxConfig(file_name=args.config)
    else:
        GlobalConfig = OfxConfig()

    accounts = GlobalConfig.accounts()
    account_ids = [a.local_id() for a in accounts]

    if args.verbose:
        logging.basicConfig(level=logging.DEBUG)

    if args.download:
        if accounts:
            if args.account:
                a = GlobalConfig.account(args.account)
                ofxdata = a.download(days=args.download_days)
            else:
                ofxdata = combined_download(accounts, days=args.download_days)
            args.download.write(ofxdata.read().encode())
            if args.open:
                open_with_ofx_handler(args.download.name)
            sys.exit(0)
        else:
            print("no accounts configured")

    main_menu(args)