Crash when overriding normal METAR fetch
Closed this issue · 2 comments
nicelion commented
When attempting to manually update a station's METAR, as can be seen in the example from the documentation site, a crash occurs.
>>> from avwx import Metar
>>> ksfo = Metar('KSFO')
>>> report = 'KSFO 031254Z 36024G55KT 320V040 1/8SM R06/0200D +TS VCFC OVC050 BKN040TCU 14/10 A2978 RMK AIRPORT CLOSED'
>>> ksfo.update(report)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/avwx/base.py", line 120, in update
report = self.service.fetch(self.icao, timeout=timeout)
File "/usr/local/lib/python3.7/site-packages/avwx/service/scrape.py", line 101, in fetch
return aio.run(self.async_fetch(station, timeout))
File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/runners.py", line 43, in run
return loop.run_until_complete(main)
File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
return future.result()
File "/usr/local/lib/python3.7/site-packages/avwx/service/scrape.py", line 109, in async_fetch
return await self._fetch(station, url, params, timeout)
File "/usr/local/lib/python3.7/site-packages/avwx/service/scrape.py", line 79, in _fetch
resp = await client.get(url, params=params)
File "/usr/local/lib/python3.7/site-packages/httpx/_client.py", line 1456, in get
timeout=timeout,
File "/usr/local/lib/python3.7/site-packages/httpx/_client.py", line 1282, in request
request, auth=auth, allow_redirects=allow_redirects, timeout=timeout
File "/usr/local/lib/python3.7/site-packages/httpx/_client.py", line 1313, in send
request, auth=auth, timeout=timeout, allow_redirects=allow_redirects
File "/usr/local/lib/python3.7/site-packages/httpx/_client.py", line 1342, in _send_handling_redirects
request, auth=auth, timeout=timeout, history=history
File "/usr/local/lib/python3.7/site-packages/httpx/_client.py", line 1378, in _send_handling_auth
response = await self._send_single_request(request, timeout)
File "/usr/local/lib/python3.7/site-packages/httpx/_client.py", line 1414, in _send_single_request
timeout=timeout.as_dict(),
File "/usr/local/lib/python3.7/site-packages/httpcore/_async/connection_pool.py", line 183, in request
await self._add_to_pool(connection, timeout=timeout)
File "/usr/local/lib/python3.7/site-packages/httpcore/_async/connection_pool.py", line 309, in _add_to_pool
await self._connection_semaphore.acquire(timeout=timeout.get("pool", None))
File "/usr/local/lib/python3.7/site-packages/httpcore/_backends/asyncio.py", line 203, in acquire
await asyncio.wait_for(self.semaphore.acquire(), timeout)
File "/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
if timeout <= 0:
TypeError: '<=' not supported between instances of 'str' and 'int'
I am getting this crash on both MacOS and Raspberry Pi OS after a fresh install of avwx.
devdupont commented
Hmmm. Looks like the documentation hasn't been building lately. Need to figure out why.
In the meantime, report parsing has been given its own method:
from avwx import Metar
ksfo = Metar("KSFO")
report = "KSFO 031254Z 36024G55KT 320V040 1/8SM R06/0200D +TS VCFC OVC050 BKN040TCU 14/10 A2978 RMK AIRPORT CLOSED"
ksfo.parse(report)
print(ksfo.data.flight_rules). # => "LIFR"
nicelion commented
Awesome. Thank you for your help.