def pkg(args): check = check_repo() if check is False: _repo_error() loader = Loader() pyu = PyUpdater(loader.load_config()) 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(args.verbose) log.info('Processing packages complete') if args.sign is True: log.info('Signing packages...') pyu.sign_update() log.info('Signing packages complete')
def __init__(self, args, pyi_args): check_repo() # We only need to grab appname l = Loader() self.app_name = l.get_app_name() self.args = args self.app_info, self.pyi_args = self._check_input_file(pyi_args)
def __init__(self, args, pyi_args): check_repo() # We only need to grab appname cm = ConfigManager() self.app_name = cm.get_app_name() self.args = args self.app_info, self.pyi_args = self._check_input_file(pyi_args)
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 _make_spec(args, pyi_args): check = check_repo() if check is False: _repo_error() builder = Builder(args, pyi_args) builder.make_spec()
def _keys(args): # pragma: no cover check = check_repo() if args.create is True and args.import_keys is True: log.error('Only one options is allowed at a time') sys.exit(1) if args.create is True and check is True: log.error('You can not create off-line keys on your dev machine') sys.exit(1) if args.import_keys is True and check is False: _repo_error() if args.create is True and check is False: k = Keys() app_name = get_correct_answer('Please enter app name', required=True) k.make_keypack(app_name) log.info('Keypack placed in cwd') return if args.import_keys is True and check is True: loader = Loader() config = loader.load_config() ki = KeyImporter() imported = ki.start() if imported is True: log.info('Keypack import successfully') loader.save_config(config) else: log.warning('Keypack import failed')
def _setting(args): # pragma: no cover check = check_repo() if check is False: _repo_error() # Used to specifiy if config needs to be saved save_config = False loader = Loader() config = loader.load_config() if args.config_path is True: save_config = True setup_client_config_path(config) if args.company is True: save_config = True setup_company(config) if args.urls is True: save_config = True setup_urls(config) if args.patches is True: save_config = True setup_patches(config) if args.plugin is not None: save_config = True setup_plugin(args.plugin, config) if args.show_plugin is not None: print_plugin_settings(args.show_plugin, config) if save_config is True: loader.save_config(config) log.info('Settings update complete')
def _build(args, pyi_args): check = check_repo() if check is False: _repo_error() builder = Builder(args, pyi_args) builder.build()
def upload(args): # pragma: no cover check = check_repo() if check is False: _repo_error() error = False loader = Loader() 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()) try: pyu.set_uploader(upload_service, args.keep) except UploaderError as err: log.error(err) error = True except UploaderPluginError as err: log.debug(err) error = True log.error('Invalid upload plugin') log.error('Use "pyupdater plugins" to get a ' 'list of installed plugins') 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(e, exc_info=True) log.error(msg)
def check_repo_ex(exit_on_error=False): check = check_repo() if check is False: log.error("Not a PyUpdater repo: You must initialize " "your repository first") if exit_on_error is True and TEST is False: os._exit(1) return check
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 check_repo_ex(exit_on_error=False): check = check_repo() if check is False: log.error('Not a PyUpdater repo: You must initialize ' 'your repository first') if exit_on_error is True and TEST is False: os._exit(1) return check
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 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__(self, test=False): self.check = check_repo() self.key_encoding = 'base64' # Used for testing # When _load is called it'll cause an empty dict to be created if test is False: self.data_dir = user_data_dir('PyUpdater', 'Digital Sapphire') else: self.data_dir = os.path.join('private', 'data') if not os.path.exists(self.data_dir): os.makedirs(self.data_dir) self.keypack_filename = os.path.join(self.data_dir, 'offline_keys.db') self._load()
def __init__(self, test=False): self.check = check_repo() self.key_encoding = 'base64' # Used for testing # When _load is called it'll cause an empty dict to be created self.keypack_filename = None if test is False: self.data_dir = user_data_dir('PyUpdater', 'Digital Sapphire') if not os.path.exists(self.data_dir): os.makedirs(self.data_dir) self.keypack_filename = os.path.join(self.data_dir, 'offline_keys.db') self._load()
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 archive(args): check = check_repo() if check is False: _repo_error() new_dir = os.path.join(CWD, settings.USER_DATA_FOLDER, 'new') name = args.name version = args.version with ChDir(new_dir): if not os.path.exists(name): log.error('%s does not exists', name) return ex_lib = ExternalLib(name, version) ex_lib.archive() if args.keep is False: remove_any(name) log.info('Removed: %s', name)
def archive(args): check = check_repo() if check is False: _repo_error() new_dir = os.path.join(os.getcwd(), settings.USER_DATA_FOLDER, 'new') name = args.name target_name = args.target_name version = args.version with ChDir(new_dir): if not os.path.exists(target_name): log.error('{} does not exists'.format(target_name)) return ex_lib = ExternalLib(name, target_name, version) ex_lib.archive() if args.keep is False: remove_any(target_name) log.info('Removed: {}'.format(target_name))
def _setting(args): # pragma: no cover check = check_repo() if check is False: _repo_error() loader = Loader() config = loader.load_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')
def __init__(self, test=False): # Ensure we are working in a pyupdater initialized repo self.check = check_repo() # We use base64 encoding for easy human consumption self.key_encoding = 'base64' # Used for testing # When _load is called it'll cause an empty dict to be created if test: self.data_dir = os.path.join('private', 'data') else: self.data_dir = user_data_dir('PyUpdater', 'Digital Sapphire') if not os.path.exists(self.data_dir): os.makedirs(self.data_dir) # The name of the offline key database self.keypack_filename = os.path.join(self.data_dir, 'offline_keys.db') self._load()
def test_check_repo_fail(self): with pytest.raises(SystemExit): check_repo()
def _build(args, pyi_args): check_repo() builder = Builder(args, pyi_args) builder.build()
def __init__(self, args, pyi_args): check_repo() self.args = args self.pyi_args = pyi_args
def _make_spec(args, pyi_args): check_repo() builder = Builder(args, pyi_args) builder.make_spec()
def test_check_repo_fail(self): assert check_repo() is False