aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rwxr-xr-xautoplanner.py4
-rw-r--r--shared.py7
-rwxr-xr-xstoringen.py4
4 files changed, 10 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index 0a17bdf..32e1c0f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@ autoplanner.json
venv/
__pycache__/
*-api-response.json
+debug
diff --git a/autoplanner.py b/autoplanner.py
index fe3e728..6af5c6d 100755
--- a/autoplanner.py
+++ b/autoplanner.py
@@ -52,9 +52,7 @@ def get_trip(date):
response = conn.getresponse()
data = response.read()
conn.close()
- f = open("./autoplanner-api-response.json", "w+")
- f.write(str(data, "utf-8"))
- f.close()
+ debug_output("autoplanner", data)
return data
def leg2desc(leg):
diff --git a/shared.py b/shared.py
index 72db189..0eeee53 100644
--- a/shared.py
+++ b/shared.py
@@ -1,6 +1,7 @@
#!/bin/python3
import urllib.request
import re
+import os
from uuid import uuid4
from bs4 import BeautifulSoup
@@ -15,3 +16,9 @@ def read_file(filename):
r = str(f.read())
f.close()
return r
+
+def debug_output(name, data):
+ if not os.path.exists("./debug"): return
+ f = open(f"./{name}-api-response.json", "w+")
+ f.write(str(data, "utf-8"))
+ f.close()
diff --git a/storingen.py b/storingen.py
index 5eb9af7..2a93936 100755
--- a/storingen.py
+++ b/storingen.py
@@ -19,9 +19,7 @@ def get_disruptions():
response = conn.getresponse()
data = response.read()
conn.close()
- f = open("./storingen-api-response.json", "w+")
- f.write(str(data, "utf-8"))
- f.close()
+ debug_output("storingen", data)
return data
def disruption2ical(disruption):