Handle more unreachable states
This commit is contained in:
parent
8b5e6c2a7c
commit
89067be592
@ -2,6 +2,7 @@ from datetime import datetime, timedelta, timezone
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
import urllib.error
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
import re
|
||||
@ -47,6 +48,8 @@ class SNCFAPI:
|
||||
fd.write(f.read())
|
||||
except ConnectionResetError:
|
||||
pass
|
||||
except urllib.error.URLError:
|
||||
pass
|
||||
|
||||
# Retrieve cached data
|
||||
res = {}
|
||||
@ -73,6 +76,8 @@ class SNCFAPI:
|
||||
fd.write(f.read())
|
||||
except ConnectionResetError:
|
||||
pass
|
||||
except urllib.error.URLError:
|
||||
pass
|
||||
|
||||
# Retrieve cached data
|
||||
res = {}
|
||||
|
@ -1,6 +1,7 @@
|
||||
from datetime import datetime, timedelta, timezone
|
||||
import json
|
||||
import os
|
||||
import urllib.error
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
@ -28,9 +29,15 @@ class DarkSkyAPI:
|
||||
|
||||
if statinfo is None or datetime.fromtimestamp(statinfo.st_mtime, tz=timezone.utc) + timedelta(hours=1) < datetime.now(tz=timezone.utc):
|
||||
# Do the request and save it
|
||||
with urllib.request.urlopen(self.baseurl + "/" + str(self.apikey) + "/" + gps + "?" + "&".join([opt+"="+self.opts[opt] for opt in self.opts])) as f:
|
||||
with open(self._cached_file % gps, 'wb') as fd:
|
||||
fd.write(f.read())
|
||||
try:
|
||||
with urllib.request.urlopen(self.baseurl + "/" + str(self.apikey) + "/" + gps + "?" + "&".join([opt+"="+self.opts[opt] for opt in self.opts])) as f:
|
||||
with open(self._cached_file % gps, 'wb') as fd:
|
||||
fd.write(f.read())
|
||||
except ConnectionResetError:
|
||||
pass
|
||||
except urllib.error.URLError:
|
||||
pass
|
||||
|
||||
|
||||
# Retrieve cached data
|
||||
res = {}
|
||||
|
Loading…
Reference in New Issue
Block a user