Anonymous avatar Anonymous committed fc80a84

Fixed crash when bootsector cannot be read and replaced it with a friendly error message on the ui

Comments (0)

Files changed (1)

src/vasm/ui/tui/modules/tui_bootloaders.py

         # FIXME:
         # When running in a chroot environment, this will produce an error
         # because the chroot has no / mountpoint            
+	if not bsector:
+	    logger.error('Unable to find current bootsector.  Possible chroot environment.')
+	    logger.error('%s bailing out.'% __file__)
+	    self.parent.return_home()
+
         if bsector:
             rootdev = bsector[:len('/dev/sda'):]
             currentbootloader = BOOTLOADERS.MBR(rootdev).read_bootloader() or \
 def __vasm_test__():
     return os.geteuid() == 0
 
+
 def __run__(parent):
+    # check if we can read the bootsector.
+    bsector = BOOTLOADERS.get_current_bootsector()
+    if bsector is None:
+	msg = (
+		_("This module is not available because your current bootsector cannot be read."),
+		_("This could indicate that you are working inside a chroot environment."),
+		)
+	dia = dialogs.Error(
+		parent = parent,
+		buttons = [("OK", parent.return_home)],
+		message = '  '.join(msg)
+		)
+	logger.error('Unable to read bootsector.  %s bailing out'% __file__)
+	return parent.pop_module(dia)
     mod = BootloaderTui(parent)
     parent.pop_module(mod)
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.