From bc784989f69a6ecc5230e4e8ae956417a4c480d2 Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Mon, 24 Aug 2020 19:45:59 +0200 Subject: [PATCH] Make P1 imports not fail if called needlessly. If their respective configuration keys are not defined in a survey configuration, the import routines will print an informational message and exit successfully. --- bin/import_final_p111.py | 7 ++++++- bin/import_final_p190.py | 7 ++++++- bin/import_raw_p111.py | 7 ++++++- bin/import_raw_p190.py | 7 ++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/bin/import_final_p111.py b/bin/import_final_p111.py index c48b1eb..7df8254 100755 --- a/bin/import_final_p111.py +++ b/bin/import_final_p111.py @@ -30,7 +30,12 @@ if __name__ == '__main__': db.set_survey(survey["schema"]) - final_p111 = survey["final"]["p111"] + try: + final_p111 = survey["final"]["p111"] + except KeyError: + print("No final P1/11 configuration") + exit(0) + pattern = final_p111["pattern"] rx = re.compile(pattern["regex"]) diff --git a/bin/import_final_p190.py b/bin/import_final_p190.py index c3d0d7b..a75fb5a 100755 --- a/bin/import_final_p190.py +++ b/bin/import_final_p190.py @@ -30,7 +30,12 @@ if __name__ == '__main__': db.set_survey(survey["schema"]) - final_p190 = survey["final"]["p190"] + try: + final_p190 = survey["final"]["p190"] + except KeyError: + print("No final P1/90 configuration") + exit(0) + pattern = final_p190["pattern"] rx = re.compile(pattern["regex"]) diff --git a/bin/import_raw_p111.py b/bin/import_raw_p111.py index 9e8d423..0e8358f 100755 --- a/bin/import_raw_p111.py +++ b/bin/import_raw_p111.py @@ -30,7 +30,12 @@ if __name__ == '__main__': db.set_survey(survey["schema"]) - raw_p111 = survey["raw"]["p111"] + try: + raw_p111 = survey["raw"]["p111"] + except KeyError: + print("No raw P1/11 configuration") + exit(0) + pattern = raw_p111["pattern"] rx = re.compile(pattern["regex"]) diff --git a/bin/import_raw_p190.py b/bin/import_raw_p190.py index e51d562..1c4d737 100755 --- a/bin/import_raw_p190.py +++ b/bin/import_raw_p190.py @@ -30,7 +30,12 @@ if __name__ == '__main__': db.set_survey(survey["schema"]) - raw_p190 = survey["raw"]["p190"] + try: + raw_p190 = survey["raw"]["p190"] + except KeyError: + print("No raw P1/90 configuration") + exit(0) + pattern = raw_p190["pattern"] rx = re.compile(pattern["regex"])