Пример #1
0
def setup_urls(config):  # pragma: no cover
    url = terminal.get_correct_answer("Enter a url to ping for updates.", required=True)
    config.UPDATE_URLS = [url]
    while 1:
        answer = terminal.ask_yes_no(
            "Would you like to add " "another url for backup?", default="no"
        )
        if answer is True:
            url = terminal.get_correct_answer("Enter another url.", required=True)
            config.UPDATE_URLS.append(url)
        else:
            break
Пример #2
0
def setup_urls(config):  # pragma: no cover
    url = terminal.get_correct_answer('Enter a url to ping for updates.',
                                      required=True)
    config.UPDATE_URLS = [url]
    while 1:
        answer = terminal.ask_yes_no('Would you like to add '
                                     'another url for backup?',
                                     default='no')
        if answer is True:
            url = terminal.get_correct_answer('Enter another url.',
                                              required=True)
            config.UPDATE_URLS.append(url)
        else:
            break
Пример #3
0
def setup_urls(config):  # pragma: no cover
    url = terminal.get_correct_answer('Enter a url to ping for '
                                                  'updates.', required=True)
    config.UPDATE_URLS = [url]
    while 1:
        answer = terminal.ask_yes_no('Would you like to add '
                                                 'another url for backup?',
                                                 default='no')
        if answer is True:
            url = terminal.get_correct_answer('Enter another url.',
                                                          required=True)
            config.UPDATE_URLS.append(url)
        else:
            break
Пример #4
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')
Пример #5
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')
Пример #6
0
def setup_appname(config):  # pragma: no cover
    if config.APP_NAME is not None:
        default = config.APP_NAME
    else:
        default = None
    config.APP_NAME = terminal.get_correct_answer('Please enter app name',
                                                  required=True,
                                                  default=default)
Пример #7
0
def setup_appname(config):  # pragma: no cover
    if config.APP_NAME is not None:
        default = config.APP_NAME
    else:
        default = None
    config.APP_NAME = terminal.get_correct_answer('Please enter app name',
                                                  required=True,
                                                  default=default)
Пример #8
0
def setup_company(config):  # pragma: no cover
    if config.COMPANY_NAME is not None:
        default = config.COMPANY_NAME
    else:
        default = None
    temp = terminal.get_correct_answer('Please enter your name or company name',
                                       required=True, default=default)
    config.COMPANY_NAME = temp
Пример #9
0
def setup_company(config):  # pragma: no cover
    if config.COMPANY_NAME is not None:
        default = config.COMPANY_NAME
    else:
        default = None
    temp = terminal.get_correct_answer(
        "Please enter your name or company name", required=True, default=default
    )
    config.COMPANY_NAME = temp
Пример #10
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')
Пример #11
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')
Пример #12
0
def setup_client_config_path(config):  # pragma: no cover
    _default_dir = os.path.basename(os.path.abspath(os.getcwd()))
    question = ("Please enter the path to where pyupdater "
                "will write the client_config.py file. "
                "You'll need to import this file to "
                "initialize the update process. \nExamples:\n\n"
                "lib/utils, src/lib, src. \n\nLeave blank to use "
                "the current directory")
    answer = terminal.get_correct_answer(question, default=_default_dir)

    if answer == _default_dir:
        config.CLIENT_CONFIG_PATH = settings.DEFAULT_CLIENT_CONFIG
    else:
        answer = answer.split(os.sep)
        answer.append(settings.DEFAULT_CLIENT_CONFIG[0])

        config.CLIENT_CONFIG_PATH = answer
Пример #13
0
def setup_client_config_path(config):  # pragma: no cover
    _default_dir = os.path.basename(os.path.abspath(os.getcwd()))
    question = ("Please enter the path to where pyupdater "
                "will write the client_config.py file. "
                "You'll need to import this file to "
                "initialize the update process. \nExamples:\n\n"
                "lib/utils, src/lib, src. \n\nLeave blank to use "
                "the current directory")
    answer = terminal.get_correct_answer(question, default=_default_dir)

    if answer == _default_dir:
        config.CLIENT_CONFIG_PATH = settings.DEFAULT_CLIENT_CONFIG
    else:
        answer = answer.split(os.sep)
        answer.append(settings.DEFAULT_CLIENT_CONFIG[0])

        config.CLIENT_CONFIG_PATH = answer
Пример #14
0
def setup_http_timeout(config):  # pragma: no cover
    default = config.HTTP_TIMEOUT
    while 1:
        temp = terminal.get_correct_answer("Enter HTTP timeout in seconds",
                                           required=True,
                                           default=str(default))
        try:
            temp = int(temp)
        except Exception as err:
            log.error(err)
            continue

        if temp < 1:
            log.error("HTTP timeout has to be >= 1")
            continue
        break

    config.HTTP_TIMEOUT = temp
Пример #15
0
def setup_max_download_retries(config):  # pragma: no cover
    default = config.MAX_DOWNLOAD_RETRIES
    while 1:
        temp = terminal.get_correct_answer("Enter max download retries",
                                           required=True,
                                           default=str(default))
        try:
            temp = int(temp)
        except Exception as err:
            log.error(err)
            log.debug(err, exc_info=True)
            continue

        if temp > 10 or temp < 1:
            log.error("Max retries can only be from 1 to 10")
            continue
        break

    config.MAX_DOWNLOAD_RETRIES = temp
Пример #16
0
def setup_max_download_retries(config):  # pragma: no cover
    default = config.MAX_DOWNLOAD_RETRIES
    while 1:
        temp = terminal.get_correct_answer('Enter max download retries',
                                           required=True, default=str(default))
        try:
            temp = int(temp)
        except Exception as err:
            log.error(err)
            log.debug(err, exc_info=True)
            continue

        if temp > 10 or temp < 1:
            log.error('Max retries can only be from 1 to 10')
            continue

        break

    config.MAX_DOWNLOAD_RETRIES = temp
Пример #17
0
 def get_correct_answer(self, question, default, required=False):
     return get_correct_answer(question, default, required)
Пример #18
0
 def get_correct_answer(self, question, default, required=False):
     return get_correct_answer(question, default, required)
Пример #19
0
 def get_correct_action(self, question, default, required):
     return get_correct_answer(question, default, required)
Пример #20
0
 def get_answer(question, default=None):
     return get_correct_answer(question, default=default)
Пример #21
0
 def get_answer(self, question, default=None):
     return get_correct_answer(question, default=default)
Пример #22
0
 def get_correct_action(self, question, default, required):
     return get_correct_answer(question, default, required)