未验证 提交 d0fb1f15 编写于 作者: C Cleber Rosa

Merge remote-tracking branch 'cacarrara/enables-pylint-w0702'

Signed-off-by: NCleber Rosa <crosa@redhat.com>
......@@ -339,7 +339,7 @@ class TestLoaderProxy(object):
sys.path.insert(0, test_module_dir)
f, p, d = imp.find_module(module_name, [test_module_dir])
test_module = imp.load_module(module_name, f, p, d)
except:
except: # pylint: disable=W0702
# On load_module exception we fake the test class and pass
# the exc_info as parameter to be logged.
test_parameters['methodName'] = 'test'
......
......@@ -827,7 +827,7 @@ class Test(unittest.TestCase, TestData):
except exceptions.TestCancel as details:
stacktrace.log_exc_info(sys.exc_info(), logger=LOG_JOB)
raise
except: # Old-style exceptions are not inherited from Exception()
except: # Old-style exceptions are not inherited from Exception() pylint: disable=W0702
stacktrace.log_exc_info(sys.exc_info(), logger=LOG_JOB)
details = sys.exc_info()[1]
if not isinstance(details, Exception): # Avoid passing nasty exc
......@@ -852,7 +852,7 @@ class Test(unittest.TestCase, TestData):
except exceptions.TestCancel as details:
stacktrace.log_exc_info(sys.exc_info(), logger=LOG_JOB)
raise
except: # avoid old-style exception failures
except: # avoid old-style exception failures pylint: disable=W0702
stacktrace.log_exc_info(sys.exc_info(), logger=LOG_JOB)
details = sys.exc_info()[1]
cleanup_exception = exceptions.TestSetupFail(details)
......
......@@ -43,5 +43,5 @@ class TestsTmpDir(JobPre, JobPost):
try:
shutil.rmtree(self._dirname)
del os.environ[self._varname]
except:
except Exception:
pass
......@@ -157,7 +157,7 @@ class Asset(object):
with FileLock(asset_file, 1):
if self._verify(asset_file):
return asset_file
except:
except Exception:
exc_type, exc_value = sys.exc_info()[:2]
log.error('%s: %s', exc_type.__name__, exc_value)
......@@ -188,7 +188,7 @@ class Asset(object):
try:
if fetch(urlobj, asset_file):
return asset_file
except:
except Exception:
exc_type, exc_value = sys.exc_info()[:2]
log.error('%s: %s', exc_type.__name__, exc_value)
......
......@@ -56,7 +56,7 @@ class FileLock(object):
os.close(fd)
self.locked = True
return self
except:
except Exception:
try:
# Read the file to realize what's happening.
with open(self.filename, 'r') as f:
......@@ -90,7 +90,7 @@ class FileLock(object):
except:
raise LockFailed('Not able to lock.')
except:
except Exception:
# If we cannot read the lock file, let's just
# go on. Maybe in next iteration (if we have time)
# we have a better luck.
......@@ -111,5 +111,5 @@ class FileLock(object):
try:
os.remove(self.filename)
self.locked = False
except:
except Exception:
pass
......@@ -44,7 +44,7 @@ class Mail(JobPre, JobPost):
smtp = smtplib.SMTP(self.server)
smtp.sendmail(self.sender, [self.rcpt], msg.as_string())
smtp.quit()
except:
except Exception:
LOG_UI.error("Failure to send email notification: "
"please check your mail configuration")
......
......@@ -17,7 +17,7 @@ class Env(Test):
def get_proc_content(rel_path):
try:
return genio.read_file(os.path.join(p_dir, rel_path)).strip()
except:
except OSError:
return "<NOT AVAILABLE>"
self.log.debug('Process ID: %s', pid)
......
......@@ -17,9 +17,12 @@
import sys
try:
import os
import time
import tempfile
import traceback
except:
from avocado.core import data_dir
except ImportError:
sys.stderr.write("Unable to import basic python libraries, please "
"reinstall avocado and dependencies.\n")
# This exit code is replicated from avocado/core/exit_codes.py and not
......@@ -27,6 +30,12 @@ except:
sys.exit(-1)
def get_crash_dir():
crash_dir_path = os.path.join(data_dir.get_data_dir(), "crashes")
os.makedirs(crash_dir_path)
return crash_dir_path
def handle_exception(*exc_info):
# Print traceback if AVOCADO_LOG_DEBUG environment variable is set
msg = "Avocado crashed:\n" + "".join(traceback.format_exception(*exc_info))
......@@ -34,18 +43,9 @@ def handle_exception(*exc_info):
if os.environ.get("AVOCADO_LOG_DEBUG"):
os.write(2, msg.encode('utf-8'))
# Store traceback in data_dir or TMPDIR
crash_dir = None
prefix = "avocado-traceback-"
try:
import time
prefix += time.strftime("%F_%T") + "-"
from avocado.core import data_dir # pylint: disable=E0611
_crash_dir = os.path.join(data_dir.get_data_dir(), "crashes")
os.makedirs(_crash_dir)
crash_dir = _crash_dir
except:
pass
tmp, name = tempfile.mkstemp(".log", prefix, crash_dir)
tmp, name = tempfile.mkstemp(".log", prefix, get_crash_dir())
os.write(tmp, msg.encode('utf-8'))
os.close(tmp)
# Print friendly message in console-like output
......
......@@ -169,7 +169,8 @@ results_dir_content() {
[ "$SKIP_RESULTSDIR_CHECK" ] || RESULTS_DIR_CONTENT="$(ls $RESULTS_DIR 2> /dev/null)"
LINT_CMD="inspekt lint --exclude=.git"
PYLINT_ENABLE="--enable R0401,W0101,W0102,W0104,W0105,W0106,W0107,W0108,W0109,W0111,W0120,W0122,W0123,W0124,W0125,W0150,W0199,W0211,W0222,W0223,W0232,W0233,W0301,W0311,W0312,W0401,W0404,W0406,W0410,W0601,W0602,W0603,W0604,W0611,W0612,W0613,W0614,W0621,W0622,W0623,W0631,W0640,W0705,W0711,W1201,W1202,W1300,W1301,W1302,W1303,W1304,W1305,W1306,W1307,W1401,W1402,W1501,W1503,W1645"
PYLINT_ENABLE="--enable R0401,W0101,W0102,W0104,W0105,W0106,W0107,W0108,W0109,W0111,W0120,W0122,W0123,W0124,W0125,W0150,W0199,W0211,W0222,W0223,W0232,W0233,W0301,W0311,W0312,W0401,W0404,W0406,W0410,W0601,W0602,W0603,W0604,W0611,W0612,W0613,W0614,W0621,W0622,W0623,W0631,W0640,W0702,W0705,W0711,W1201,W1202,W1300,W1301,W1302,W1303,W1304,W1305,W1306,W1307,W1401,W1402,W1501,W1503,W1645"
if [ "$AVOCADO_PARALLEL_LINT" ]; then
LINT_CMD="$LINT_CMD --parallel=$AVOCADO_PARALLEL_LINT"
fi
......
......@@ -29,7 +29,7 @@ def has_no_external_connectivity():
try:
urllib.urlopen('http://docs.python.org/objects.inv')
return False
except:
except Exception:
return True
......
......@@ -186,7 +186,7 @@ class FileLockTest(unittest.TestCase):
args = [(self.tmpdir, players, timeout)] * players
try:
pool.map(file_lock_action, args)
except:
except Exception:
msg = 'Failed to run FileLock with %s players:\n%s'
msg %= (players, prepare_exc_info(sys.exc_info()))
self.fail(msg)
......
......@@ -59,7 +59,7 @@ class PhoneHome(unittest.TestCase):
conn.request('POST', url)
try:
conn.getresponse()
except:
except Exception:
pass
finally:
conn.close()
......
......@@ -7,7 +7,7 @@ from xml.dom import minidom
try:
from io import BytesIO
except:
except ImportError:
from BytesIO import BytesIO
try:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册