From 762e64402245d0af404f1bb1305dba7b834f3af9 Mon Sep 17 00:00:00 2001 From: mbusb Date: Thu, 27 Apr 2017 20:46:21 +0530 Subject: [PATCH] Commandline improvements 1. Reframe wordings when displaying messages under CLI 2. Corrected systemrescuecd subdir path 3. Corrected CLI usage example for windows --- multibootusb | 29 ++++++++++++++++------------- scripts/install.py | 1 - scripts/update_cfg_file.py | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/multibootusb b/multibootusb index 52693c9..af491c1 100644 --- a/multibootusb +++ b/multibootusb @@ -29,8 +29,6 @@ except: import scripts gui = True -iso_link = None -usb_disk = None uninstall = False @@ -41,15 +39,15 @@ def usage(): print(' -h or --help : Print this help message and exit') print(' -i or --iso : Path to ISO file') print(' -t or --target : Path to target USB device partition (example /dev/sdb1)') - print(' -c or --command : This option is must for invoking multibootusb from command line') - print(' -u or --uninstall : List and uninstall distro from USB disk') + print(' -c or --command : Invoke command line usage. This option is must') + print(' -u or --uninstall : List and uninstall distro from an USB disk') print(' -d or --debug : Enable debug messages (very verbose!)\n') - print(' Command line example for making a bootable USB from command line should look like this:\n') + print(' Eexample for making a bootable USB from command line should look like this:\n') print('\tpython3 multibootusb -c -i ../../favourite.iso -t /dev/sdb1 on Linux and \n') - print('\tpython3 multibootusb -c -i ../../favourite.iso -t /dev/sdb1 on Windows\n') - print(' Command line example for uninstalling distro from USB should look like this:\n') + print('\tpython3 multibootusb -c -i ../../favourite.iso -t G: on Windows\n') + print(' Example for uninstalling distro from an USB should look like this:\n') print('\tpython3 multibootusb -c -u -t /dev/sdb1 on Linux and \n') - print('\tpython3 multibootusb -c -u -t /dev/sdb1 on Windows\n') + print('\tpython3 multibootusb -c -u -t G: on Windows\n') exit(2) @@ -102,16 +100,21 @@ if __name__ == '__main__': if config.debug is True: from scripts.debug import colors - print(colors.HEADER + "=== DEBUG ENABLED ===") + log(colors.HEADER + "=== DEBUG ENABLED ===") if gui is False: - if uninstall is True and config.usb_disk is not None: + if uninstall is True and config.usb_disk is not '': cli_uninstall_distro() - elif config.iso_link is None and config.usb_disk is None: + elif uninstall is True and config.usb_disk is '': + log('\nYou must provide \'-t\' option to point to your USB disk for uninstalling a distro.\n' + 'See the usage example below.') usage() - elif config.iso_link is None or config.usb_disk is None: - print('\nOptions \'-i\' and \'t\' must be supplied together. See the usage below.') + elif config.image_path is '' and config.usb_disk is '': + log('\nNo option provided. See the usage below.') + usage() + elif config.image_path is '' or config.usb_disk is '': + log('\nOptions \'-i\' and \'-t\' must be supplied together. See the usage below.') usage() else: cli_install_distro() diff --git a/scripts/install.py b/scripts/install.py index c9a9524..4cefbd4 100644 --- a/scripts/install.py +++ b/scripts/install.py @@ -28,7 +28,6 @@ def install_distro(): :return: """ usb_mount = config.usb_mount - print('------------------>' + config.usb_mount) install_dir = os.path.join(config.usb_mount, "multibootusb", iso_basename(config.image_path)) _iso_file_list = iso.iso_file_list(config.image_path) diff --git a/scripts/update_cfg_file.py b/scripts/update_cfg_file.py index 407f2af..d6bde67 100644 --- a/scripts/update_cfg_file.py +++ b/scripts/update_cfg_file.py @@ -134,7 +134,7 @@ def update_distro_cfg_files(iso_link, usb_disk, distro, persistence=0): iso_basename(iso_link) + '/ ', string, flags=re.I) elif distro == "systemrescuecd": rows = [] - subdir = '/multibootusb/' + iso_basename(iso_link) + '/' + subdir = '/multibootusb/' + iso_basename(iso_link) for line in string.splitlines(True): addline = True if re.match(r'append.*--.*', line, flags=re.I):