"""
-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
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, "")
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:
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, "")