diff --git a/api/jobs/rules.py b/api/jobs/rules.py index c23ff0f513e37c9606350d8173d81f75cf21a73e..5797c5a2fdadd233f24b2ddf93ede5cdfabc5059 100644 --- a/api/jobs/rules.py +++ b/api/jobs/rules.py @@ -79,7 +79,7 @@ def eval_match(match_type, match_param, file_, container): # Match the container having any file (including this one) with this type elif match_type == 'container.has-type': for c_file in container['files']: - if match_param == c_file['type']: + if match_param == c_file.get('type'): return True return False diff --git a/bin/database.py b/bin/database.py index ace9377ab68e8c4500aa8950102e1d0b98e3ae88..6e569683d1cbe68255f9781d051bdf163af644c7 100755 --- a/bin/database.py +++ b/bin/database.py @@ -494,7 +494,15 @@ def upgrade_to_18(): if gear_doc is not None: gear_list = gear_doc.get('gear_list', []) for gear in gear_list: - gears.upsert_gear(gear) + try: + gears.upsert_gear(gear) + except Exception as e: + logging.error("") + logging.error("Error upgrading gear:") + logging.error(type(e)) + logging.error("Gear will not be retained. Document follows:") + logging.error(gear) + logging.error("") config.db.singletons.remove({"_id": "gears"}) diff --git a/test/unit_tests/python/test_rules.py b/test/unit_tests/python/test_rules.py index d37a1497f9015bd458dbf53d89b1030a9b6024b6..f2d291d6de4c2f42ce3a34fc3a1506422201e831 100644 --- a/test/unit_tests/python/test_rules.py +++ b/test/unit_tests/python/test_rules.py @@ -95,8 +95,8 @@ def test_eval_match_container_measurement(): def test_eval_match_container_has_type(): part = rulePart(match_type='container.has-type', container={'files': [ - {'measurements': ['a', 'diffusion', 'b']}, - {'measurements': ['c', 'other', 'b']}, + {'type': 'diffusion'}, + {'type': 'other'}, ]}) args = part.gen(match_param='other')