Added check to see if the variable file is empty

The `pw-token-gen.py` script will fail if used against an empty file.
This change adds a None type check and returns an exit error and
messaage if the loaded value is None.

Closes-Bug: 1446338
Change-Id: I83cb9d1ef312f870f555c6de5f42815ba40e895e
This commit is contained in:
Kevin Carter 2015-04-27 10:50:46 -05:00
parent b6476c652a
commit 03646d48f3

View File

@ -157,6 +157,12 @@ def main():
with open(user_vars_file, 'rb') as f:
user_vars = yaml.safe_load(f.read())
if not user_vars:
raise SystemExit(
'FAIL: The variable file provided [ %s ] is empty.'
% user_vars_file
)
changed = False
generator = CredentialGenerator()
for entry, value in user_vars.iteritems():