mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 14:27:42 +00:00
flynt pass to provide consistency to string formatters and concatenation
This commit is contained in:
@@ -22,13 +22,13 @@ class FileDownloadStaticDataProvider(StaticDataProvider):
|
||||
self._poll_interval = poll_interval
|
||||
self._thread = None
|
||||
self._stop_event = Event()
|
||||
self._url_data_cache = URLDataCache("staticdata_" + name)
|
||||
self._url_data_cache = URLDataCache(f"staticdata_{name}")
|
||||
|
||||
def start(self):
|
||||
# Fire off the polling thread. It will poll immediately on startup, then sleep for poll_interval between
|
||||
# subsequent polls, so start() returns immediately and the application can continue starting.
|
||||
logging.info(
|
||||
"Set up query of " + self.name + " static reference data every " + str(self._poll_interval) + " days.")
|
||||
f"Set up query of {self.name} static reference data every {self._poll_interval!s} days.")
|
||||
self._thread = Thread(target=self._run, name=f"FileDownloadStaticDataProvider-{self.name}")
|
||||
self._thread.start()
|
||||
|
||||
@@ -45,7 +45,7 @@ class FileDownloadStaticDataProvider(StaticDataProvider):
|
||||
try:
|
||||
# Request data from API. Use the data cache (with a TTL of 1 day) here, not as the main mechanism for
|
||||
# caching, but just so continual restarts of the software during testing don't hammer the servers.
|
||||
logging.debug("Downloading " + self.name + " static reference data...")
|
||||
logging.debug(f"Downloading {self.name} static reference data...")
|
||||
http_response = self._url_data_cache.get(self._url, headers=HTTP_HEADERS)
|
||||
# Check response code was good
|
||||
if http_response.ok:
|
||||
@@ -54,7 +54,7 @@ class FileDownloadStaticDataProvider(StaticDataProvider):
|
||||
if ok:
|
||||
self.status = "OK"
|
||||
self.last_update_time = datetime.now(pytz.UTC)
|
||||
logging.info("Updated static reference data for " + self.name)
|
||||
logging.info(f"Updated static reference data for {self.name}")
|
||||
else:
|
||||
self.status = "Error"
|
||||
logging.warning(f"HTTP {http_response.status_code} when downloading static reference data for {self.name}.")
|
||||
@@ -67,7 +67,7 @@ class FileDownloadStaticDataProvider(StaticDataProvider):
|
||||
logging.warning(f"Timeout when downloading static reference data for {self.name}.")
|
||||
except Exception:
|
||||
self.status = "Error"
|
||||
logging.exception("Exception in HTTP static reference data provider (" + self.name + ")")
|
||||
logging.exception(f"Exception in HTTP static reference data provider ({self.name})")
|
||||
self._stop_event.wait(timeout=1)
|
||||
|
||||
def _handle_http_response(self, http_response):
|
||||
|
||||
@@ -15,19 +15,19 @@ class LocalFileStaticDataProvider(StaticDataProvider):
|
||||
self._stop = False
|
||||
|
||||
def start(self):
|
||||
logging.debug("Loading " + self.name + " static reference data from file.")
|
||||
logging.debug(f"Loading {self.name} static reference data from file.")
|
||||
try:
|
||||
ok = self._load_data(self._path)
|
||||
if ok:
|
||||
self.status = "OK"
|
||||
self.last_update_time = datetime.now(pytz.UTC)
|
||||
logging.info("Updated static reference data for " + self.name)
|
||||
logging.info(f"Updated static reference data for {self.name}")
|
||||
else:
|
||||
self.status = "Error"
|
||||
logging.error("Failed to load data for " + self.name)
|
||||
logging.error(f"Failed to load data for {self.name}")
|
||||
except Exception:
|
||||
self.status = "Error"
|
||||
logging.exception("Exception in local file Static Data Provider (" + self.name + ")")
|
||||
logging.exception(f"Exception in local file Static Data Provider ({self.name})")
|
||||
|
||||
def stop(self):
|
||||
self._stop = True
|
||||
|
||||
Reference in New Issue
Block a user