Throw meaningful exception when qubes.xml is missing

Based on kalkin-'s Rais QubesException if qubes xml config is missing
This commit is contained in:
Wojtek Porczyk 2016-04-05 16:33:49 +02:00
parent 156ecf4163
commit 42666e0ec5

View File

@ -1232,7 +1232,14 @@ class Qubes(PropertyHolder):
:raises lxml.etree.XMLSyntaxError: on syntax error in qubes.xml :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') fh = os.fdopen(fd, 'rb')
if os.name == 'posix': if os.name == 'posix':