Skip to content

Commit 25bb3f4

Browse files
Merge pull request #71 from xenserver-next/fix-accessor-exceptions
xcp/accessor.py: Fix pylint warning on duplicate exceptions
2 parents 2578989 + e2c02fe commit 25bb3f4

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

xcp/accessor.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,7 @@ def __init__(self, location, ro):
102102
def openAddress(self, address):
103103
try:
104104
filehandle = open(os.path.join(self.location, address), "rb")
105-
except OSError as e:
106-
if e.errno == errno.EIO:
107-
self.lastError = 5
108-
else:
109-
self.lastError = mapError(e.errno)
110-
return False
111-
except IOError as e:
105+
except (IOError, OSError) as e:
112106
if e.errno == errno.EIO:
113107
self.lastError = 5
114108
else:
@@ -223,13 +217,7 @@ def __init__(self, baseAddress, ro):
223217
def openAddress(self, address):
224218
try:
225219
file = open(os.path.join(self.baseAddress, address), "rb")
226-
except IOError as e:
227-
if e.errno == errno.EIO:
228-
self.lastError = 5
229-
else:
230-
self.lastError = mapError(e.errno)
231-
return False
232-
except OSError as e:
220+
except (IOError, OSError) as e:
233221
if e.errno == errno.EIO:
234222
self.lastError = 5
235223
else:
@@ -316,13 +304,7 @@ def access(self, path):
316304
return True
317305
lst = self.ftp.nlst(os.path.dirname(url))
318306
return os.path.basename(url) in list(map(os.path.basename, lst))
319-
except IOError as e:
320-
if e.errno == errno.EIO:
321-
self.lastError = 5
322-
else:
323-
self.lastError = mapError(e.errno)
324-
return False
325-
except OSError as e:
307+
except (IOError, OSError) as e:
326308
if e.errno == errno.EIO:
327309
self.lastError = 5
328310
else:

0 commit comments

Comments
 (0)