Browse Source

Add debug to pnalib to find why something fails

Toni Fadjukoff 7 years ago
parent
commit
ac6d00fbdd
1 changed files with 10 additions and 2 deletions
  1. 10 2
      pnalib.py

+ 10 - 2
pnalib.py View File

4
 import json
4
 import json
5
 
5
 
6
 def get_jsonp_file(url, temp_fname, use_old, allow_old=True):
6
 def get_jsonp_file(url, temp_fname, use_old, allow_old=True):
7
-    return get_file(url, temp_fname, use_old, jsonp_load, allow_old)
7
+    try:
8
+        return get_file(url, temp_fname, use_old, jsonp_load, allow_old)
9
+    except json.decoder.JSONDecodeError as e:
10
+        print("Failed to parse JSON from {}".format(temp_fname))
11
+        raise
8
 
12
 
9
 def get_json_file(url, temp_fname, use_old, allow_old=True):
13
 def get_json_file(url, temp_fname, use_old, allow_old=True):
10
-    return get_file(url, temp_fname, use_old, json.load, allow_old)
14
+    try:
15
+        return get_file(url, temp_fname, use_old, json.load, allow_old)
16
+    except json.decoder.JSONDecodeError as e:
17
+        print("Failed to parse JSON from {}".format(temp_fname))
18
+        raise
11
 
19
 
12
 def jsonp_load(fp):
20
 def jsonp_load(fp):
13
     return json.loads(fp.read()[1:-2])
21
     return json.loads(fp.read()[1:-2])