예제 #1
0
 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
예제 #2
0
 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
예제 #3
0
 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
예제 #4
0
 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
예제 #5
0
 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()
예제 #6
0
 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()
예제 #7
0
파일: cli.py 프로젝트: gadeleon/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')
    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()
예제 #8
0
파일: cli.py 프로젝트: 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()
예제 #9
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()
예제 #10
0
 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__))
예제 #11
0
 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__))
예제 #12
0
 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)
예제 #13
0
 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()
예제 #14
0
 def create(self):
     db = factory.createdb(self.dburi, self.dbver)
     self.cli = PwmanCliNew(db, self.xselpath, DummyCallback,
                            config_parser=self.configp)
예제 #15
0
 def create(self):
     db = factory.createdb(self.dburi, self.dbver)
     self.cli = PwmanCliNew(db,
                            self.xselpath,
                            DummyCallback,
                            config_parser=self.configp)
예제 #16
0
 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()
예제 #17
0
 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()
예제 #18
0
 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)