X-Git-Url: https://git.grml.org/?p=grml2usb.git;a=blobdiff_plain;f=grml2usb;h=e2d927995190ad5167e5fa3a1a16d207b789bbcf;hp=7afeb4881b76f0f48184bc008385c7498dc0367f;hb=073fee44304aa4279c7192b33557a5e139f11b16;hpb=3664e4ae1482b8951b741d459f8860ba3a4b38c1 diff --git a/grml2usb b/grml2usb index 7afeb48..e2d9279 100755 --- a/grml2usb +++ b/grml2usb @@ -65,8 +65,7 @@ RE_LOOP_DEVICE = re.compile(r"/dev/loop\d+$") def syslinux_warning(option, opt, opt_parser): - """A helper function for printing a warning about deprecated option - """ + """A helper function for printing a warning about deprecated option""" # pylint: disable-msg=W0613 sys.stderr.write( "Note: the --syslinux option is deprecated as syslinux " @@ -77,8 +76,7 @@ def syslinux_warning(option, opt, opt_parser): # if grub option is set, unset syslinux option def grub_option(option, opt, opt_parser): - """A helper function adjusting other option values - """ + """A helper function adjusting other option values""" # pylint: disable-msg=W0613 setattr(opt_parser.values, option.dest, True) setattr(opt_parser.values, "syslinux", False) @@ -267,8 +265,7 @@ class VerifyException(Exception): def cleanup(): - """Cleanup function to make sure there aren't any mounted devices left behind. - """ + """Cleanup function to make sure there aren't any mounted devices left behind.""" def del_failed(_fn, path, _exc): logging.warning("Deletion of %s failed in temporary folder", path) @@ -403,8 +400,7 @@ def which(program): def get_defaults_file(iso_mount, flavour, name): - """get the default file for syslinux - """ + """get the default file for syslinux""" bootloader_dirs = ["/boot/isolinux/", "/boot/syslinux/"] for directory in bootloader_dirs: for name in name, "%s_%s" % (get_flavour_filename(flavour), name): @@ -520,7 +516,7 @@ def mkfs_fat16(device): logging.info("Formating partition with fat16 filesystem") logging.debug("mkfs.vfat -F 16 %s", device) - proc = subprocess.Popen(["mkfs.vfat", "-F", "16", device]) + proc = subprocess.Popen(["mkfs.vfat", "-n", "GRML", "-F", "16", device]) proc.wait() if proc.returncode != 0: raise CriticalException("error executing mkfs.vfat") @@ -906,13 +902,21 @@ def unmount(target, unmount_options): unregister_mountpoint(target) +def extract_device_name(device): + """Extract the device name of a given path + + @device: device name, like /dev/sda1 or /dev/sda + """ + return re.match(r"/dev/(.*?)\d*$", device).group(1) + + def check_for_usbdevice(device): """Check whether the specified device is a removable USB device @device: device name, like /dev/sda1 or /dev/sda """ - usbdevice = re.match(r"/dev/(.*?)\d*$", device).group(1) + usbdevice = extract_device_name(device) # newer systems: usbdev = os.path.realpath("/sys/class/block/" + usbdevice + "/removable") if not os.path.isfile(usbdev): @@ -1322,8 +1326,7 @@ def get_device_from_partition(partition): def get_flavour(flavour_str): - """Returns the flavour of a grml version string - """ + """Returns the flavour of a grml version string""" return re.match(r"[\w-]*", flavour_str).group() @@ -1799,8 +1802,7 @@ def install_grml(mountpoint, device): def remove_mountpoint(mountpoint): - """remove a registered mountpoint - """ + """remove a registered mountpoint""" try: unmount(mountpoint, "")