def update(args): # pragma: no cover check_repo() db = Storage() loader = Loader(db) log.info('Starting repo update') config = loader.load_config() repo_update(config) loader.save_config(config) log.info('Reconfig complete') db._sync_db()
def test_add(self): db = Storage() keydb = KeyDB(db, load=True) db._sync_db() assert len(os.listdir(os.getcwd())) == 1 keydb.add_key("public1", "private1") keydb.add_key("public2", "private2") assert len(keydb.get_public_keys()) == 2 assert keydb.get_public_keys()[0] == "public1" assert keydb.get_public_keys()[1] == "public2"
def test_add(self): db = Storage() keydb = KeyDB(db, load=True) db._sync_db() assert len(os.listdir(os.getcwd())) == 1 keydb.add_key('public1', 'private1') keydb.add_key('public2', 'private2') assert len(keydb.get_public_keys()) == 2 assert keydb.get_public_keys()[0] == 'public1' assert keydb.get_public_keys()[1] == 'public2'
def test_get_revoked_key(self): db = Storage() keydb = KeyDB(db, load=True) db._sync_db() assert len(os.listdir(os.getcwd())) == 1 assert keydb.get_revoked_key() is None keydb.add_key('public1', 'private1') keydb.add_key('public2', 'private2') assert len(keydb.get_public_keys()) == 2 keydb.revoke_key(count=2) assert len(keydb.get_public_keys()) == 0
def test_get_revoked_key(self): db = Storage() keydb = KeyDB(db, load=True) db._sync_db() assert len(os.listdir(os.getcwd())) == 1 assert keydb.get_revoked_key() is None keydb.add_key("public1", "private1") keydb.add_key("public2", "private2") assert len(keydb.get_public_keys()) == 2 keydb.revoke_key(count=2) assert len(keydb.get_public_keys()) == 0
def test_revoking_break(self): db = Storage() keydb = KeyDB(db, load=False) db._sync_db() assert len(os.listdir(os.getcwd())) == 1 keydb.add_key('public1', 'private1') keydb.add_key('public2', 'private2') assert keydb.get_revoked_key() is None assert len(keydb.get_public_keys()) == 2 keydb.revoke_key(count=1) assert len(keydb.get_public_keys()) == 1 assert keydb.get_revoked_key()['public'] == 'public1'
def test_revoking_break(self): db = Storage() keydb = KeyDB(db, load=False) db._sync_db() assert len(os.listdir(os.getcwd())) == 1 keydb.add_key("public1", "private1") keydb.add_key("public2", "private2") assert keydb.get_revoked_key() is None assert len(keydb.get_public_keys()) == 2 keydb.revoke_key(count=1) assert len(keydb.get_public_keys()) == 1 assert keydb.get_revoked_key()["public"] == "public1"
def pkg(args): check_repo() db = Storage() loader = Loader(db) pyu = PyUpdater(loader.load_config(), db) if args.process is False and args.sign is False: sys.exit('You must specify a command') if args.process is True: log.info('Processing packages...') pyu.process_packages() log.info('Processing packages complete') if args.sign is True: log.info('Signing packages...') pyu.sign_update() log.info('Signing packages complete') db._sync_db()
def _setting(args): # pragma: no cover check_repo() db = Storage() loader = Loader(db) config = loader.load_config() if args.appname is True: setup_appname(config) if args.company is True: setup_company(config) if args.urls is True: setup_urls(config) if args.patches is True: setup_patches(config) if args.scp is True: setup_scp(config) if args.s3 is True: setup_object_bucket(config) loader.save_config(config) log.info('Settings update complete') db._sync_db()
def init(args): # pragma: no cover db = Storage() loader = Loader(db) count = args.count if count > 10: sys.exit('Cannot be more then 10') if not os.path.exists(os.path.join(settings.CONFIG_DATA_FOLDER, settings.CONFIG_FILE_USER)): config = initial_setup(SetupConfig()) log.info('Creating pyu-data dir...') pyu = PyUpdater(config, db) pyu.setup() log.info('Making signing keys...') pyu.make_keys(count) config.PUBLIC_KEYS = pyu.get_public_keys() loader.save_config(config) log.info('Setup complete') db._sync_db() else: sys.exit('Not an empty PyUpdater repository')
def upload(args): # pragma: no cover error = False check_repo() db = Storage() loader = Loader(db) upload_service = args.service if upload_service is None: log.error('Must provide service name') error = True if error is False: pyu = PyUpdater(loader.load_config(), db) try: pyu.set_uploader(upload_service) except UploaderError as err: log.error(str(err)) error = True except UploaderPluginError as err: log.debug(str(err)) error = True mgr = stevedore.ExtensionManager(settings.UPLOAD_PLUGIN_NAMESPACE) plugin_names = mgr.names() log.debug('Plugin names: {}'.format(plugin_names)) if len(plugin_names) == 0: msg = ('*** No upload plugins instaled! ***\nYou can install ' 'the aws s3 plugin with\n$ pip install PyUpdater' '[s3]\n\nOr the scp plugin with\n$ pip install ' 'PyUpdater[scp]') else: msg = ('Invalid Uploader\n\nAvailable options:\n' '{}'.format(' '.join(plugin_names))) log.error(msg) if error is False: try: pyu.upload() except Exception as e: msg = ('Looks like you forgot to add USERNAME ' 'and/or REMOTE_DIR') log.debug(str(e), exc_info=True) log.error(msg) db._sync_db()
def init(args): # pragma: no cover db = Storage() loader = Loader(db) count = args.count if count > 10: sys.exit('Cannot be more then 10') if not os.path.exists( os.path.join(settings.CONFIG_DATA_FOLDER, settings.CONFIG_FILE_USER)): config = initial_setup(SetupConfig()) log.info('Creating pyu-data dir...') pyu = PyUpdater(config, db) pyu.setup() log.info('Making signing keys...') pyu.make_keys(count) config.PUBLIC_KEYS = pyu.get_public_keys() loader.save_config(config) log.info('Setup complete') db._sync_db() else: sys.exit('Not an empty PyUpdater repository')
def _keys(args): # pragma: no cover check_repo() db = Storage() loader = Loader(db) config = loader.load_config() pyu = PyUpdater(config, db) if args.count is not None: count = args.count pyu.revoke_key(count) config.PUBLIC_KEYS = pyu.get_public_keys() key = pyu.get_recent_revoked_key() if key is not None: log.info('* Most Recent Revoked Key *') log.info('Created: {}'.format(pretty_time(key['date']))) log.info('Type: {}'.format(key['key_type'])) log.info('Public Key: {}'.format(key['public'])) if args.private is True: log.info('Private Key: {}'.format(key['private'])) else: log.info('Private Key: * Next time to show private key ' 'use --show-private *') loader.save_config(config) db._sync_db()