Commits

A S committed dec2e4b

Run update script if data json files are missing (ep.io)

Comments (0)

Files changed (1)

 import config
 from flask import json
 
-# load data
-with open(config.DATA_DIR + '/downloads.json') as f:
-    downloads_json = f.read()
-    downloads = json.loads(downloads_json)
+# load downloads data
+try:
+    with open('%s/downloads.json' % (config.DATA_DIR)) as f:
+        downloads_json = f.read()
+        downloads = json.loads(downloads_json)
+except IOError:
+    import update
 
-with open(config.DATA_DIR + '/compatibility.json') as f:
-    compatibility_json = f.read()
-    compatibility = json.loads(compatibility_json)
+# load downloads data
+try:
+    with open('%s/compatibility.json' % (config.DATA_DIR)) as f:
+        compatibility_json = f.read()
+        compatibility = json.loads(compatibility_json)
+except IOError:
+    import update