Exemplo n.º 1
0
def _ask_for_source_of_new_iso(base_sys, _b_prober, _pseed_):
    """Queries for Backup, from iso, or boostrap as the source for the build
    """
    # pseed (pre-master-seed) is not used now that we know the system.
    stage = 'ask-for-source-of-new-iso'
    base_list = []

    if base_sys == 'other':
        _mseed_ = _pseed_
    else:
        base = pycone._base(base_sys)
        _mseed_ = pycone._master_seed(base)

    if _b_prober:
        base_list = pyconeQ.backup_list + pyconeQ.iso_list + pyconeQ.custom_list

        # create a list of choices return the users choice
        choice = pycone._choose_from(base_list, pyconeQ.base_type_msg + '\n' + stage)

        # choice_list with Backup
        choice_list = [_sys_backup, _from_iso, _bootstrap]
    else:
        ## go get the system wanted for operations
        base_list = pyconeQ.iso_list + pyconeQ.custom_list
        # create a list of choices return the users choice with Backup disabled
        choice = pycone._choose_from(base_list, pyconeQ.base_type_msg + '\n' + stage)

        # choice_list without Backup
        choice_list = [_from_iso, _bootstrap]
        # choice list without Backup
    # choices, System Backup, From ISO, or Bootstrap
    pycone._print_log(base_list, choice + 1, stage)##

    choice_list[choice](base_sys, _mseed_)
Exemplo n.º 2
0
def _q_my_system(_pseed_, source):

    stage = 'q-my-system'
    pycone._print_log('', stage)##
    c_system = str.capitalize(_pseed_)
    choice = pycone._choose_from(pyconeQ.yes_no_list, pyconeQ.which_system % c_system)
    # probe current system, then user confirm
    pycone._print_log(c_system, stage)##
    pycone._print_log(pyconeQ.yes_no_list, stage)##
    pycone._print_log(choice + 1, stage)##

    if choice == 0:
        # choose a backup of current system
        pycone._print_log(choice + 1, stage)##
        #pycone._rsync_live(seed)
        base = pycone._base(_pseed_)
        pycone._print_log('pseed', stage)##
        pycone._print_log(_pseed_, stage)##
        _mseed_ = pycone._master_seed(str.lower(base))
        pycone._print_log('mseed', stage)##
        pycone._print_log(_mseed_, stage)##
        _mkdir_p(_mseed_,source)
        _ask_rsync(_mseed_)
    elif choice == 1:
        # choose to use an existing iso file
        #_new_config('iso')
        pycone._print_log(choice + 1, stage)##
        _sys_backup('')
        pycone._exit()
    else:
        pycone._do_help_quit(choice, pyconeQ.yes_no_list)
Exemplo n.º 3
0
def _ask_existing_new_build():
    """begin with choice of an existing build file or
    creation of a new build file
    """
    stage = 'begin'
    pycone._print_log('', stage)##
    choice = pycone._choose_from(pyconeQ.level_list, pyconeQ.welcome_msg)
    # create a list of choices return the users choice
    pycone._print_log(pyconeQ.level_list, stage)##
    pycone._print_log(choice + 1, stage)##

    if choice == 0:
        #choose to use existing builder config
        pycone._print_log('use auto conf', stage)##
        print('not yet functional')
        pycone._exit()
        # no need to write to autoseed, read from it
    elif choice == 1:
        # choose to create a new builder config
        #_write_to_auto_seed('[autoseed]','', 'new')
        pycone._print_log('create a new conf', stage)##
        _pseed_ = pycone._os_prober(pycone._master_seed(''))
        _ask_source_system(_pseed_)
    else:
        pycone._do_help_quit(choice, pyconeQ.level_list)
Exemplo n.º 4
0
def _confirm_os_probe(_pseed_):
    """Probes the system, returns the result and asks user to confirm.
    Works with system backup, not needed for iso or bootstrap.
    """
    stage = 'confirm-os-probe'

    _pseed_ = pycone._master_seed(None)
    # create a pre-master-seed; no <distro>-seed
    pycone._print_log('### pseed ###', _pseed_, 'test')##

    _probed_name = pycone._os_prober(_pseed_)
    # get the system through prober
    _probed_sys = pycone._base(_probed_name)
    # return the full distro-seed name, if exists
    c_pseed = str.capitalize(str(_probed_name))
    # capitalized string just for use in query
    pycone._print_log(_probed_name, _probed_sys, stage)##

    if (_probed_sys != False):
        # be sure base did not return false(ie distro seed does not exist)
        choice = pycone._choose_from(pyconeQ.yes_no_list, pyconeQ.which_system % c_pseed + '\n' + stage)
        # probe current system, then user confirm
        choice_list = [_ask_for_source_of_new_iso, _ask_base_system]
        # on yes, go create master seed, then continue to question for Backup, etc
        # on no, continue to manual list of options, check with seedlist, then on to Backup (just a detour)if seedlist != False
        _b_prober = True
        # states os_prober returned a name, correct or not

        pycone._print_log(pyconeQ.yes_no_list, choice + 1, stage)##
        pycone._print_log(c_pseed, None, stage)##

        choice_list[choice](_probed_name, _b_prober, _pseed_)
    else:
        _b_prober = False
        _ask_base_system(None, _b_prober, _pseed_)
Exemplo n.º 5
0
def _confirm_base_system(empty):
    """Probes the system, returns the result and asks user to confirm.
    Works with system backup, not needed for iso or bootstrap.
    """
    stage = 'confirm-base-system'

    _pseed_ = pycone._master_seed('')
    pycone._print_log('pseed ####', _pseed_, 'test')##

    _probe = pycone._os_prober(_pseed_)
    # get the system through prober
    _probed_sys = pycone._base(_probe)
    # return the full distro-seed name, if exists
    c_pseed = str.capitalize(str(_probe))
    # capitalized string just for use in query
    pycone._print_log(_probe, _probed_sys, stage)##

    if (_probed_sys != False):
        # be sure base did not return false(ie distro seed does not exist)
        choice = pycone._choose_from(pyconeQ.yes_no_list, pyconeQ.which_system % c_pseed)
        # probe current system, then user confirm
        choice_list = [_seed_probe_match, _get_base_system]
        # on yes, go create master seed, then continue to question for Backup, etc
        # on no, continue to manual list of options, check with seedlist, then on to Backup (just a detour)if seedlist != False
        ## create the create-master-seed def

        pycone._print_log(pyconeQ.yes_no_list, choice + 1, stage)##
        pycone._print_log(c_system, '', stage)##

        choice_list[choice](_probe)
    else:
        pass
Exemplo n.º 6
0
def _ask_source_system(_pseed_):
    """Queries for Backup, from iso, or boostrap as the source for the build
    """
    # now choose the source of build
    stage = 'new configuration'
    pycone._print_log('', stage)##
    choice = pycone._choose_from(pyconeQ.base_type_list, pyconeQ.base_type_msg)
    # create a list of choices return the users choice
    pycone._print_log(pyconeQ.base_type_list, stage)##
    pycone._print_log(choice + 1, stage)##

    if choice == 0:
        # choose a backup of current system
        #_write_to_auto_seed('source :\n\t','backup', 'append')
        _q_my_system(_pseed_, 'backup')
    elif choice == 1:
        # choose to use an existing iso file
        #_new_config('iso')
        print("iso that thing")
        print("not working at this time")
        pycone._exit()
    elif choice == 2:
        # choose to install a new bootstrap system
        #_new_config('bootstrap')
        print("bootstrap new system")
        print("not working at this time")
        pycone._exit()
    else:
        pycone._do_help_quit(choice, pyconeQ.base_type_list)
Exemplo n.º 7
0
def _ask_base_system(_probe, _b_prober, _pseed_):
    """Upon failed auto-os-probe, manually list available seeds
    """
    stage = 'ask-base-system'
    pycone._print_log('##', stage, '##')##

    sys_q_list = pycone._system_list()
    # return a list of choices from available system seeds

    list_w_other = sys_q_list + ['Other']
    # remember quit & help are added later, therefore are not part of len

    choice = pycone._choose_from(list_w_other, pyconeQ.user_source_system + pyconeQ.base_sys_msg)
    # this is the users choice, 'other' == (len(list) - 2)
    pycone._print_log(list_w_other, choice, stage)##

    base_system = str.lower(list_w_other[choice])
    # make the choice to lower letter for manipulation
    pycone._print_log((len(list_w_other)), base_system, stage)##

    # if choice is other, source system is unsupported and cannot have 'Backup'
    if choice == (len(list_w_other)-1):
        _dist_seed_ = 'other'
        _b_prober = False
    else:
        _dist_seed_ = base_system
        # get the seed's complete name
        _b_prober = True

    pycone._print_log(_dist_seed_, _b_prober, stage)##
    _ask_for_source_of_new_iso(_dist_seed_, _b_prober, _pseed_)
Exemplo n.º 8
0
def _get_base_system(source):
    stage = 'get base system'
    pycone._print_log('', stage)

    sys_q_list = pycone._system_list()
    # return a list of choices from available system seeds and quit/help
    pycone._print_log(sys_q_list, stage)

    choice_list = pycone._choice_list(sys_q_list)
    # return a numerated list of choices for user
    pycone._print_log(choice_list, stage)

    choice = pycone._choose_from(sys_q_list, pyconeQ.base_sys)
    # return the users choice
    pycone._print_log(choice + 1, stage)

    pycone._do_help_quit(choice, sys_q_list + pyconeQ.quit_help_list)## this seems incorrect
    # allows 'help' and 'quit' choices to work

    base_system = str.lower(sys_q_list[choice])
    # make the choice to lower letter for easier manipulation
    pycone._print_log(base_system, stage)

    base_sys = pycone._base(base_system)
    # get the full seed name
    pycone._print_log(base_sys, stage)

    # master_seed =
    # creates a master seed from base + user + main seeds

    base_sys_seed = pycone.pyne_dir(base_sys)
    # get the full seed path and name
    pycone._print_log(base_sys_seed, stage)

    return base_sys
Exemplo n.º 9
0
def _install_source_system_packages(base):
    """Install packages used on the source system to create iso from backup/bootstrap
    """
    stage = 'install source packages'
    pycone._print_log('', stage)##
    choice = pycone._choose_from(pyconeQ.yes_no_list, pyconeQ.source_paks_msg)
    # return the users choice
    pycone._print_log(pyconeQ.yes_no_list, stage)##
    pycone._print_log(choice + 1, stage)##

    # Check ok to install required packages
    if choice == 0:
        source_packages = pycone._var_from_seed(base, 'packages', '_SOURCE')
        # list of packages required by the source system
        pycone._print_log(choice + 1, stage)##
        pycone._print_log(source_packages, stage)##

        pycone._package_db_update(base)
        # update the database of available packages

        for item in source_packages:
            pycone._install(base, item)
        # install each required package
    elif choice == 1:
        pycone._print_log(choice + 1, stage)##
        pycone._print_log(source_packages, stage)##
        print('PyneCone cannot continue. Exiting')
        pycone._exit()
    else:
        pycone._do_help_quit(choice, pyconeQ.yes_no_list)
Exemplo n.º 10
0
def _mount_chroot_fs(seed):

    choice = pycone._choose_from(pyconeQ.yes_no_list, pyconeQ.mount_msg)
    # create a list of choices return the users choice

    if choice == 0:
        # choose a backup of current system
        _working_dir = pycone._var_from_seed(seed, 'directories', '_BUILD_DIR')[0]

        _mount_dev = pycone._var_from_seed(seed, 'mount', '_MOUNT')[0] + ' '
        _mount_proc = pycone._var_from_seed(seed, 'mount', '_MOUNT')[1] + ' '

        _devfs = pycone._var_from_seed(seed, 'mount', '_MOUNTFS')[0]
        _procfs = pycone._var_from_seed(seed, 'mount', '_MOUNTFS')[1]

        _mount_devfs = _mount_dev + _working_dir + _devfs
        _mount_procfs = _mount_proc + _working_dir + _procfs

        #os.system(_mount_devfs)
        #os.system(_mount_procfs)
        print(_mount_devfs)
        print(_mount_procfs)
    elif choice == 1:
        # choose to use an existing iso file
        #_new_config('iso')
        print("Nothing to do. Exiting")
        pycone._exit()
    else:
        pycone._do_help_quit(choice, pyconeQ.yes_no_list)
Exemplo n.º 11
0
def _confirm_mount_chroot_fs(seed):
    """Requests the user confirm mounting of new fs
    """
    stage = 'confirm-mount-chroot-fs'

    choice = pycone._choose_from(pyconeQ.yes_no_list, pyconeQ.mount_msg + '\n' + stage)
    # create a list of choices return the users choice
    choice_list = [_mount_chroot_fs, pycone._exit]

    pycone._print_log(pyconeQ.base_type_list, choice + 1, stage)##

    choice_list[choice](seed)
Exemplo n.º 12
0
def _confirm_rsync(_mseed_):
    """Requests the user confirm rsync'ing of source system
    """
    stage = 'confirm-rsync'

    # do _mkdir_p(_mseed_,source)
    choice = pycone._choose_from(pyconeQ.yes_no_list, pyconeQ.start_rsync_msg + '\n' + stage)
    # return the users choice
    choice_list = [ _rsync_do, pycone._exit]

    pycone._print_log(pyconeQ.base_type_list, choice + 1, stage)##

    choice_list[choice](_mseed_)
Exemplo n.º 13
0
def _confirm_install_source_system_packages(base):## fix
    """Install packages used on the source system to
    create iso from backup/bootstrap
    """
    stage = 'install-source-system-packages'

    choice = pycone._choose_from(pyconeQ.yes_no_list, pyconeQ.source_paks_msg + '\n' + stage)
    # return the users choice
    choice_list = [_install_source_system_packages, pycone._exit()]

    pycone._print_log(pyconeQ.base_type_list, choice + 1, stage)##

    choice_list[choice](base)
#end
Exemplo n.º 14
0
def _ask_existing_new_build(empty):
    """choice of an existing build file or
    creation of a new build file
    """
    stage = 'ask-existing/new-build'

    _pseed_ = pycone._master_seed(None)
    # get a partial master seed (master seed without <distro>-seed
    choice = pycone._choose_from(pyconeQ.level_list, stage)
    # create a list of choices return the users choice
    choice_list = [_use_auto_seed, _ask_for_source_of_new_iso]

    pycone._print_log(pyconeQ.level_list, choice + 1, stage)##

    choice_list[choice](_pseed_)
Exemplo n.º 15
0
def _confirm_new_auto_seed(empty):
    """Confirm creation of new auto-seed
    """
    stage = 'confirm-new-auto-seed'

    # do _mkdir_p(_mseed_,source)
    choice = pycone._choose_from(pyconeQ.yes_no_list, pyconeQ.new_auto_seed_msg + '\n' + stage)
    # return the users choice
    # This will need to be changed so that the user may be able to name the
    # auto-seed file, and for this to ask for a name
    # *must be named <name>_auto_seed.conf*
    choice_list = [ _confirm_os_probe, pycone._exit]

    pycone._print_log(None, choice + 1, stage)##

    choice_list[choice](None)
Exemplo n.º 16
0
def _ask_wizard_or_expert():
    """choice of using the Wizard or
    goto Expert mode to adjust a previous build
    """
    stage = 'ask-wizard-or-expert'

    choice = pycone._choose_from(pyconeQ.mode_list, pyconeQ.welcome_msg + '\n\n' + pyconeQ.mode_msg + '\n' + stage)
    # create a list of choices return the users choice
    if pycone._auto_seed_exits():
        choice_list = [_ask_existing_new_build, _expert_mode]
    else:
        choice_list = [_confirm_new_auto_seed, _expert_mode]
    # list of decisions

    pycone._print_log(pyconeQ.mode_list, choice + 1, stage)##
    # print to log file

    choice_list[choice](None)
Exemplo n.º 17
0
def _ask_for_user_config_backup(seed):
    """Confirm copy of chosen user config files
    """
    stage = 'ask-for-user-config-backup'
    users = os.listdir('/home/') + ['None']

    user_list = []
    for item in users:
        if item != 'ftp':
            user_list.append(item)
    choice = pycone._choose_from(user_list, pyconeQ.which_user_msg)

    user = user_list[choice]

    pycone._print_log(choice, user, stage)##

    if user == 'None':
        pass
    else:
        _copy_user_config_files(seed, user)
Exemplo n.º 18
0
def _mkdir_p(base, _mseed_):
    """Create the directories needed to store new system
    """
    # make the dirs in the pyne dir, which doesn't get rsync'd
    stage = 'mkdir_p'
    pycone._print_log('', '', stage)##

    distro_dir = pycone._var_from_seed(_mseed_, 'directories', '_BUILD_DIR')
    iso_creation_dir = pycone._var_from_seed(_mseed_, 'directories', '_ISO_DIR')
    required_dirs = distro_dir + iso_creation_dir

    for dir in required_dirs:
        dir = '/home/pyne' + dir
        pycone._print_log(dir, '', stage)##
        # if path is not already present, request to create it
        # else the dir exists, and PyneCone will use them
        if not os.path.exists(dir):

            choice = pycone._choose_from(pyconeQ.yes_no_list, pyconeQ.create_new_dir_msg % dir)
            # return the users choice
            pycone._print_log(pyconeQ.yes_no_list, '', stage)##

            if choice == 0:
                pycone._print_log(choice + 1, '', stage)##
                try:
                    pycone._print_log('making dir', '', stage)
                    print("making dir", dir)
                    #os.makedirs(dir)

                except:
                    # call error handler
                    pycone._print_log('error making dir', '', stage)
                    print("error creating backup directory")
                    pycone._exit()
            elif choice == 1:
                pycone._print_log(choice + 1, '', stage)##
                print('PyneCone cannot continue. Exiting')
                pycone._exit()
            else:
                pycone._do_help_quit(choice, pyconeQ.yes_no_list)
        time.sleep(2)
Exemplo n.º 19
0
def _confirm_base_system(empty):#### new version being worked on
    """Probes the system, returns the result and asks user to confirm.
    Works with system backup, not needed for iso or bootstrap.
    """
    stage = 'confirm-base-system'

    _probe = pycone._os_prober(_pseed_)
    c_pseed = str.capitalize(_probe)
    #base = pycone._base(_pseed_)
    #_mseed_ = pycone._master_seed(str.lower(base))

    choice = pycone._choose_from(pyconeQ.yes_no_list, pyconeQ.which_system % c_pseed + '\n' + stage)
    # probe current system, then user confirm
    choice_list = [_create_master_seed, _get_base_system]
    ## create the create-master-seed def
    ## use pycone._seedlist() and _os_prober() to compare and
    ## confirm a seed file exists for current system

    pycone._print_log(pyconeQ.yes_no_list, choice + 1, stage)##
    pycone._print_log(c_system, '', stage)##

    choice_list[choice](_probe)
Exemplo n.º 20
0
def _q_base_system():
    system = pycone._os_prober(pycone._master_seed(''))
    stage = 'rsync'
    pycone._print_log('', stage)##
    c_system = str.capitalize(system)
    choice = pycone._choose_from(pyconeQ.yes_no_list, pyconeQ.which_system % c_system)
    # return the users choice
    pycone._print_log(pyconeQ.yes_no_list, stage)
    pycone._print_log(choice + 1, stage)

    if choice == 0:
        # choose a backup of current system
        pycone._print_log(choice + 1, stage)
        #pycone._rsync_live(seed)
        print('use %s system' % c_system)
    elif choice == 1:
        # choose to use an existing iso file
        #_new_config('iso')
        pycone._print_log(choice + 1, stage)
        print("Nothing to do. Exiting")
        exit()
    else:
        _help_quit(choice, pyconeQ.yes_no_list)
Exemplo n.º 21
0
def _ask_rsync(_mseed_):

    stage = 'ask-rsync'
    pycone._print_log('', stage)##
    choice = pycone._choose_from(pyconeQ.yes_no_list, pyconeQ.start_rsync_msg)
    # return the users choice
    pycone._print_log(pyconeQ.yes_no_list, stage)##

    if choice == 0:
        # choose a backup of current system
        pycone._print_log(choice + 1, stage)##
        distro_dir = pycone._var_from_seed(_mseed_, 'directories', '_BUILD_DIR')
        for dir in distro_dir:
            dir = '/home/pyne' + dir
        pycone._rsync_live(_mseed_, dir)
    elif choice == 1:
        # choose to use an existing iso file
        #_new_config('iso')
        pycone._print_log(choice + 1, stage)##
        print("Nothing to do. Exiting")
        pycone._exit()
    else:
        pycone._do_help_quit(choice, pyconeQ.yes_no_list)