Skip to content
Snippets Groups Projects
Commit 35262aa3 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-917: raise more specific json decode error

parent 5f324d14
Branches
Tags
2 merge requests!634WIP: COBALT commissioning delta,!540TMSS-917: primary subtask
...@@ -45,11 +45,12 @@ def populate_schemas(schema_dir: str=None, templates_filename: str=None): ...@@ -45,11 +45,12 @@ def populate_schemas(schema_dir: str=None, templates_filename: str=None):
# load all templates and schemas and prepare them for upload. # load all templates and schemas and prepare them for upload.
# determine the dependencies, and upload the depenends first, and the rest in parallel later. # determine the dependencies, and upload the depenends first, and the rest in parallel later.
for template in templates: for template in templates:
with open(os.path.join(schema_dir, template['file_name'])) as schema_file:
content = schema_file.read()
try: try:
with open(os.path.join(schema_dir, template['file_name'])) as schema_file: json_schema = json.loads(content)
json_schema = json.loads(schema_file.read())
except Exception as e: except Exception as e:
raise Exception("Could not decode JSON schema %s" % template['file_name']) from e raise Exception("Could not decode JSON schema file: '%s'\n%s" % (template['file_name'], content)) from e
# add template name/description/version from schema if not already in template # add template name/description/version from schema if not already in template
template['name'] = template.get('name', json_schema.get('title', '<no name>')) template['name'] = template.get('name', json_schema.get('title', '<no name>'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment