-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsource_helper.py
More file actions
30 lines (27 loc) · 1.06 KB
/
source_helper.py
File metadata and controls
30 lines (27 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
source = "txt/source.txt"
try:
with open(source, "r") as RSS:
RSS_URL = RSS.read()
except FileNotFoundError:
print(f"[WARN] {source} not found!")
print("You need a file called source.txt with a URL pointing towards an XML file so the software knows")
print("where to get the information from!!")
input("Press Enter to continue...")
coord_source = "txt/coord_source.txt"
try:
with open(coord_source, "r") as f:
line = f.read().strip()
if not line:
raise ValueError("Coordinate file is empty")
lat_str, lon_str = line.split(",")
coordinates = (float(lat_str), float(lon_str)) # tuple of floats
except FileNotFoundError:
print(f"[WARN] {coord_source} not found!")
print("You need a file called coord_source.txt with coords in it so the radar has a location")
input("Press Enter to continue...")
coordinates = None
except ValueError as e:
print(f"[WARN] {coord_source} is invalid: {e}")
input("Press Enter to continue...")
coordinates = None
print("Coordinates:", coordinates)