diff --git a/avocado/core/app.py b/avocado/core/app.py index 1ee2b30c21bc70dc284158c12f844bd09378a06f..352f7d7a47675f5ba0bf98c3a3f8d7bf7e314297 100644 --- a/avocado/core/app.py +++ b/avocado/core/app.py @@ -63,13 +63,13 @@ class AvocadoApp(object): self.parser.finish() if self.cli_dispatcher.extensions: self.cli_dispatcher.map_method('run', self.parser.args) - except SystemExit as e: + except SystemExit as detail: # If someone tries to exit Avocado, we should first close the # STD_OUTPUT and only then exit. setattr(self.parser.args, 'paginator', 'off') output.reconfigure(self.parser.args) STD_OUTPUT.close() - sys.exit(e.code) + sys.exit(detail.code) except: # For any other exception we also need to close the STD_OUTPUT. setattr(self.parser.args, 'paginator', 'off') diff --git a/avocado/core/output.py b/avocado/core/output.py index 99cb3f242a7c6f7bbd95a8a3ac859a2851773875..6495aa4151d8ccf811684668147908f2fa8f26b0 100644 --- a/avocado/core/output.py +++ b/avocado/core/output.py @@ -299,8 +299,8 @@ class StdOutput(object): # indiscriminately. By handling them here, we can be sure # that the failure was due to stdout or stderr not being # connected to an open PIPE. - except IOError as e: - if not e.errno == errno.EPIPE: + except IOError as detail: + if not detail.errno == errno.EPIPE: raise def fake_outputs(self): diff --git a/avocado/core/restclient/cli/actions/server.py b/avocado/core/restclient/cli/actions/server.py index c13d9bd4ebd724c94784c45d87faf03798b99e08..0c922691e1122a5acb2f0b3d4ea569851f76b58d 100644 --- a/avocado/core/restclient/cli/actions/server.py +++ b/avocado/core/restclient/cli/actions/server.py @@ -27,8 +27,8 @@ def list_brief(app): """ try: data = app.connection.get_api_list() - except connection.UnexpectedHttpStatusCode as e: - if e.received == 403: + except connection.UnexpectedHttpStatusCode as detail: + if detail.received == 403: LOG_UI.error("Error: Access Forbidden") return False diff --git a/avocado/core/sysinfo.py b/avocado/core/sysinfo.py index e9c12187d8752e7d7a1e46a7b3276159a0734818..e5d5fcad7a89f095f15b3855b3dc9ac5f5405698 100644 --- a/avocado/core/sysinfo.py +++ b/avocado/core/sysinfo.py @@ -240,8 +240,8 @@ class JournalctlWatcher(Collectible): result = process.system_output(cmd, verbose=False) last_record = json.loads(astring.to_text(result, "utf-8")) return last_record['__CURSOR'] - except Exception as e: - log.debug("Journalctl collection failed: %s", e) + except Exception as detail: + log.debug("Journalctl collection failed: %s", detail) def run(self, logdir): if self.cursor: @@ -254,8 +254,8 @@ class JournalctlWatcher(Collectible): except IOError: log.debug("Not logging journalctl (lack of permissions): %s", dstpath) - except Exception as e: - log.debug("Journalctl collection failed: %s", e) + except Exception as detail: + log.debug("Journalctl collection failed: %s", detail) class LogWatcher(Collectible): @@ -336,12 +336,12 @@ class LogWatcher(Collectible): if not in_data: break out_messages.write(in_data) - except ValueError as e: - log.info(e) + except ValueError as detail: + log.info(detail) except (IOError, OSError): log.debug("Not logging %s (lack of permissions)", self.path) - except Exception as e: - log.error("Log file %s collection failed: %s", self.path, e) + except Exception as detail: + log.error("Log file %s collection failed: %s", self.path, detail) class SysInfo(object): diff --git a/avocado/plugins/run.py b/avocado/plugins/run.py index 4eadd4fd970e6a53e3ef890a96f6735998636108..b594ce060e9b91f0aedc99a9f0af35309d5b7e8a 100644 --- a/avocado/plugins/run.py +++ b/avocado/plugins/run.py @@ -204,8 +204,8 @@ class Run(CLICmd): sys.exit(exit_codes.AVOCADO_FAIL) try: args.job_timeout = time_to_seconds(args.job_timeout) - except ValueError as e: - LOG_UI.error(e.args[0]) + except ValueError as detail: + LOG_UI.error(detail.args[0]) sys.exit(exit_codes.AVOCADO_FAIL) with job.Job(args) as job_instance: pre_post_dispatcher = JobPrePostDispatcher() diff --git a/avocado/utils/asset.py b/avocado/utils/asset.py index fd692fd59624bc67c5b84a852b91823a9045bd23..ad73a78722a25a0ca64647ce1d37c244357cfab2 100644 --- a/avocado/utils/asset.py +++ b/avocado/utils/asset.py @@ -222,8 +222,8 @@ class Asset(object): os.symlink(path, self.asset_file) self._compute_hash() return self._verify() - except OSError as e: - if e.errno == errno.EEXIST: + except OSError as detail: + if detail.errno == errno.EEXIST: os.remove(self.asset_file) os.symlink(path, self.asset_file) self._compute_hash() diff --git a/avocado/utils/crypto.py b/avocado/utils/crypto.py index 465bdf8106bf774fd501c20fb0660ff95d983c9f..4a7a4ab9f7cbb9565899404e9c8bc863eae141e5 100644 --- a/avocado/utils/crypto.py +++ b/avocado/utils/crypto.py @@ -40,9 +40,9 @@ def hash_file(filename, size=None, algorithm="md5"): try: hash_obj = hashlib.new(algorithm) - except ValueError as e: + except ValueError as detail: logging.error('Returning "None" due to inability to create hash ' - 'object: "%s"', e) + 'object: "%s"', detail) return None with open(filename, 'rb') as file_to_hash: diff --git a/avocado/utils/filelock.py b/avocado/utils/filelock.py index b996f6e0807ab9512382faef9dc6e551c1cf8547..eeda383358e3606ebc2145280d18ead51d4efa5f 100644 --- a/avocado/utils/filelock.py +++ b/avocado/utils/filelock.py @@ -62,8 +62,8 @@ class FileLock(object): with open(self.filename, 'r') as f: try: content = f.read() - except Exception as e: - raise LockFailed(e.message) + except Exception as detail: + raise LockFailed(detail.message) # If file is empty, I guess someone created it with 'touch' # to manually lock the file. diff --git a/selftests/cyclical_deps b/selftests/cyclical_deps index e9f1caf4a91ff764d6a2c3b16de680aa16788771..0525f2a0f9d6aee1166fc5a42322d9c6c48c629c 100755 --- a/selftests/cyclical_deps +++ b/selftests/cyclical_deps @@ -48,8 +48,8 @@ def has_snakefood(): try: cmd = ['sfood', '-h'] subprocess.call(cmd, stdout=null) - except Exception as e: - print("Could not find sfood utility: %s: %s" % (cmd, e), file=sys.stderr) + except Exception as detail: + print("Could not find sfood utility: %s: %s" % (cmd, detail), file=sys.stderr) print("Did you forget to 'pip install snakefood'?", file=sys.stderr) return False return True