Support use with python version 2.4
authorMichael Prokop <mika@grml.org>
Sun, 28 Jun 2009 09:05:45 +0000 (11:05 +0200)
committerMichael Prokop <mika@grml.org>
Sun, 28 Jun 2009 09:05:45 +0000 (11:05 +0200)
debian/changelog
grml2usb

index 687e732..8010b63 100644 (file)
@@ -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 <mika@grml.org>  Tue, 16 Jun 2009 01:39:53 +0200
 
index fd03ef9..fd6dc17 100755 (executable)
--- 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, "")