Пример #1
0
def run_cmd(cmd, params_and_opts, config):
    if cmd == 'install':
        if len(params_and_opts[0]) < 3:
            console.install_not_enough_args_err_msg()
            abnormal_exit()
        install_pkgs(params_and_opts[0][2:], params_and_opts[1], config)
    elif cmd == 'updatescripts':
        update_scripts(config)
    elif cmd == 'selfupdate':
        self_update(config)
    elif cmd == 'listinstalled':
        list_installed(config)
    elif cmd == 'urlinstall':
        url_install(config, params_and_opts[0][2:])
    elif cmd == 'srcinstall':
        src_install(config, params_and_opts[0][2:])
    elif cmd == 'update':
        update(config, params_and_opts[0][2:])
    elif cmd == 'updateall':
        update_all(config)
    elif cmd == 'clear':
        clear(config)
    elif cmd == 'repoversion':
        if len(params_and_opts[0]) <= 2:
            print_repo_version(config)
        else:
            set_repo_version(config, params_and_opts[0][2])
    elif cmd == 'help':
        misc.print_help(config)
    else:
        print('Unrecognized command: ' + cmd)
        misc.print_help(config)
Пример #2
0
def update_all(config):
    # To update check what is the installed version
    # And what is the available version
    # If they do not match then do installation.
    try:
        #try:
        #	with open(config['PACKAGE_LIST']) as fp:
        #		package_list = json.loads(fp.read())
        #except:
        #	print('Please run: alps updatescripts before running an update.')
        #	abnormal_exit()
        to_be_updated = get_updates(config)
        #for pkg in package_list:
        #		if pkg['status'] == True and not pkg['available_version'] == pkg['version']:
        #			to_be_updated.append(pkg['name'])

        print('The following packages would be updated:\n\t' +
              ' '.join(to_be_updated))
        response = console.prompt_choice(
            'Are you sure you want to install these packages?', ['y', 'n'],
            'y')
        if response == 'y':
            for pkg in to_be_updated:
                begin_install(script_path(pkg, config))
                execute_cmd(script_path(pkg, config).split())
                remove_duplicate_entries(config)
    except KeyboardInterrupt:
        abnormal_exit()
Пример #3
0
def execute_script(script_path, params=None):
    try:
        if params != None:
            execute_cmd(script_path.split().extend(params))
        else:
            execute_cmd(script_path.split())
    except KeyboardInterrupt:
        abnormal_exit()
Пример #4
0
def prompt_choice(msg, options, default):
    try:
        suffix = concat_opts(options, default, '/')
        response = prompt(msg + ' ' + suffix + ' ')
        if response == '':
            return default
        return response
    except KeyboardInterrupt:
        abnormal_exit()
Пример #5
0
def dependencies(pkg_name, dependency_type, config):
    try:
        with open(pkg_name) as f:
            lines = f.readlines()
        deps = list()
        for line in lines:
            if line != '':
                if line.startswith(dependency_type):
                    deps.append(line.strip().replace(dependency_type, ''))
        return deps
    except FileNotFoundError:
        print()
        parts = pkg_name.split('/')
        print('Not able to find buildscript for ' +
              parts[len(parts) - 1].replace('.sh', ''))
        abnormal_exit()
Пример #6
0
def install_pkgs(pkg_names, opts, config):
    try:
        dep_chain = deps.dep_chain_status(pkg_names, False, config)
        console.print_status(dep_chain)
        if not ('-ni' in opts or '--no-interactive' in opts):
            response = console.prompt_choice(
                'Are you sure you want to install these packages?', ['y', 'n'],
                'y')
        else:
            response = 'y'
        if response == 'y':
            for (pkg, status) in dep_chain.items():
                if not status:
                    begin_install(script_path(pkg, config))
                    execute_cmd(script_path(pkg, config).split())
    except KeyboardInterrupt:
        abnormal_exit()
Пример #7
0
def menu(choices, heading, default):
    try:
        print('')
        print(heading)
        print('')
        count = 1
        opts = list()
        for choice in choices:
            if (default == count):
                print(str(count) + '. ' + choice + ' (default)')
            else:
                print(str(count) + '. ' + choice)
            opts.append(str(count))
            count = count + 1
        print('')
        return prompt_choice('Choose an option', opts, default)
    except KeyboardInterrupt:
        abnormal_exit()