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

View File

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