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()
def test_get_conf_options(self): Args = namedtuple('args', 'cfile, dbase, algo') args = Args(cfile='nosuchfile', dbase='dummy.db', algo='AES') self.assertRaises(Exception, get_conf_options, (args, 'False')) config._defaults['Database']['type'] = 'SQLite' # config._conf['Database']['type'] = 'SQLite' xsel, dbtype = get_conf_options(args, 'True') self.assertEqual(dbtype, 'SQLite')
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()
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()
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)
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)
def test_get_conf_options(self): Args = namedtuple('args', 'cfile, dbase, algo') args = Args(cfile='dummy.cfg', dbase='dummy.db', algo='AES') xsel, dburi, configp = get_conf_options(args, 'True') self.assertEqual(dburi, 'dummy.db')
def test_set_xsel(self): Args = namedtuple('args', 'cfile, dbase, algo') args = Args(cfile='dummy.cfg', dbase='dummy.db', algo='AES') xsel, dbtype, configp = get_conf_options(args, 'True') set_xsel(configp, False) set_xsel(configp, True)