|
3 | 3 | from __future__ import print_function
|
4 | 4 | from __future__ import absolute_import
|
5 | 5 |
|
| 6 | +import os |
6 | 7 | from collections import namedtuple
|
7 | 8 | import json
|
8 | 9 | import xml.etree.ElementTree as ET
|
@@ -59,15 +60,21 @@ class StructuredData(object):
|
59 | 60 |
|
60 | 61 | def __init__(self, json_path):
|
61 | 62 | self.json_path = json_path
|
62 |
| - try: |
63 |
| - with open(json_path, "r") as output_json_f: |
64 |
| - structured_data = json.load(output_json_f) |
65 |
| - structured_data_tests = structured_data["tests"] |
66 |
| - except Exception: |
67 |
| - error("Warning: Targetting older Galaxy which did not " |
68 |
| - "produce a structured test results files.") |
69 |
| - structured_data = {} |
70 |
| - structured_data_tests = {} |
| 63 | + if not os.path.exists(json_path): |
| 64 | + error("Warning: Problem with target Galaxy, it did not " |
| 65 | + "produce a structured test results files - summary " |
| 66 | + "information and planemo reports will be incorrect." |
| 67 | + ) |
| 68 | + else: |
| 69 | + try: |
| 70 | + with open(json_path, "r") as output_json_f: |
| 71 | + structured_data = json.load(output_json_f) |
| 72 | + structured_data_tests = structured_data["tests"] |
| 73 | + except Exception: |
| 74 | + error("Galaxy produced invalid JSON for structured data - summary " |
| 75 | + "information and planemo reports will be incorrect.") |
| 76 | + structured_data = {} |
| 77 | + structured_data_tests = {} |
71 | 78 | self.structured_data = structured_data
|
72 | 79 | self.structured_data_tests = structured_data_tests
|
73 | 80 | structured_data_by_id = {}
|
|
0 commit comments