mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-08-05 18:11:41 +00:00
Fix issue where, if a shutdown request was sent while parsing static reference data, the program would continue parsing. #118
This commit is contained in:
@@ -27,4 +27,9 @@ class ARLHS(FileDownloadSIGRefDataProvider):
|
||||
"Longitude"] != "" else None,
|
||||
grid=row["Maidenhead Locator"]))
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest of
|
||||
# the data in this case
|
||||
if self._stop_event.is_set():
|
||||
break
|
||||
|
||||
return new_data
|
||||
|
||||
@@ -32,4 +32,10 @@ class DME(LocalFileSIGRefDataProvider):
|
||||
if latitude and longitude:
|
||||
ref.grid = latlong_to_locator(latitude, longitude, 6)
|
||||
new_data.append(ref)
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest
|
||||
# of the data in this case
|
||||
if self._stop:
|
||||
break
|
||||
|
||||
return new_data
|
||||
|
||||
@@ -26,4 +26,9 @@ class GMA(FileDownloadSIGRefDataProvider):
|
||||
"Longitude"] != "" else None,
|
||||
grid=row["Maidenhead Locator"]))
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest of
|
||||
# the data in this case
|
||||
if self._stop_event.is_set():
|
||||
break
|
||||
|
||||
return new_data
|
||||
|
||||
@@ -27,4 +27,9 @@ class ILLW(FileDownloadSIGRefDataProvider):
|
||||
"Longitude"] != "" else None,
|
||||
grid=row["Maidenhead Locator"]))
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest of
|
||||
# the data in this case
|
||||
if self._stop_event.is_set():
|
||||
break
|
||||
|
||||
return new_data
|
||||
|
||||
@@ -33,4 +33,9 @@ class IOTA(FileDownloadSIGRefDataProvider):
|
||||
new_data.append(SIGRef(sig=self.SIG, id=ref_id, name=ref["name"],
|
||||
grid=grid, latitude=latitude, longitude=longitude))
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest
|
||||
# of the data in this case
|
||||
if self._stop_event.is_set():
|
||||
break
|
||||
|
||||
return new_data
|
||||
|
||||
@@ -29,4 +29,9 @@ class LLOTA(FileDownloadSIGRefDataProvider):
|
||||
latitude=ll[0],
|
||||
longitude=ll[1]))
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest
|
||||
# of the data in this case
|
||||
if self._stop_event.is_set():
|
||||
break
|
||||
|
||||
return new_data
|
||||
|
||||
@@ -12,6 +12,7 @@ class LocalFileSIGRefDataProvider(SIGRefDataProvider):
|
||||
def __init__(self, sig, provider_config, path):
|
||||
super().__init__(sig, provider_config)
|
||||
self._path = path
|
||||
self._stop = False
|
||||
|
||||
def start(self):
|
||||
logging.debug("Loading " + self.sig_name + " SIG ref data from file.")
|
||||
@@ -29,7 +30,7 @@ class LocalFileSIGRefDataProvider(SIGRefDataProvider):
|
||||
logging.error("Exception in local file SIG Ref Data Provider (" + self.sig_name + ")", e, exc_info=True)
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
self._stop = True
|
||||
|
||||
def _file_to_data(self, path):
|
||||
"""Load a file on the given path and turn it into SIG Ref data."""
|
||||
|
||||
@@ -26,4 +26,9 @@ class MOTA(FileDownloadSIGRefDataProvider):
|
||||
"Longitude"] != "" else None,
|
||||
grid=row["Maidenhead Locator"]))
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest of
|
||||
# the data in this case
|
||||
if self._stop_event.is_set():
|
||||
break
|
||||
|
||||
return new_data
|
||||
|
||||
@@ -26,4 +26,9 @@ class POTA(FileDownloadSIGRefDataProvider):
|
||||
longitude=float(row["longitude"]) if "longitude" in row and row[
|
||||
"longitude"] != "" else None))
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest of
|
||||
# the data in this case
|
||||
if self._stop_event.is_set():
|
||||
break
|
||||
|
||||
return new_data
|
||||
|
||||
@@ -23,4 +23,9 @@ class SIOTA(FileDownloadSIGRefDataProvider):
|
||||
latitude=float(row["LAT"]) if "LAT" in row else None,
|
||||
longitude=float(row["LNG"]) if "LNG" in row else None))
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest of
|
||||
# the data in this case
|
||||
if self._stop_event.is_set():
|
||||
break
|
||||
|
||||
return new_data
|
||||
|
||||
@@ -31,4 +31,9 @@ class SOTA(FileDownloadSIGRefDataProvider):
|
||||
ref.grid = latlong_to_locator(latitude, longitude, 6)
|
||||
new_data.append(ref)
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest of
|
||||
# the data in this case
|
||||
if self._stop_event.is_set():
|
||||
break
|
||||
|
||||
return new_data
|
||||
|
||||
@@ -15,10 +15,16 @@ class Toilets(LocalFileSIGRefDataProvider):
|
||||
|
||||
def _file_to_data(self, path):
|
||||
new_data = []
|
||||
f = open(path)
|
||||
csv_data = f.read()
|
||||
dr = csv.DictReader(csv_data.splitlines())
|
||||
for row in dr:
|
||||
new_data.append(SIGRef(sig=self.SIG, id=row["ref"], name=row["ref"], latitude=float(row["lat"]),
|
||||
longitude=float(row["lon"])))
|
||||
with open(path) as _f:
|
||||
csv_data = _f.read()
|
||||
dr = csv.DictReader(csv_data.splitlines())
|
||||
for row in dr:
|
||||
new_data.append(SIGRef(sig=self.SIG, id=row["ref"], name=row["ref"], latitude=float(row["lat"]),
|
||||
longitude=float(row["lon"])))
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest
|
||||
# of the data in this case
|
||||
if self._stop:
|
||||
break
|
||||
|
||||
return new_data
|
||||
|
||||
@@ -24,4 +24,9 @@ class Towers(FileDownloadSIGRefDataProvider):
|
||||
latitude=float(row["Lat"]) if "Lat" in row and row["Lat"] != "" else None,
|
||||
longitude=float(row["Lon"]) if "Lon" in row and row["Lon"] != "" else None))
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest of
|
||||
# the data in this case
|
||||
if self._stop_event.is_set():
|
||||
break
|
||||
|
||||
return new_data
|
||||
|
||||
@@ -41,4 +41,9 @@ class WCA(FileDownloadSIGRefDataProvider):
|
||||
longitude=longitude,
|
||||
grid=grid))
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest of
|
||||
# the data in this case
|
||||
if self._stop_event.is_set():
|
||||
break
|
||||
|
||||
return new_data
|
||||
|
||||
@@ -28,4 +28,9 @@ class WOTA(FileDownloadSIGRefDataProvider):
|
||||
latitude=feature["geometry"]["coordinates"][1],
|
||||
longitude=feature["geometry"]["coordinates"][0]))
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest of
|
||||
# the data in this case
|
||||
if self._stop_event.is_set():
|
||||
break
|
||||
|
||||
return new_data
|
||||
|
||||
@@ -24,4 +24,9 @@ class WWBOTA(FileDownloadSIGRefDataProvider):
|
||||
latitude=float(row["Lat"]) if "Lat" in row and row["Lat"] != "" else None,
|
||||
longitude=float(row["Long"]) if "Long" in row and row["Long"] != "" else None))
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest of
|
||||
# the data in this case
|
||||
if self._stop_event.is_set():
|
||||
break
|
||||
|
||||
return new_data
|
||||
|
||||
@@ -27,4 +27,9 @@ class WWFF(FileDownloadSIGRefDataProvider):
|
||||
longitude=float(row["longitude"]) if "longitude" in row and row[
|
||||
"longitude"] != "" and row["longitude"] != "-" else None))
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest of
|
||||
# the data in this case
|
||||
if self._stop_event.is_set():
|
||||
break
|
||||
|
||||
return new_data
|
||||
|
||||
@@ -31,4 +31,9 @@ class ZLOTA(FileDownloadSIGRefDataProvider):
|
||||
ref.grid = latlong_to_locator(latitude, longitude, 6)
|
||||
new_data.append(ref)
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest
|
||||
# of the data in this case
|
||||
if self._stop_event.is_set():
|
||||
break
|
||||
|
||||
return new_data
|
||||
|
||||
@@ -22,6 +22,12 @@ class CQZoneData(LocalFileStaticDataProvider):
|
||||
cq_zone_data = geopandas.GeoDataFrame.from_features(json.load(f)["features"])
|
||||
for idx in cq_zone_data.index:
|
||||
prepare(cq_zone_data.at[idx, 'geometry'])
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to prepare the rest
|
||||
# of the data in this case
|
||||
if self.stop:
|
||||
break
|
||||
|
||||
DATA_STORE.cq_zone_data = cq_zone_data
|
||||
return True
|
||||
|
||||
|
||||
@@ -22,6 +22,12 @@ class ITUZoneData(LocalFileStaticDataProvider):
|
||||
itu_zone_data = geopandas.GeoDataFrame.from_features(json.load(f)["features"])
|
||||
for idx in itu_zone_data.index:
|
||||
prepare(itu_zone_data.at[idx, 'geometry'])
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to prepare the rest
|
||||
# of the data in this case
|
||||
if self.stop:
|
||||
break
|
||||
|
||||
DATA_STORE.itu_zone_data = itu_zone_data
|
||||
return True
|
||||
|
||||
|
||||
@@ -23,10 +23,18 @@ class K0SWE(FileDownloadStaticDataProvider):
|
||||
for dxcc in dxcc_list:
|
||||
dxcc_map[dxcc["entityCode"]] = dxcc
|
||||
|
||||
# Bail out if a stop has been requested, i.e. the program is shutting down - no need to parse the rest
|
||||
# of the data in this case
|
||||
if self._stop_event.is_set():
|
||||
break
|
||||
|
||||
# Add to data store
|
||||
for k, v in dxcc_map.items():
|
||||
DATA_STORE.dxcc_data[k] = v
|
||||
|
||||
if self._stop_event.is_set():
|
||||
break
|
||||
|
||||
# Regenerate in-memory regex-to-DXCC-entity-code map.
|
||||
DATA_STORE.regenerateCallRegexToDXCCEntityMap()
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ class LocalFileStaticDataProvider(StaticDataProvider):
|
||||
def __init__(self, name, provider_config, path):
|
||||
super().__init__(name, provider_config)
|
||||
self._path = path
|
||||
self._stop = False
|
||||
|
||||
def start(self):
|
||||
logging.debug("Loading " + self.name + " static reference data from file.")
|
||||
@@ -29,7 +30,7 @@ class LocalFileStaticDataProvider(StaticDataProvider):
|
||||
logging.error("Exception in local file Static Data Provider (" + self.name + ")", e, exc_info=True)
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
self._stop = True
|
||||
|
||||
def _load_data(self, path):
|
||||
"""Load data from the given file path. Return true if successful, false otherwise."""
|
||||
|
||||
Reference in New Issue
Block a user