From: Michael Prokop Date: Sun, 28 Jun 2009 09:05:45 +0000 (+0200) Subject: Support use with python version 2.4 X-Git-Tag: v0.9.8~2 X-Git-Url: https://git.grml.org/?p=grml2usb.git;a=commitdiff_plain;h=5296685e8dc17decbbd1f163bc06c25f336e313c Support use with python version 2.4 --- diff --git a/debian/changelog b/debian/changelog index 687e732..8010b63 100644 --- a/debian/changelog +++ b/debian/changelog @@ -32,6 +32,7 @@ grml2usb (0.9.8) UNRELEASED; urgency=low - mention grml2iso - improve section link names for the online version - add 'grub-probe: error: unknown filesystem' + * Support use with python version 2.4. -- Michael Prokop Tue, 16 Jun 2009 01:39:53 +0200 diff --git a/grml2usb b/grml2usb index fd03ef9..fd6dc17 100755 --- a/grml2usb +++ b/grml2usb @@ -12,7 +12,7 @@ This script installs a grml system (either a running system or ISO[s]) to a USB """ -from __future__ import with_statement +# from __future__ import with_statement from optparse import OptionParser from inspect import isroutine, isclass import datetime, logging, os, re, subprocess, sys, tempfile, time @@ -612,20 +612,21 @@ def install_grub(device): device_mountpoint = tempfile.mkdtemp(prefix="grml2usb") register_tmpfile(device_mountpoint) try: - mount(device, device_mountpoint, "") - logging.debug("grub-install --recheck --no-floppy --root-directory=%s %s", device_mountpoint, device) - proc = subprocess.Popen(["grub-install", "--recheck", "--no-floppy", - "--root-directory=%s" % device_mountpoint, device], stdout=file(os.devnull, "r+")) - proc.wait() - if proc.returncode != 0: - # raise Exception("error executing grub-install") - logging.critical("Fatal: error executing grub-install (please check the grml2usb FAQ)") + try: + mount(device, device_mountpoint, "") + logging.debug("grub-install --recheck --no-floppy --root-directory=%s %s", device_mountpoint, device) + proc = subprocess.Popen(["grub-install", "--recheck", "--no-floppy", + "--root-directory=%s" % device_mountpoint, device], stdout=file(os.devnull, "r+")) + proc.wait() + if proc.returncode != 0: + # raise Exception("error executing grub-install") + logging.critical("Fatal: error executing grub-install (please check the grml2usb FAQ)") + cleanup() + sys.exit(1) + except CriticalException, error: + logging.critical("Fatal: %s" % error) cleanup() sys.exit(1) - except CriticalException, error: - logging.critical("Fatal: %s" % error) - cleanup() - sys.exit(1) finally: unmount(device_mountpoint, "") @@ -1479,12 +1480,13 @@ def handle_dir(live_image, device): sys.exit(1) try: - grml_flavour = identify_grml_flavour(live_image) - logging.info("Identified grml flavour \"%s\"." % grml_flavour) - install_iso_files(grml_flavour, live_image, device, device_mountpoint) - except TypeError: - logging.critical("Fatal: a critical error happend during execution (not a grml ISO?), giving up") - sys.exit(1) + try: + grml_flavour = identify_grml_flavour(live_image) + logging.info("Identified grml flavour \"%s\"." % grml_flavour) + install_iso_files(grml_flavour, live_image, device, device_mountpoint) + except TypeError: + logging.critical("Fatal: a critical error happend during execution (not a grml ISO?), giving up") + sys.exit(1) finally: if remove_device_mountpoint: try: @@ -1537,12 +1539,13 @@ def handle_iso(iso, device): sys.exit(1) try: - grml_flavour = identify_grml_flavour(iso_mountpoint) - logging.info("Identified grml flavour \"%s\"." % grml_flavour) - install_iso_files(grml_flavour, iso_mountpoint, device, device_mountpoint) - except TypeError: - logging.critical("Fatal: a critical error happend during execution (not a grml ISO?), giving up") - sys.exit(1) + try: + grml_flavour = identify_grml_flavour(iso_mountpoint) + logging.info("Identified grml flavour \"%s\"." % grml_flavour) + install_iso_files(grml_flavour, iso_mountpoint, device, device_mountpoint) + except TypeError: + logging.critical("Fatal: a critical error happend during execution (not a grml ISO?), giving up") + sys.exit(1) finally: if os.path.isdir(iso_mountpoint) and remove_iso_mountpoint: unmount(iso_mountpoint, "")