Log exceptions
This commit is contained in:
parent
9d625c87ee
commit
287c4ac349
@ -2,6 +2,7 @@ from collections.abc import Iterable
|
||||
from datetime import date, datetime, timedelta, timezone
|
||||
from functools import reduce
|
||||
import hashlib
|
||||
import logging
|
||||
import re
|
||||
import time
|
||||
import urllib.error
|
||||
@ -47,11 +48,9 @@ class IcalModule:
|
||||
with open(cache_file, 'wb') as fd:
|
||||
fd.write(c.read())
|
||||
except ConnectionResetError as e:
|
||||
print(e)
|
||||
pass
|
||||
logging.exception(e)
|
||||
except urllib.error.URLError as e:
|
||||
print(e)
|
||||
pass
|
||||
logging.exception(e)
|
||||
|
||||
with open(cache_file) as c:
|
||||
ecal = Calendar.from_ical(c.read())
|
||||
|
@ -1,6 +1,7 @@
|
||||
from datetime import datetime, timedelta, timezone
|
||||
import hashlib
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
@ -97,12 +98,12 @@ class IDFMAPI:
|
||||
with urllib.request.urlopen(req) as f:
|
||||
with open(cache_file, 'wb') as fd:
|
||||
fd.write(f.read())
|
||||
except ConnectionResetError:
|
||||
pass
|
||||
except urllib.error.URLError:
|
||||
pass
|
||||
except urllib.error.HTTPError:
|
||||
pass
|
||||
except ConnectionResetError as e:
|
||||
logging.exception(e)
|
||||
except urllib.error.URLError as e:
|
||||
logging.exception(e)
|
||||
except urllib.error.HTTPError as e:
|
||||
logging.exception(e)
|
||||
|
||||
with open(cache_file) as f:
|
||||
res = json.load(f)
|
||||
|
@ -65,7 +65,9 @@ class SNCFAPI:
|
||||
pass
|
||||
|
||||
if statinfo is None or datetime.fromtimestamp(statinfo.st_mtime, tz=timezone.utc) + timedelta(minutes=self.max_cache_timeout) < datetime.now(tz=timezone.utc):
|
||||
raise Exception("File too old")
|
||||
print(self.baseurl + "/1.0/infoVoy/rechercherListeCirculations?numero=%d&dateCirculation=%s&codeZoneArret&typeHoraire=TEMPS_REEL" % (int(numero), date.strftime("%Y-%m-%d")))
|
||||
logging.exception(Exception("File too old to predict SNCF issue"))
|
||||
return None
|
||||
|
||||
# Retrieve cached data
|
||||
res = {}
|
||||
@ -101,13 +103,10 @@ class SNCFAPI:
|
||||
fd.write(f.read())
|
||||
except ConnectionResetError as e:
|
||||
logging.exception(e)
|
||||
pass
|
||||
except urllib.error.URLError as e:
|
||||
logging.exception(e)
|
||||
pass
|
||||
except TimeoutError as e:
|
||||
logging.exception(e)
|
||||
pass
|
||||
|
||||
try:
|
||||
statinfo = os.stat(cache_file)
|
||||
|
Loading…
x
Reference in New Issue
Block a user