Esempio n. 1
0
def loader():
    CONFIG = {
        'APP_NAME': 'PyUpdater Test',
        'COMPANY_NAME': 'ACME',
        'UPDATE_PATCHES': True,
    }

    cm = ConfigManager()
    config = cm.load_config()
    config.update(CONFIG)
    cm.save_config(config)
    return config
Esempio n. 2
0
def loader():
    default_config = {
        "APP_NAME": "PyUpdater Test",
        "COMPANY_NAME": "ACME",
        "UPDATE_PATCHES": True,
    }

    cm = ConfigManager()
    config = cm.load_config()
    config.update(default_config)
    cm.save_config(config)
    return config
Esempio n. 3
0
def _cmd_keys(*args):  # pragma: no cover
    check = check_repo_ex()

    ns = args[0]
    # We try to prevent developers from creating root keys on the dev
    # machines.
    if ns.create is True and ns.import_keys is True:
        log.error('Only one options is allowed at a time')
        return

    # Okay the actual check is pretty weak but we are all grown ups here :)
    if ns.create is True and check is True:
        log.error('You can not create off-line keys on your dev machine')
        return

    # Can't import if we don't have a config to place it in.
    if ns.import_keys is True and check is False:
        return

    # We are supposed to be on another secure computer.
    # Security is in the eye of the beholder.
    # That was deep.
    if ns.create is True and check is False:
        if hasattr(ns, 'test'):
            log.debug('We are testing!')
            app_name = 'test'
            # Starting up with some testing in mind.
            k = Keys(test=True)
        else:
            k = Keys()
            # Get the app name for the soon to be generated keypack.pyu
            app_name = get_correct_answer('Please enter app name',
                                          required=True)

        # Create the keypack for this particular application.
        # make_keypack will return True if successful.
        if k.make_keypack(app_name):
            log.info('Keypack placed in cwd')
        else:
            log.error('Failed to create keypack')
            return

    # Save the keypack.pyu that's in the current directory to the
    # .pyupdater/config.pyu file.
    if ns.import_keys is True and check is True:
        cm = ConfigManager()
        config = cm.load_config()
        ki = KeyImporter()
        if ki.start():
            log.info('Keypack import successfully')
            cm.save_config(config)
        else:
            log.warning('Keypack import failed')
Esempio n. 4
0
def _cmd_keys(*args):  # pragma: no cover
    check = check_repo_ex()

    ns = args[0]
    # We try to prevent developers from creating root keys on the dev
    # machines.
    if ns.create_keys is True and ns.import_keys is True:
        log.error('Only one options is allowed at a time')
        return

    # Okay the actual check is pretty weak but we are all grown ups here :)
    if ns.create_keys is True and check is True:
        log.error('You can not create off-line keys on your dev machine')
        return

    # Can't import if we don't have a config to place it in.
    if ns.import_keys is True and check is False:
        return

    # We are supposed to be on another secure computer.
    # Security is in the eye of the beholder.
    # That was deep.
    if ns.create_keys is True and check is False:
        if hasattr(ns, 'test'):
            log.debug('We are testing!')
            app_name = 'test'
            # Starting up with some testing in mind.
            k = Keys(test=True)
        else:
            k = Keys()
            # Get the app name for the soon to be generated keypack.pyu
            app_name = get_correct_answer('Please enter app name',
                                          required=True)

        # Create the keypack for this particular application.
        # make_keypack will return True if successful.
        if k.make_keypack(app_name):
            log.info('Keypack placed in cwd')
        else:
            log.error('Failed to create keypack')
            return

    # Save the keypack.pyu that's in the current directory to the
    # .pyupdater/config.pyu file.
    if ns.import_keys is True and check is True:
        cm = ConfigManager()
        config = cm.load_config()
        ki = KeyImporter()
        if ki.start():
            log.info('Keypack import successfully')
            cm.save_config(config)
        else:
            log.error('Keypack import failed')
Esempio n. 5
0
def loader():
    default_config = {
        'APP_NAME': 'PyUpdater Test',
        'COMPANY_NAME': 'ACME',
        'UPDATE_PATCHES': True,
    }

    cm = ConfigManager()
    config = cm.load_config()
    config.update(default_config)
    cm.save_config(config)
    return config
Esempio n. 6
0
def _cmd_settings(*args):  # pragma: no cover
    check_repo_ex(exit_on_error=True)

    ns = args[0]
    # Used to specify if config needs to be saved
    save_config = True
    cm = ConfigManager()
    config = cm.load_config()

    # Set the path of the client_config.py relative to the root of
    # the repository
    if ns.config_path is True:
        setup_client_config_path(config)

    # Change the company name. This will effect the file path on the end users
    # computer to place update files & meta data
    if ns.company is True:
        setup_company(config)

    # The amount of times the client retries downloads
    if ns.max_download_retries is True:
        setup_max_download_retries(config)

    # The http timeout for FileDownloader
    if ns.http_timeout is True:
        setup_http_timeout(config)

    # Base urls to online updates & meta data
    if ns.urls is True:
        setup_urls(config)

    # Enable/Disable binary patches
    if ns.patches is True:
        setup_patches(config)

    # Setup config for requested upload plugin
    if ns.plugin is not None:
        setup_plugin(ns.plugin, config)

    # Show list of installed upload plugins
    if ns.show_plugin is not None:
        save_config = False
        print_plugin_settings(ns.show_plugin, config)

    # If any changes have been made, save data to disk.
    if save_config is True:
        cm.save_config(config)
        log.info("Saved config")
Esempio n. 7
0
def _cmd_settings(*args):  # pragma: no cover
    check_repo_ex(exit_on_error=True)

    ns = args[0]
    # Used to specify if config needs to be saved
    save_config = True
    cm = ConfigManager()
    config = cm.load_config()

    # Set the path of the client_config.py relative to the root of
    # the repository
    if ns.config_path is True:
        setup_client_config_path(config)

    # Change the company name. This will effect the file path on the end users
    # computer to place update files & meta data
    if ns.company is True:
        setup_company(config)

    # The amount of times the client retries downloads
    if ns.max_download_retries is True:
        setup_max_download_retries(config)

    # Base urls to online updates & meta data
    if ns.urls is True:
        setup_urls(config)

    # Enable/Disable binary patches
    if ns.patches is True:
        setup_patches(config)

    # Setup config for requested upload plugin
    if ns.plugin is not None:
        setup_plugin(ns.plugin, config)

    # Show list of installed upload plugins
    if ns.show_plugin is not None:
        save_config = False
        print_plugin_settings(ns.show_plugin, config)

    # If any changes have been made, save data to disk.
    if save_config is True:
        cm.save_config(config)
        log.info('Saved config')
Esempio n. 8
0
def _cmd_init(*args):  # pragma: no cover
    if not os.path.exists(os.path.join(settings.CONFIG_DATA_FOLDER,
                                       settings.CONFIG_FILE_USER)):
        # Load a basic config.
        config = Config()

        # Run config through all of the setup functions
        config = initial_setup(config)
        log.info('Creating pyu-data dir...')

        # Initialize PyUpdater with newly created config
        pyu = PyUpdater(config)

        # Setup repository
        pyu.setup()

        # Load config manager & save config to disk
        cm = ConfigManager()
        cm.save_config(config)
        log.info('Setup complete')
    else:
        log.error('Not an empty PyUpdater repository')
Esempio n. 9
0
def _cmd_init(*args):  # pragma: no cover
    if not os.path.exists(
            os.path.join(settings.CONFIG_DATA_FOLDER,
                         settings.CONFIG_FILE_USER)):
        # Load a basic config.
        config = Config()

        # Run config through all of the setup functions
        config = initial_setup(config)
        log.info('Creating pyu-data dir...')

        # Initialize PyUpdater with newly created config
        pyu = PyUpdater(config)

        # Setup repository
        pyu.setup()

        # Load config manager & save config to disk
        cm = ConfigManager()
        cm.save_config(config)
        log.info('Setup complete')
    else:
        log.error('Not an empty PyUpdater repository')
Esempio n. 10
0
 def test_build(self):
     cm = ConfigManager()
     config = cm.load_config()
     config.update(CONFIG)
     cm.save_config(config)
Esempio n. 11
0
 def test_build(self):
     cm = ConfigManager()
     config = cm.load_config()
     config.update(CONFIG)
     cm.save_config(config)