[Core] Improve the try part.

Improve the readability of the block try. It's more easy to maintain the
block when this contain only the line can be raise.

Change-Id: I5024aecec41955b7cd5e0fe48ea4c6a0a7d6e293
This commit is contained in:
Natal Ngétal 2018-11-16 16:42:22 +01:00
parent 314fe55026
commit 235b73aea9
2 changed files with 14 additions and 14 deletions

View File

@ -139,6 +139,11 @@ class BugVerifyCmd(object):
try:
with open(self.args.skip_file) as f:
skip = yaml.safe_load(f)
except yaml.constructor.ConstructorError:
LOG.error('Invalid yaml file {}'.format(self.args.skip_file))
except IOError:
LOG.error('File not found {}'.format(self.args.skip_file))
else:
for t in skip.get('known_failures'):
bug = {'test': t.get('test'), 'reason': t.get('reason')}
if t.get('lp'):
@ -146,12 +151,8 @@ class BugVerifyCmd(object):
if t.get('bz'):
bug['bz'] = t.get('bz')
known_failures.append(bug)
except yaml.constructor.ConstructorError:
LOG.error('Invalid yaml file {}'.format(self.args.skip_file))
except IOError:
LOG.error('File not found {}'.format(self.args.skip_file))
finally:
return known_failures
return known_failures
def _print_yaml(self, known_failures):
return yaml.dump({'known_failures': known_failures},

View File

@ -318,15 +318,14 @@ class TempestMailCmd(object):
known_failures = []
try:
skip = yaml.safe_load(open(self.args.skip_file))
except yaml.constructor.ConstructorError:
self.log.error('Invalid yaml file {}'.format(self.args.skip_file))
else:
for t in skip.get('known_failures'):
known_failures.append({'test': t.get('test'),
'reason': t.get('reason')})
except yaml.constructor.ConstructorError:
self.log.error('Invalid yaml file {}'.format(self.args.skip_file))
except Exception:
pass
finally:
return known_failures
return known_failures
def checkJobs(self):
data = []
@ -388,8 +387,8 @@ class TempestMailCmd(object):
'reason': t.get('reason')})
if self.args.skip_file:
known_failures = \
(known_failures + self.load_skip_file(self.args.skip_file))
known_failures = (
known_failures + self.load_skip_file(self.args.skip_file))
newconfig.known_failures = known_failures
newconfig.api_server = config.get('api_server')