Merge "updated hacking rules"

This commit is contained in:
Jenkins 2014-10-03 01:47:40 +00:00 committed by Gerrit Code Review
commit 513eeb80d7
5 changed files with 60 additions and 64 deletions

View File

@ -313,6 +313,9 @@ class HTMLViewer(object):
return empty_description, headers return empty_description, headers
try: try:
stats = Stats2(*log_files) stats = Stats2(*log_files)
except (IOError, ValueError):
raise DataLoadFailure(_('Can not load profile data from %s.')
% log_files)
if not fulldirs: if not fulldirs:
stats.strip_dirs() stats.strip_dirs()
stats.sort_stats(sort) stats.sort_stats(sort)
@ -359,9 +362,6 @@ class HTMLViewer(object):
'profilehtml': profile_html, 'profilehtml': profile_html,
}) })
return content, headers return content, headers
except:
raise DataLoadFailure(_('Can not load profile data from %s.')
% log_files)
def download(self, log_files, sort='time', limit=-1, nfl_filter='', def download(self, log_files, sort='time', limit=-1, nfl_filter='',
output_format='default'): output_format='default'):
@ -438,7 +438,7 @@ class HTMLViewer(object):
file_path = nfls[0] file_path = nfls[0]
try: try:
lineno = int(nfls[1]) lineno = int(nfls[1])
except: except (TypeError, ValueError, IndexError):
lineno = 0 lineno = 0
# for security reason, this need to be fixed. # for security reason, this need to be fixed.
if not file_path.endswith('.py'): if not file_path.endswith('.py'):

View File

@ -242,7 +242,6 @@ class ProfileMiddleware(object):
start_response('500 Internal Server Error', []) start_response('500 Internal Server Error', [])
return _('Error on render profiling results: %s') % ex return _('Error on render profiling results: %s') % ex
else: else:
try:
_locals = locals() _locals = locals()
code = self.unwind and PROFILE_EXEC_EAGER or\ code = self.unwind and PROFILE_EXEC_EAGER or\
PROFILE_EXEC_LAZY PROFILE_EXEC_LAZY
@ -250,10 +249,6 @@ class ProfileMiddleware(object):
app_iter = _locals['app_iter_'] app_iter = _locals['app_iter_']
self.dump_checkpoint() self.dump_checkpoint()
return app_iter return app_iter
except:
self.logger.exception(_('Error profiling code'))
finally:
pass
def renew_profile(self): def renew_profile(self):
self.profiler = get_profiler(self.profile_module) self.profiler = get_profiler(self.profile_module)

View File

@ -732,7 +732,7 @@ class ContainerReconciler(Daemon):
""" """
try: try:
self.reconcile() self.reconcile()
except: except: # noqa
self.logger.exception('Unhandled Exception trying to reconcile') self.logger.exception('Unhandled Exception trying to reconcile')
self.log_stats(force=True) self.log_stats(force=True)

View File

@ -99,7 +99,7 @@ class TestRecon(unittest.TestCase):
def tearDown(self, *_args, **_kwargs): def tearDown(self, *_args, **_kwargs):
try: try:
os.remove(self.tmpfile_name) os.remove(self.tmpfile_name)
except: except OSError:
pass pass
def test_gen_stats(self): def test_gen_stats(self):

View File

@ -58,10 +58,11 @@ commands = python setup.py build_sphinx
# it's not a bug that we aren't using all of hacking # it's not a bug that we aren't using all of hacking
# H102 -> apache2 license exists # H102 -> apache2 license exists
# H103 -> license is apache # H103 -> license is apache
# H201 -> no bare excepts # add when hacking supports noqa # H201 -> no bare excepts (unless marked with " # noqa")
# H231 -> Check for except statements to be Python 3.x compatible
# H501 -> don't use locals() for str formatting # H501 -> don't use locals() for str formatting
# H903 -> \n not \r\n # H903 -> \n not \r\n
ignore = H ignore = H
select = F,E,W,H102,H103,H501,H903,H231 select = F,E,W,H102,H103,H201,H231,H501,H903
exclude = .venv,.tox,dist,doc,*egg exclude = .venv,.tox,dist,doc,*egg
show-source = True show-source = True