diff --git a/lib/rucio/client/baseclient.py b/lib/rucio/client/baseclient.py index 9c93e01cc1..77a5df050d 100644 --- a/lib/rucio/client/baseclient.py +++ b/lib/rucio/client/baseclient.py @@ -412,7 +412,7 @@ def _send_request(self, url, headers=None, type_='GET', data=None, params=None, if retry > self.request_retries: raise continue - except IOError as error: + except OSError as error: # Handle Broken Pipe # While in python3 we can directly catch 'BrokenPipeError', in python2 it doesn't exist. if getattr(error, 'errno') != errno.EPIPE: @@ -859,7 +859,7 @@ def __read_token(self): token_file_handler = open(self.token_file, 'r') self.auth_token = token_file_handler.readline() self.headers['X-Rucio-Auth-Token'] = self.auth_token - except IOError as error: + except OSError as error: print("I/O error({0}): {1}".format(error.errno, error.strerror)) except Exception: raise @@ -890,7 +890,7 @@ def __write_token(self): with fdopen(file_d, "w") as f_exp_epoch: f_exp_epoch.write(str(self.token_exp_epoch)) move(file_n, self.token_exp_epoch_file) - except IOError as error: + except OSError as error: print("I/O error({0}): {1}".format(error.errno, error.strerror)) except Exception: raise diff --git a/lib/rucio/common/cache.py b/lib/rucio/common/cache.py index 1abd8f8bae..ccd0150a39 100644 --- a/lib/rucio/common/cache.py +++ b/lib/rucio/common/cache.py @@ -35,7 +35,7 @@ import pymemcache _mc_client = pymemcache.Client(CACHE_URL, connect_timeout=1, timeout=1) _mc_client.version() -except IOError: +except OSError: ENABLE_CACHING = False except ImportError: ENABLE_CACHING = False diff --git a/lib/rucio/common/pcache.py b/lib/rucio/common/pcache.py index b937d2dd02..ddcd6f2697 100644 --- a/lib/rucio/common/pcache.py +++ b/lib/rucio/common/pcache.py @@ -1127,7 +1127,7 @@ def lock_file(self, name, blocking=True): return try: f = open(name, 'w') - except IOError as e: + except OSError as e: self.log(ERROR, "open: %s", e) return e.errno @@ -1139,7 +1139,7 @@ def lock_file(self, name, blocking=True): try: status = fcntl.lockf(f, flag) break - except IOError as e: + except OSError as e: if e.errno in (errno.EAGAIN, errno.EACCES) and not blocking: f.close() del self.locks[name] diff --git a/lib/rucio/core/rule.py b/lib/rucio/core/rule.py index 49d1f8420a..e9b103f84a 100644 --- a/lib/rucio/core/rule.py +++ b/lib/rucio/core/rule.py @@ -2791,7 +2791,7 @@ def generate_email_for_rule_ok_notification( try: with open(template_path, 'r') as templatefile: template = Template(templatefile.read()) - except IOError as ex: + except OSError as ex: logger(logging.ERROR, "Couldn't open file '%s'", template_path, exc_info=ex) return diff --git a/lib/rucio/daemons/auditor/hdfs.py b/lib/rucio/daemons/auditor/hdfs.py index 1c1e26df59..e7ad1a2108 100644 --- a/lib/rucio/daemons/auditor/hdfs.py +++ b/lib/rucio/daemons/auditor/hdfs.py @@ -32,7 +32,7 @@ def _hdfs_get(src_url, dst_path): ) _, stderr = get.communicate() if get.returncode != 0: - raise IOError('_hdfs_get(): "{0}": {1}. Return code {2}'.format( + raise OSError('_hdfs_get(): "{0}": {1}. Return code {2}'.format( ' '.join(cmd), stderr, get.returncode, diff --git a/lib/rucio/rse/protocols/posix.py b/lib/rucio/rse/protocols/posix.py index 9c9ab7a937..cdd670c77a 100644 --- a/lib/rucio/rse/protocols/posix.py +++ b/lib/rucio/rse/protocols/posix.py @@ -70,12 +70,12 @@ def get(self, pfn, dest, transfer_timeout=None): """ try: shutil.copy(self.pfn2path(pfn), dest) - except IOError as e: + except OSError as e: try: # To check if the error happend local or remote with open(dest, 'wb'): pass call(['rm', '-rf', dest]) - except IOError as e: + except OSError as e: if e.errno == 2: raise exception.DestinationNotAccessible(e) else: @@ -109,7 +109,7 @@ def put(self, source, target, source_dir=None, transfer_timeout=None): if not os.path.exists(dirs): os.makedirs(dirs) shutil.copy(sf, target) - except IOError as e: + except OSError as e: if e.errno == 2: raise exception.SourceNotFound(e) elif not self.exists(self.rse['prefix']): @@ -151,7 +151,7 @@ def rename(self, pfn, new_pfn): if not os.path.exists(os.path.dirname(new_path)): os.makedirs(os.path.dirname(new_path)) os.rename(path, new_path) - except IOError as e: + except OSError as e: if e.errno == 2: if self.exists(self.pfn2path(path)): raise exception.SourceNotFound(e) diff --git a/lib/rucio/rse/protocols/webdav.py b/lib/rucio/rse/protocols/webdav.py index 61ddba3d09..d3c740e641 100644 --- a/lib/rucio/rse/protocols/webdav.py +++ b/lib/rucio/rse/protocols/webdav.py @@ -331,13 +331,13 @@ def put(self, source, target, source_dir=None, transfer_timeout=None, progressba raise exception.RucioException(result.status_code, result.text) except requests.exceptions.ConnectionError as error: raise exception.ServiceUnavailable(error) - except IOError as error: + except OSError as error: raise exception.SourceNotFound(error) except requests.exceptions.ConnectionError as error: raise exception.ServiceUnavailable(error) except requests.exceptions.ReadTimeout as error: raise exception.ServiceUnavailable(error) - except IOError as error: + except OSError as error: raise exception.SourceNotFound(error) def rename(self, pfn, new_pfn):