Skip to content

Commit 97f9c20

Browse files
committed
Fix: #863
1 parent b7f7755 commit 97f9c20

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

Configs/.local/lib/hyde/weather.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,16 @@
6060

6161
### Functions ###
6262
def load_env_file(filepath):
63-
with open(filepath, encoding="utf-8") as f:
64-
for line in f:
65-
if line.strip() and not line.startswith("#"):
66-
if line.startswith("export "):
67-
line = line[len("export ") :]
68-
key, value = line.strip().split("=", 1)
69-
os.environ[key] = value.strip('"')
63+
try:
64+
with open(filepath, encoding="utf-8") as f:
65+
for line in f:
66+
if line.strip() and not line.startswith("#"):
67+
if line.startswith("export "):
68+
line = line[len("export ") :]
69+
key, value = line.strip().split("=", 1)
70+
os.environ[key] = value.strip('"')
71+
except Exception:
72+
pass # shhh
7073

7174

7275
def get_weather_icon(weatherinstance):
@@ -173,9 +176,10 @@ def format_chances(hour):
173176

174177

175178
### Variables ###
176-
# Load environment variables from the specified files
177-
load_env_file(os.path.expanduser("~/.local/state/hyde/staterc"))
178-
load_env_file(os.path.expanduser("~/.local/state/hyde/config"))
179+
load_env_file(
180+
os.path.join(os.environ.get("HOME"), ".rlocal", "state", "hyde", "staterc")
181+
)
182+
load_env_file(os.path.join(os.environ.get("HOME"), ".local", "state", "hyde", "config"))
179183

180184
temp_unit = os.getenv(
181185
"WEATHER_TEMPERATURE_UNIT", "c"

0 commit comments

Comments
 (0)