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)
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)
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)
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)
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)
def _start_here(): """Start the script here """ if pycone._root(): if pycone.python_ver(): pycone._os_system('rm -f ' + pycone.pyne_log) # remove the old debug log file, fresh file each run _ask_wizard_or_expert() pycone._exit(None) else: print(pyconeQ.python_ver) exit(None) else: print(pyconeQ.root_msg) exit(None)
def _start_here(): """Start the script here """ if pycone._root(): if pycone.python_ver(): os.system('rm /tmp/pyne_log.txt') # remove the old debug log file, fresh file each run _ask_existing_new_build() pycone._exit() else: print(pyconeQ.python_ver) exit() else: print(pyconeQ.root_msg) exit()
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)
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)
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
def _unimplemented(): print('Not yet implemented') time.sleep(3) pycone._exit('Please try options without *')