From 44bbc2948bba7ff68382229facf5dd7070ce41da Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Thu, 17 Sep 2020 14:00:49 -0400 Subject: [PATCH] Parse options working in ODM 2.0 --- helpers/odmOptionsToJson.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/helpers/odmOptionsToJson.py b/helpers/odmOptionsToJson.py index ce292c9..e20b722 100644 --- a/helpers/odmOptionsToJson.py +++ b/helpers/odmOptionsToJson.py @@ -27,6 +27,10 @@ dest_file = os.environ.get("ODM_OPTIONS_TMP_FILE") sys.path.append(sys.argv[2]) +try: + imp.load_source('opendm', sys.argv[2] + '/opendm/__init__.py') +except: + pass try: imp.load_source('context', sys.argv[2] + '/opendm/context.py') except: @@ -44,11 +48,16 @@ class ArgumentParserStub(argparse.ArgumentParser): def add_mutually_exclusive_group(self): return ArgumentParserStub() -odm.parser = ArgumentParserStub() -odm.config() +if not hasattr(odm, 'parser'): + # ODM >= 2.0 + odm.config(parser=ArgumentParserStub()) +else: + # ODM 1.0 + odm.parser = ArgumentParserStub() + odm.config() + out = json.dumps(options) print(out) if dest_file is not None: with open(dest_file, "w") as f: f.write(out) -