提交 0fee03b6 编写于 作者: C Cleber Rosa 提交者: Lukáš Doktor

Lint: fix some of the pylint C0103 (invalid-name) conditions

These short exception detail variables are just one of the many
"invalid-name" violations we have.  Better have some fixed than
none.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 a249a33b
......@@ -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')
......
......@@ -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):
......
......@@ -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
......
......@@ -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):
......
......@@ -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()
......
......@@ -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()
......
......@@ -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:
......
......@@ -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.
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册