Example #1
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)
Example #2
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_)
Example #3
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_)
Example #4
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)
Example #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
Example #6
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_)
Example #7
0
def _sys_backup(source):
    """Go through the Q&A session to build auto_seed.py
    """
    master_seed_file = '/tmp/master_seed.conf'
    stage = 'sys_backup'
    pycone._print_log('', stage)##
    base_seed = _get_base_system('')
    pycone._print_log(base_seed, stage)##

    #_write_to_auto_seed('base_seed :\n\t', base_seed, 'append')
    # update the auto-seed file with base seed type

    master_seed = pycone._master_seed(base_seed)
    # get a master-seed file of all needed seeds
    pycone._print_log('master_seed', stage)##
    pycone._print_log(master_seed, stage)##

    _install_source_system_packages(master_seed)
    # install packages used on the source system to create iso from backup/bootstrap

    #time.sleep(1)

    _needed_dirs = _new_dirs(master_seed_file)
    # get directories needed by PyneCone
    pycone._print_log(_needed_dirs, stage)##

    _mkdir_p(_needed_dirs)
    # create the directories
    pycone._print_log('mkdir', stage)##

    #time.sleep(1)

    _rsync(master_seed)
    # backup the current system
    pycone._print_log('rsync', stage)##

    #time.sleep(1)

    _mount_chroot_fs(master_seed)
    # mount the backup/bootstrap systems for chroot
    pycone._print_log('chrootfs', stage)##

    _chroot(master_seed)
    pycone._print_log('chroot', stage)##

    print('Hello')
Example #8
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)
Example #9
0
import io
import os
import time
import pycone
import pyconeQ
import configparser
import pwd
import sys
import string
###############################################################################





system = pycone._os_prober(pycone._master_seed(''))

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)
Example #10
0
def _seed_probe_match(_probe_):
    """create a full master-seed file with distro-seed
    """
    _dseed_ = pycone._base(_probe_)
    # return the full name of the seed
    _mseed_ = pycone._master_seed(_dseed_)
Example #11
0
# pyne_sync.py
## system backup script

import io
import os
import time
import pycone
import pyconeQ
import configparser
from os.path import exists, join
from os import pathsep
import sys

application = 'rsync'
_seed_ = pycone._master_seed('')

def _find_file(filename):
    """Find a given file in the system $PATH or return False.
    This is not a file search function. It is not recursive and
    descends no trees.
    """
    try:
        search_path = os.environ['PATH']
        paths = str.split(search_path, pathsep) + sys.path
        for path in paths:
            if exists(join(path, filename)):
                return os.path.abspath(join(path, filename))
    except:
        return False
#end-search_file