diff --git a/SAS/TMSS/client/lib/populate.py b/SAS/TMSS/client/lib/populate.py index 7f48b22029c8c43b5631eb91ee0130efa7a29414..fc42db6a202d397c6b05a3f8648bb6b7a516ee15 100644 --- a/SAS/TMSS/client/lib/populate.py +++ b/SAS/TMSS/client/lib/populate.py @@ -31,18 +31,18 @@ def populate_schemas(schema_dir: str=None, templates_filename: str=None): with open(templates_filepath) as templates_file: templates = json.loads(templates_file.read()) - for template in templates: - try: - with open(os.path.join(schema_dir, template.pop('file_name'))) as schema_file: - try: - json_schema = json.loads(schema_file.read()) + with TMSSsession.create_from_dbcreds_for_ldap() as client: + for template in templates: + try: + with open(os.path.join(schema_dir, template.pop('file_name'))) as schema_file: + try: + json_schema = json.loads(schema_file.read()) - template_path = template.pop('template') - name = template.pop('name', json_schema.get('title', '<no name>')) - description = template.pop('description', json_schema.get('description', '<no description>')) - version = template.pop('version', '1') + template_path = template.pop('template') + name = template.pop('name', json_schema.get('title', '<no name>')) + description = template.pop('description', json_schema.get('description', '<no description>')) + version = template.pop('version', '1') - with TMSSsession.create_from_dbcreds_for_ldap() as client: if template_path == 'subtask_template' and 'type' in template: # override plain-text type by its url template['type'] = client.get_path_as_json_object('subtask_type/'+template.pop('type'))['url'] @@ -66,8 +66,8 @@ def populate_schemas(schema_dir: str=None, templates_filename: str=None): description=description, version=version, **template) - except Exception as e: - logger.error(e) - except Exception as e: - logger.error(e) + except Exception as e: + logger.error(e) + except Exception as e: + logger.error(e) diff --git a/SAS/TMSS/src/tmss/tmssapp/populate.py b/SAS/TMSS/src/tmss/tmssapp/populate.py index 538afcae209e97d6036bfd7050f75d500814351b..8a7e9ecef7a27b3cbd96e1963cd543701aafeb78 100644 --- a/SAS/TMSS/src/tmss/tmssapp/populate.py +++ b/SAS/TMSS/src/tmss/tmssapp/populate.py @@ -58,7 +58,7 @@ def populate_test_data(): # create a Test Scheduling Set UC1 under project TMSS-Commissioning tmss_project = models.Project.objects.get(name="TMSS-Commissioning") - for set_nr in range(1): + for set_nr in range(2): scheduling_set_data = SchedulingSet_test_data(name="Test Scheduling Set UC1 example %s" % (set_nr,), project=tmss_project) scheduling_set = models.SchedulingSet.objects.create(**scheduling_set_data) scheduling_set.tags = ["TEST", "UC1"] @@ -66,7 +66,7 @@ def populate_test_data(): logger.info('created test scheduling_set: %s', scheduling_set.name) - for unit_nr in range(1): + for unit_nr in range(5): strategy_template = models.SchedulingUnitObservingStrategyTemplate.objects.get(name="UC1 CTC+pipelines")