示例#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')
示例#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)
示例#3
0
 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)
示例#4
0
    def test_execution(self, pyu, db):
        archive_name = 'myapp-{}-0.1.0{}'.format(get_system(), ext)
        parser = get_parser()
        data_dir = pyu.config['DATA_DIR']
        pyu_data_dir = os.path.join(data_dir, 'pyu-data')
        pyu.setup()
        pyu.make_keys(3)
        with ChDir(data_dir):
            loader = Loader(db)
            loader.save_config(pyu.config.copy())
            with open('app.py', 'w') as f:
                f.write('print "Hello World"')
            args, pyu_args = parser.parse_known_args(create_build_cmd(0))
            b = Builder(args, pyu_args)
            b.build()

        assert os.path.exists(os.path.join(pyu_data_dir, 'new',
                              archive_name))
        pyu.process_packages()
        assert os.path.exists(os.path.join(pyu_data_dir, 'deploy',
                              archive_name))
        assert os.path.exists(os.path.join(pyu_data_dir, 'files',
                              archive_name))
        pyu.sign_update()
        assert os.path.exists(os.path.join(pyu_data_dir, 'deploy',
                              'versions.gz'))
示例#5
0
 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)
示例#6
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')
示例#7
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)
示例#8
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')
示例#9
0
def test_write_config(cleandir):
    config = TransistionDict()
    prod_config = ProdConfig()
    config.from_object(prod_config)
    l = Loader()
    l.write_config_py(config)
    assert 'client_config.py' in os.listdir(os.getcwd())
示例#10
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')
示例#11
0
def test_write_config(cleandir):
    config = ConfigDict()
    prod_config = ProdConfig()
    config.from_object(prod_config)
    l = Loader()
    l._write_config_py(config)
    assert 'client_config.py' in os.listdir(os.getcwd())
示例#12
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')
示例#13
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()
示例#14
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()
示例#15
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
示例#16
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
示例#17
0
def init():  # pragma: no cover
    if not os.path.exists(os.path.join(settings.CONFIG_DATA_FOLDER,
                          settings.CONFIG_FILE_USER)):
        config = Config()
        config = initial_setup(config)
        log.info('Creating pyu-data dir...')
        pyu = PyUpdater(config)
        pyu.setup()
        loader = Loader()
        loader.save_config(config)
        log.info('Setup complete')
    else:
        sys.exit('Not an empty PyUpdater repository')
示例#18
0
def init():  # pragma: no cover
    if not os.path.exists(os.path.join(settings.CONFIG_DATA_FOLDER,
                          settings.CONFIG_FILE_USER)):
        config = Config()
        config = initial_setup(config)
        log.info('Creating pyu-data dir...')
        pyu = PyUpdater(config)
        pyu.setup()
        loader = Loader()
        loader.save_config(config)
        log.info('Setup complete')
    else:
        sys.exit('Not an empty PyUpdater repository')
示例#19
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()
示例#20
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()
示例#21
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')
示例#22
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')
示例#23
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)
示例#24
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()
示例#25
0
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')
示例#26
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()
示例#27
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()
示例#28
0
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')
示例#29
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()
示例#30
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()
示例#31
0
 def test_build(self):
     l = Loader()
     config = l.load_config()
     config.update(CONFIG)
     l.save_config(config)
示例#32
0
 def test_build(self):
     l = Loader()
     config = l.load_config()
     config.update(CONFIG)
     l.save_config(config)