Forráskód Böngészése

Throw meaningful exception when qubes.xml is missing

Based on kalkin-'s Rais QubesException if qubes xml config is missing
Wojtek Porczyk 8 éve
szülő
commit
42666e0ec5
1 módosított fájl, 8 hozzáadás és 1 törlés
  1. 8 1
      qubes/__init__.py

+ 8 - 1
qubes/__init__.py

@@ -1232,7 +1232,14 @@ class Qubes(PropertyHolder):
         :raises lxml.etree.XMLSyntaxError: on syntax error in qubes.xml
         '''
 
-        fd = os.open(self._store, os.O_RDWR) # no O_CREAT
+        try:
+            fd = os.open(self._store, os.O_RDWR) # no O_CREAT
+        except OSError as e:
+            if e.errno != errno.ENOENT:
+                raise
+            raise qubes.exc.QubesException(
+                'Qubes XML store {!r} is missing; use qubes-create tool'.format(
+                    self._store))
         fh = os.fdopen(fd, 'rb')
 
         if os.name == 'posix':