Esempio n. 1
0
def main():
    args = parser_options().parse_args()
    PwmanCli, OSX = get_ui_platform(sys.platform)
    xselpath, dbtype, config = get_conf_options(args, OSX)
    dburi = config.get_value('Database', 'dburi')
    print(dburi)
    dbver = get_db_version(config, args)
    CryptoEngine.get()


    db = factory.createdb(dburi, dbver)

    if args.import_file:
        importer = Importer((args, config, db))
        importer.run()
        sys.exit(0)

    cli = PwmanCli(db, xselpath, CLICallback, config)

    try:
        cli.cmdloop()
    except KeyboardInterrupt as e:
        print(e)
    finally:
        config.save()
Esempio n. 2
0
File: cli.py Progetto: pwman3/pwman3
def main():
    args = parser_options().parse_args()
    PwmanCli, OSX = get_ui_platform(sys.platform)
    xselpath, dbtype, config = get_conf_options(args, OSX)
    dburi = config.get_value('Database', 'dburi')

    client_info = config.get_value('Updater', 'client_info')

    if not client_info:
        client_info = calculate_client_info()
        config.set_value('Updater', 'client_info', client_info)

    if not has_cryptography:
        import colorama
        if config.get_value('Crypto', 'supress_warning').lower() != 'yes':
            print("{}WARNING: You are not using PyCrypto!!!\n"
                  "WARNING: You should install PyCrypto for better security and "  # noqa
                  "perfomance\nWARNING: You can supress this warning by editing "  # noqa
                  "pwman config file.{}".format(colorama.Fore.RED,
                                                colorama.Style.RESET_ALL))

    if args.cmd == "version":
        latest = check_version(version, client_info)
        print("version: %s is latest: %s" % (version, latest))
        sys.exit(0)

    elif config.get_value('Updater',
                          'supress_version_check').lower() != 'yes':
        check_version(version, client_info)

    print(dburi)
    dbver = get_db_version(config, args)
    timeout = int(config.get_value('Global', 'lock_timeout'))
    CryptoEngine.get(timeout)

    db = factory.createdb(dburi, dbver)

    if args.file_delim:
        importer = Importer((args, config, db))
        importer.run()
        sys.exit(0)

    cli = PwmanCli(db, xselpath, CLICallback, config)

    if args.cmd == "p":
        cli.onecmd("pp %s" % args.node)
        sys.exit(0)

    if args.cmd == "cp":
        cli.onecmd("cp %s" % args.node)
        sys.exit(0)

    try:
        cli.cmdloop()
    except KeyboardInterrupt as e:
        print(e)
    finally:
        config.save()
Esempio n. 3
0
def main():
    args = parser_options().parse_args()
    PwmanCli, OSX = get_ui_platform(sys.platform)
    xselpath, dbtype, config = get_conf_options(args, OSX)
    dburi = config.get_value('Database', 'dburi')

    client_info = config.get_value('Updater', 'client_info')

    if not client_info:
        client_info = calculate_client_info()
        config.set_value('Updater', 'client_info', client_info)

    if not has_cryptography:
        import colorama
        if config.get_value('Crypto', 'supress_warning').lower() != 'yes':
            print(
                "{}WARNING: You are not using PyCrypto!!!\n"
                "WARNING: You should install PyCrypto for better security and "  # noqa
                "perfomance\nWARNING: You can supress this warning by editing "  # noqa
                "pwman config file.{}".format(colorama.Fore.RED,
                                              colorama.Style.RESET_ALL))

    if args.cmd == "version":
        latest = check_version(version, client_info)
        print("version: %s is latest: %s" % (version, latest))
        sys.exit(0)

    elif config.get_value('Updater', 'supress_version_check').lower() != 'yes':
        check_version(version, client_info)

    print(dburi)
    dbver = get_db_version(config, args)
    timeout = int(config.get_value('Global', 'lock_timeout'))
    CryptoEngine.get(timeout)

    db = factory.createdb(dburi, dbver)

    if args.file_delim:
        importer = Importer((args, config, db))
        importer.run()
        sys.exit(0)

    cli = PwmanCli(db, xselpath, CLICallback, config)

    if args.cmd == "p":
        cli.onecmd("pp %s" % args.node)
        sys.exit(0)

    if args.cmd == "cp":
        cli.onecmd("cp %s" % args.node)
        sys.exit(0)

    try:
        cli.cmdloop()
    except KeyboardInterrupt as e:
        print(e)
    finally:
        config.save()
Esempio n. 4
0
 def run(self):
     global AUTHENTICATED, TAGS, DB
     OSX = False
     print(sys.argv)
     args = parser_options().parse_args()
     xselpath, dburi, configp = get_conf_options(args, OSX)
     DB = pwman.data.factory.createdb(dburi, None)
     DB.open()
     print(dburi)
     print(dir(DB))
     CryptoEngine.get()
     debug(True)
     run(port=9030)
Esempio n. 5
0
 def test_all_config(self):
     sys.argv = ['pwman3']
     default_config['Database'] = {'type': '',
                                   'filename': ''}
     _save_conf = config._conf.copy()
     config._conf = {}
     with open('dummy.conf', 'w') as dummy:
         dummy.write(dummyfile)
     sys.argv = ['pwman3', '-d', '', '-c', 'dummy.conf']
     p2 = parser_options()
     args = p2.parse_args()
     self.assertRaises(Exception, get_conf_options, args, False)
     config._conf = _save_conf.copy()
     os.unlink('dummy.conf')
Esempio n. 6
0
    def run(self):
        global AUTHENTICATED, TAGS, DB

        OSX = False
        sys.argv = []

        args = parser_options().parse_args()
        xselpath, dbtype = get_conf_options(args, OSX)
        dbver = 0.5
        DB = pwman.data.factory.create(dbtype, dbver)
        DB.open(dbver=0.5)
        print(dir(DB))
        CryptoEngine.get(dbver=0.5)
        print(pwman.config._conf)
        debug(True)
        run(port=9030)