enkore / i3pystatus

A complete replacement for i3status
https://i3pystatus.readthedocs.io/
MIT License
445 stars 188 forks source link

WUnderground weather module returns 401 Unauthorized #857

Closed elig0n closed 8 months ago

elig0n commented 9 months ago
[ERROR   ][i3pystatus.weather.wunderground.Wunderground 46] Failed to make API request to https://api.weather.com/v2/pws/observations/current?apiKey=REDACTED&stationId=ICENTERD15&format=json&units=m
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/i3pystatus/weather/__init__.py", line 29, in api_request
    response_json = self.http_request(url, headers=headers).strip()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/i3pystatus/core/util.py", line 364, in wrapper
    return method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/i3pystatus/weather/__init__.py", line 17, in http_request
    with urlopen(req) as content:
         ^^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 525, in open
    response = meth(req, response)
               ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 634, in http_response
    response = self.parent.error(
               ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 563, in error
    return self._call_chain(*args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 496, in _call_chain
    result = func(*args)
             ^^^^^^^^^^^
  File "/usr/lib/python3.11/urllib/request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 401: Unauthorized

I was getting some of these for the last two days.

Here is my proposal around it: https://github.com/enkore/i3pystatus/pull/856