diff options
author | Lucian Musat <george.l.musat@intel.com> | 2015-09-29 17:47:42 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-10-01 17:54:45 +0100 |
commit | 3cfad28dfa9ef3d142f12d7d181ee70ee1559dc4 (patch) | |
tree | 68fce3aeac6d0b1a816af8b068c7c0ad7c5ea420 /meta/lib | |
parent | 5e124c2ad5d961cdab954ab054f9ae7718ab1b55 (diff) | |
download | openembedded-core-3cfad28dfa9ef3d142f12d7d181ee70ee1559dc4.tar.gz openembedded-core-3cfad28dfa9ef3d142f12d7d181ee70ee1559dc4.tar.bz2 openembedded-core-3cfad28dfa9ef3d142f12d7d181ee70ee1559dc4.zip |
oeqa/runexported: Replaced optionparser with argparse.
Also added the default json file name as default for
the first positional argument.
Signed-off-by: Lucian Musat <george.l.musat@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rwxr-xr-x | meta/lib/oeqa/runexported.py | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/meta/lib/oeqa/runexported.py b/meta/lib/oeqa/runexported.py index 0daedd057e..dba0d7aec1 100755 --- a/meta/lib/oeqa/runexported.py +++ b/meta/lib/oeqa/runexported.py @@ -21,7 +21,7 @@ import sys import os import time -from optparse import OptionParser +import argparse try: import simplejson as json @@ -76,40 +76,38 @@ class TestContext(object): def main(): - usage = "usage: %prog [options] <json file>" - parser = OptionParser(usage=usage) - parser.add_option("-t", "--target-ip", dest="ip", help="The IP address of the target machine. Use this to \ + parser = argparse.ArgumentParser() + parser.add_argument("-t", "--target-ip", dest="ip", help="The IP address of the target machine. Use this to \ overwrite the value determined from TEST_TARGET_IP at build time") - parser.add_option("-s", "--server-ip", dest="server_ip", help="The IP address of this machine. Use this to \ + parser.add_argument("-s", "--server-ip", dest="server_ip", help="The IP address of this machine. Use this to \ overwrite the value determined from TEST_SERVER_IP at build time.") - parser.add_option("-d", "--deploy-dir", dest="deploy_dir", help="Full path to the package feeds, that this \ + parser.add_argument("-d", "--deploy-dir", dest="deploy_dir", help="Full path to the package feeds, that this \ the contents of what used to be DEPLOY_DIR on the build machine. If not specified it will use the value \ specified in the json if that directory actually exists or it will error out.") - parser.add_option("-l", "--log-dir", dest="log_dir", help="This sets the path for TEST_LOG_DIR. If not specified \ + parser.add_argument("-l", "--log-dir", dest="log_dir", help="This sets the path for TEST_LOG_DIR. If not specified \ the current dir is used. This is used for usually creating a ssh log file and a scp test file.") + parser.add_argument("json", help="The json file exported by the build system", default="testdata.json", nargs='?') - (options, args) = parser.parse_args() - if len(args) != 1: - parser.error("Incorrect number of arguments. The one and only argument should be a json file exported by the build system") + args = parser.parse_args() - with open(args[0], "r") as f: + with open(args.json, "r") as f: loaded = json.load(f) - if options.ip: - loaded["target"]["ip"] = options.ip - if options.server_ip: - loaded["target"]["server_ip"] = options.server_ip + if args.ip: + loaded["target"]["ip"] = args.ip + if args.server_ip: + loaded["target"]["server_ip"] = args.server_ip d = MyDataDict() for key in loaded["d"].keys(): d[key] = loaded["d"][key] - if options.log_dir: - d["TEST_LOG_DIR"] = options.log_dir + if args.log_dir: + d["TEST_LOG_DIR"] = args.log_dir else: d["TEST_LOG_DIR"] = os.path.abspath(os.path.dirname(__file__)) - if options.deploy_dir: - d["DEPLOY_DIR"] = options.deploy_dir + if args.deploy_dir: + d["DEPLOY_DIR"] = args.deploy_dir else: if not os.path.isdir(d["DEPLOY_DIR"]): print("WARNING: The path to DEPLOY_DIR does not exist: %s" % d["DEPLOY_DIR"]) |