aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xallium/allium.py3
-rw-r--r--allium/lib/relays.py11
2 files changed, 13 insertions, 1 deletions
diff --git a/allium/allium.py b/allium/allium.py
index a17002e..a3d6af8 100755
--- a/allium/allium.py
+++ b/allium/allium.py
@@ -40,6 +40,9 @@ if __name__ == '__main__':
# object containing onionoo data and processing routines
RELAY_SET = Relays(args.output_dir, args.onionoo_url)
+ if RELAY_SET.json == None:
+ sys.exit(0)
+
RELAY_SET.create_output_dir()
# index and "all" HTML relay sets; index set limited to 500 relays
diff --git a/allium/lib/relays.py b/allium/lib/relays.py
index 70ada47..378e8dc 100644
--- a/allium/lib/relays.py
+++ b/allium/lib/relays.py
@@ -27,6 +27,8 @@ class Relays():
self.onionoo_url = onionoo_url
self.ts_file = os.path.join(os.path.dirname(ABS_PATH), "timestamp")
self.json = self._fetch_onionoo_details()
+ if self.json == None:
+ return
self.timestamp = self._write_timestamp()
self._fix_missing_observed_bandwidth()
@@ -48,7 +50,14 @@ class Relays():
else:
conn = urllib.request.Request(self.onionoo_url)
- api_response = urllib.request.urlopen(conn).read()
+ try:
+ api_response = urllib.request.urlopen(conn).read()
+ except urllib.error.HTTPError as err:
+ if err.code == 304:
+ print("no onionoo update since last run, dying peacefully...")
+ return
+ else:
+ raise(err)
return json.loads(api_response.decode('utf-8'))