'except FileNotFoundError' instead of ENOENT check

This commit is contained in:
Rusty Bird 2018-09-13 19:46:45 +00:00
parent 5aa35a1208
commit b3983f5ef8
No known key found for this signature in database
GPG Key ID: 469D78F47AAF2ADF
2 changed files with 4 additions and 9 deletions

View File

@ -22,7 +22,6 @@
import collections import collections
import copy import copy
import errno
import functools import functools
import grp import grp
import itertools import itertools
@ -1008,8 +1007,8 @@ class Qubes(qubes.PropertyHolder):
try: try:
fd = os.open(self._store, fd = os.open(self._store,
os.O_RDWR | (os.O_CREAT * int(for_save))) os.O_RDWR | (os.O_CREAT * int(for_save)))
except OSError as e: except FileNotFoundError:
if not for_save and e.errno == errno.ENOENT: if not for_save:
raise qubes.exc.QubesException( raise qubes.exc.QubesException(
'Qubes XML store {!r} is missing; ' 'Qubes XML store {!r} is missing; '
'use qubes-create tool'.format(self._store)) 'use qubes-create tool'.format(self._store))

View File

@ -24,7 +24,6 @@ from __future__ import absolute_import
import asyncio import asyncio
import base64 import base64
import errno
import grp import grp
import os import os
import os.path import os.path
@ -1461,11 +1460,8 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
try: try:
# TODO: make it async? # TODO: make it async?
shutil.rmtree(self.dir_path) shutil.rmtree(self.dir_path)
except OSError as e: except FileNotFoundError:
if e.errno == errno.ENOENT: pass
pass
else:
raise
yield from self.storage.remove() yield from self.storage.remove()
@asyncio.coroutine @asyncio.coroutine