diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rwxr-xr-x | autoplanner.py | 4 | ||||
-rw-r--r-- | shared.py | 7 | ||||
-rwxr-xr-x | storingen.py | 4 |
4 files changed, 10 insertions, 6 deletions
@@ -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): @@ -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): |