def test_factory_createdb_postgresql(self): db = factory.createdb("postgresql:///pwman", 0.6) self.assertIsInstance(db, PostgresqlDatabase) del db db = factory.createdb("postgresql:///pwman", 0.7) self.assertIsInstance(db, PostgresqlDatabase) del db
def test_factory_createdb(self): db = factory.createdb("sqlite:///test.db", 0.6) self.assertIsInstance(db, SQLite) del db db = factory.createdb("sqlite:///test.db", 0.7) self.assertIsInstance(db, SQLite) del db
def setUp(self): "test that the right db instance was created" self.dbtype = 'sqlite' self.db = factory.createdb('sqlite://' + os.path.abspath(testdb), __DB_FORMAT__) self.tester = SetupTester(__DB_FORMAT__, dburi=testdb) self.tester.create()
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 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 test_factory_create(self): fn = os.path.join(os.path.dirname(__file__), 'foo.db') db = factory.createdb('sqlite://' + os.path.abspath(fn), 0.6) db._open() self.assertTrue(os.path.exists(fn)) db.close() os.unlink(fn) self.assertIsInstance(db, SQLite) self.assertRaises(DatabaseException, factory.createdb, *('UNKNOWN', __DB_FORMAT__))
def test_factory_create(self): fn = os.path.join(os.path.dirname(__file__), 'foo.db') db = factory.createdb('sqlite://'+os.path.abspath(fn), 0.6) db._open() self.assertTrue(os.path.exists(fn)) db.close() os.unlink(fn) self.assertIsInstance(db, SQLite) self.assertRaises(DatabaseException, factory.createdb, *('UNKNOWN', __DB_FORMAT__))
def test_factory_check_db_file(self): fn = os.path.join(os.path.dirname(__file__), 'baz.db') db = factory.createdb('sqlite:///' + os.path.abspath(fn), 0.3) db._open() self.assertEqual(factory.check_db_version('sqlite:///' + fn), 0.3) os.unlink(fn)
def setUp(self): "test that the right db instance was created" dbver = __DB_FORMAT__ self.db = factory.createdb('sqlite://' + testdb, dbver) self.tester = SetupTester(dbver, testdb) self.tester.create()
def create(self): db = factory.createdb(self.dburi, self.dbver) self.cli = PwmanCliNew(db, self.xselpath, DummyCallback, config_parser=self.configp)
def setUp(self): "test that the right db instance was created" self.dbtype = 'sqlite' self.db = factory.createdb('sqlite:///'+testdb, __DB_FORMAT__) self.tester = SetupTester(__DB_FORMAT__, testdb) self.tester.create()
def setUp(self): "test that the right db instance was created" self.dbtype = 'sqlite' self.db = factory.createdb('sqlite:///' + testdb, __DB_FORMAT__) self.tester = SetupTester(__DB_FORMAT__, testdb) self.tester.create()
def test_factory_check_db_file(self): fn = os.path.join(os.path.dirname(__file__), 'baz.db') db = factory.createdb('sqlite:///'+os.path.abspath(fn), 0.3) db._open() self.assertEqual(factory.check_db_version('sqlite:///'+fn), 0.3) os.unlink(fn)