Skip to content

Commit fdce74c

Browse files
committed
Improved error messages when stuff goes bad with planemo test.
1 parent 99ee51a commit fdce74c

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

planemo/galaxy_test/structures.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import print_function
44
from __future__ import absolute_import
55

6+
import os
67
from collections import namedtuple
78
import json
89
import xml.etree.ElementTree as ET
@@ -59,15 +60,21 @@ class StructuredData(object):
5960

6061
def __init__(self, json_path):
6162
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 = {}
7178
self.structured_data = structured_data
7279
self.structured_data_tests = structured_data_tests
7380
structured_data_by_id = {}

0 commit comments

Comments
 (0)