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 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()
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()