Esempio n. 1
1
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')
Esempio n. 2
0
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)
Esempio n. 3
0
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')
Esempio n. 4
0
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')
Esempio n. 5
0
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)
Esempio n. 6
0
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')
Esempio n. 7
0
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')
Esempio n. 8
0
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()
Esempio n. 9
0
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()
Esempio n. 10
0
def loader():
    CONFIG = {
        'APP_NAME': 'PyUpdater Test',
        'COMPANY_NAME': 'ACME',
        'UPDATE_PATCHES': True,
        }

    l = Loader()
    config = l.load_config()
    config.update(CONFIG)
    l.save_config(config)
    return config
Esempio n. 11
0
def loader():
    CONFIG = {
        'APP_NAME': 'PyUpdater Test',
        'COMPANY_NAME': 'ACME',
        'UPDATE_PATCHES': True,
        }

    l = Loader()
    config = l.load_config()
    config.update(CONFIG)
    l.save_config(config)
    return config
Esempio n. 12
0
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()
Esempio n. 13
0
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()
Esempio n. 14
0
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')
Esempio n. 15
0
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')
Esempio n. 16
0
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)
        except UploaderError as err:
            log.error(err)
            error = True
        except UploaderPluginError as err:
            log.debug(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(e, exc_info=True)
            log.error(msg)
Esempio n. 17
0
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()
Esempio n. 18
0
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()
Esempio n. 19
0
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()
Esempio n. 20
0
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()
Esempio n. 21
0
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()
Esempio n. 22
0
 def test_build(self):
     l = Loader()
     config = l.load_config()
     config.update(CONFIG)
     l.save_config(config)
Esempio n. 23
0
 def test_build(self):
     l = Loader()
     config = l.load_config()
     config.update(CONFIG)
     l.save_config(config)