New option for CLI

1. Added functionality to skip confirmation with -y or yes CLI switch
2. Now it is possible to add many distro at a time (batch) process using CLI switch
   example CLI usge is python3 multibootusb -c -y -i /path/to/name.iso,/path/to/diss_name.iso -t G:
   (remember not to add space between iso paths)

This commit solves https://github.com/mbusb/multibootusb/issues/137 and https://github.com/mbusb/multibootusb/issues/136
pull/157/head
mbusb 7 years ago
parent 14c9dec64a
commit 336d57f585

@ -68,8 +68,8 @@ if __name__ == '__main__':
admin.runAsAdmin()
sys.exit(0)
try:
opts, args = getopt.getopt(sys.argv[1:], 'i:t:vhcud',
['iso=', 'target=', 'version', 'help', 'command', 'uninstall', 'debug'])
opts, args = getopt.getopt(sys.argv[1:], 'i:t:yvhcud',
['iso=', 'target=', 'yes', 'version', 'help', 'command', 'uninstall', 'debug'])
except getopt.GetoptError:
usage()
sys.exit(2)
@ -81,7 +81,10 @@ if __name__ == '__main__':
print_version()
sys.exit()
elif opt in ('-i', '--iso'):
config.image_path = arg
if ',' not in arg:
config.image_path = arg
else:
config.image_path = arg.split(',')
elif opt in ('-t', '--target'):
config.usb_disk = arg
elif opt in ('-c', '--command'):
@ -90,6 +93,8 @@ if __name__ == '__main__':
uninstall = True
elif opt in ('-d', '--debug'):
config.debug = True
elif opt in ('-y', '--yes'):
config.yes = True
else:
gui = True
#start_gui()

@ -25,6 +25,8 @@ uninstall_distro_dir_path = ""
iso_file_list = ''
iso_bin_dir = ''
process_exist = None
yes = False
imager_iso_link = ""
imager_usb_disk_selected = ""

@ -44,35 +44,65 @@ def cli_install_distro():
log(config.usb_disk + ' is not a valid device partition...')
exit(1)
#elif integrity(config.image_path) is not True:
# log(config.image_path, ' failed to pass integrity check...')
# log(config.image_path + ' failed to pass integrity check...')
# exit(1)
elif size_not_enough(config.image_path, config.usb_disk) is True:
log(config.usb_disk + ' does not have enough space...')
else:
usb_details = details(config.usb_disk)
config.usb_mount = usb_details['mount_point']
print(config.usb_mount)
print(config.image_path)
config.usb_uuid = usb_details['uuid']
config.usb_label = usb_details['label']
prepare_mbusb_host_dir()
extract_cfg_file(config.image_path)
_distro = distro(iso_cfg_ext_dir(), config.image_path)
if isinstance(config.image_path, str) is True:
iso_install(config.image_path)
elif isinstance(config.image_path, list) is True:
# Transfer the list to other variable and loop through iso image
iso_list = config.image_path
for config.image_path in iso_list:
iso_install(config.image_path)
def iso_install(iso_image):
"""
Script for installing iso image to a disk. This can be called by other script for auto install of many distros
:param iso_image: Path to ISO image
:return:
"""
if size_not_enough(iso_image, config.usb_disk) is True:
log(config.usb_disk + ' does not have enough space...')
else:
clean_iso_cfg_ext_dir(os.path.join(multibootusb_host_dir(), "iso_cfg_ext_dir")) # Need to be cleaned everytime
extract_cfg_file(iso_image)
_distro = distro(iso_cfg_ext_dir(), iso_image)
if _distro is not None:
log('Detected distro type is :' + _distro)
log('\nSelected ISO is :'+ quote(iso_name(config.image_path)))
log('Selected target device is :'+ quote(config.usb_disk), '\n')
log('Please confirm the option.')
log('Y/y/Yes/yes/YES or N/n/No/no/NO')
if read_input_yes() is True:
log('Initiating installation process for ' + iso.iso_basename(iso_image))
if config.yes is not True:
log('Detected distro type is :' + _distro)
log('\nSelected ISO is :' + quote(iso_name(iso_image)))
log('Selected target device is :' + quote(config.usb_disk), '\n')
log('Please confirm the option.')
log('Y/y/Yes/yes/YES or N/n/No/no/NO')
if read_input_yes() is True:
config.distro = _distro
copy_mbusb_dir_usb(config.usb_disk)
install_progress()
syslinux_distro_dir(config.usb_disk, iso_image, _distro)
syslinux_default(config.usb_disk)
update_distro_cfg_files(iso_image, config.usb_disk, _distro)
log('Finished installing ' + iso.iso_basename(iso_image))
else:
log('Not proceeding. User cancelled the operation.')
else:
log('Skipping user confirmation for ' + iso_image)
config.distro = _distro
copy_mbusb_dir_usb(config.usb_disk)
install_progress()
syslinux_distro_dir(config.usb_disk, config.image_path, _distro)
syslinux_distro_dir(config.usb_disk, iso_image, _distro)
syslinux_default(config.usb_disk)
update_distro_cfg_files(config.image_path, config.usb_disk, _distro)
update_distro_cfg_files(iso_image, config.usb_disk, _distro)
log('Finished installing ' + iso.iso_basename(iso_image))
else:
log('\n\nSorry ' + iso_name(config.image_path) + ' is not supported at the moment.\n'
log('\n\nSorry ' + iso_name(iso_image) + ' is not supported at the moment.\n'
'Please report tissue at https://github.com/mbusb/multibootusb/issues\n')

Loading…
Cancel
Save