[yocto] [qa-tools][PATCH 3/3] testopia_update: Fix options verification for config and params
jose.perez.carranza at linux.intel.com
jose.perez.carranza at linux.intel.com
Wed Feb 22 09:12:42 PST 2017
From: Jose Perez Carranza <jose.perez.carranza at linux.intel.com>
A function was created to handle the load of options separately for
configuration and parameters
Signed-off-by: Anibal Limon <anibal.limon at linux.intel.com>
Signed-off-by: Jose Perez Carranza <jose.perez.carranza at linux.intel.com>
---
testopia_update.py | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/testopia_update.py b/testopia_update.py
index 1c2db63..9b35188 100755
--- a/testopia_update.py
+++ b/testopia_update.py
@@ -17,6 +17,17 @@ ACTIONS = ('create', 'update')
BRANCHES = ('master', 'jethro', 'dizzy', 'daisy', 'noexists')
CATEGORIES = ('AUTO', 'MANUAL')
+def load_opts(args, opts_list, opts):
+ for to in opts_list:
+ if to in vars(args):
+ arg = getattr(args, to)
+ if arg:
+ setattr(opts, to, arg)
+ if not hasattr(opts, to):
+ logger.error("%s: Requires testopia %s in arguments or config." % \
+ (sys.argv[0], to))
+ sys.exit(1)
+
class Options(object):
pass
@@ -85,7 +96,7 @@ if __name__ == '__main__':
logger = logging.getLogger()
testopia_config = ['url', 'username', 'password', 'store_location']
- testopia_opts = testopia_config + ['action', 'product_name', 'category_name',
+ testopia_opts = ['action', 'product_name', 'category_name',
'project_version', 'project_milestone', 'project_revision',
'project_date']
@@ -99,15 +110,7 @@ if __name__ == '__main__':
for to in testopia_config:
setattr(opts, to, config.get("Testopia", to))
- for to in testopia_opts:
- if to in vars(args):
- arg = getattr(args, to)
- if arg:
- setattr(opts, to, arg)
- if not hasattr(opts, to):
- logger.error("%s: Requires testopia %s in arguments or config." % \
- (sys.argv[0], to))
- sys.exit(1)
+ load_opts(args, testopia_config, opts)
if not os.path.exists(opts.store_location):
os.makedirs(opts.store_location)
@@ -121,6 +124,8 @@ if __name__ == '__main__':
print("%s\n" % p.name)
sys.exit(0)
+ load_opts(args, testopia_opts, opts)
+
params = ['action', 'product_name', 'branch_name', 'env_name']
for p in params:
if not getattr(args, p):
--
2.1.4
More information about the yocto
mailing list