Michał Górny avatar Michał Górny committed ed17f20

Refuse to proceed if one of kernels is not writable.

Comments (0)

Files changed (2)

ecleankernel/cli.py

 			print('- %s: %s' % (k.version, ', '.join(reason)))
 	else:
 		for k, reason in removals:
+			k.check_writable()
+
+		for k, reason in removals:
 			print('* Removing kernel %s (%s)' % (k.version, ', '.join(reason)))
 			del kernels[k.version]
 

ecleankernel/kernel.py

 from glob import glob
 
 class PathRef(str):
-	def __init__(self, *args, **kwargs):
+	def __init__(self, path):
+		str.__init__(self, path)
 		self._refs = 0
 
 	def ref(self):
 		del self.modules
 		del self.build
 
+	def check_writable(self):
+		for path in (self.vmlinuz, self.systemmap, self.config,
+				self.modules, self.build):
+			if not os.access(path, os.W_OK):
+				raise OSError('%s not writable, refusing to proceed' % path)
+
 	def __repr__(self):
 		return "Kernel(%s, '%s%s%s%s%s')" % (repr(self.version),
 				'V' if self.vmlinuz else ' ',
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.