Merge "Prefer to use yaml safe_load instead load"
This commit is contained in:
commit
6805c3f9f4
|
@ -69,7 +69,7 @@ from ansible.module_utils.basic import * # noqa
|
|||
|
||||
def _open_yaml(filename):
|
||||
with open(filename, "r") as stream:
|
||||
tmp_dict = yaml.load(stream)
|
||||
tmp_dict = yaml.safe_load(stream)
|
||||
return tmp_dict
|
||||
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ class BugVerifyCmd(object):
|
|||
known_failures = []
|
||||
try:
|
||||
with open(self.args.skip_file) as f:
|
||||
skip = yaml.load(f)
|
||||
skip = yaml.safe_load(f)
|
||||
for t in skip.get('known_failures'):
|
||||
bug = {'test': t.get('test'), 'reason': t.get('reason')}
|
||||
if t.get('lp'):
|
||||
|
@ -146,6 +146,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:
|
||||
|
|
|
@ -320,10 +320,12 @@ class TempestMailCmd(object):
|
|||
def load_skip_file(self, skipfile):
|
||||
known_failures = []
|
||||
try:
|
||||
skip = yaml.load(open(self.args.skip_file))
|
||||
skip = yaml.safe_load(open(self.args.skip_file))
|
||||
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:
|
||||
|
@ -355,7 +357,10 @@ class TempestMailCmd(object):
|
|||
|
||||
def setupConfig(self):
|
||||
self.log.debug("Loading configuration")
|
||||
config = yaml.load(open(self.args.config))
|
||||
try:
|
||||
config = yaml.safe_load(open(self.args.config))
|
||||
except yaml.constructor.ConstructorError:
|
||||
self.log.error('Invalid yaml file {}'.format(self.args.config))
|
||||
|
||||
newconfig = Config()
|
||||
known_failures = []
|
||||
|
|
Loading…
Reference in New Issue