Commits

Michał Górny committed f1087fb

Introduce BootloaderNotFound instead of implicit IOError.

  • Participants
  • Parent commits 595ee75

Comments (0)

Files changed (3)

File ecleankernel/bootloader/__init__.py

 from .yaboot import Yaboot
 from .symlinks import Symlinks
 
+from .common import BootloaderNotFound
+
 import errno
 
 bootloaders = (LILO, GRUB2, GRUB, Yaboot, Symlinks)
 			debug.indent()
 			try:
 				return bl(debug = debug)
-			except IOError as e:
-				if e.errno != errno.ENOENT:
-					raise
+			except BootloaderNotFound:
+				pass
 			finally:
 				debug.outdent()

File ecleankernel/bootloader/common.py

+#	vim:fileencoding=utf-8
+# (c) 2011 Michał Górny <mgorny@gentoo.org>
+# Released under the terms of the 2-clause BSD license.
+
+class BootloaderNotFound(Exception):
+	pass

File ecleankernel/bootloader/lilo.py

 
 from __future__ import print_function
 
-import re
+from .common import BootloaderNotFound
+
+import errno, re
 
 class LILO(object):
 	name = 'lilo'
 				re.MULTILINE | re.IGNORECASE)
 		self.path = path or self.def_path
 
-		with open(self.path) as f:
-			debug.print('%s found' % (path or self.def_path))
-			self._content = f.read()
+		try:
+			with open(self.path) as f:
+				debug.print('%s found' % self.path)
+				self._content = f.read()
+		except IOError as e:
+			if e.errno != errno.ENOENT:
+				raise
+			else:
+				raise BootloaderNotFound()
 
 	def _get_kernels(self, content):
 		debug = self._debug