From 03646d48f358369a149e88cbdd800c285afec5bf Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Mon, 27 Apr 2015 10:50:46 -0500 Subject: [PATCH] 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 --- scripts/pw-token-gen.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/pw-token-gen.py b/scripts/pw-token-gen.py index f5f70c09b0..5deee8e5af 100755 --- a/scripts/pw-token-gen.py +++ b/scripts/pw-token-gen.py @@ -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():