Skip to content

Commit

Permalink
Merge pull request #50 from JohnMarzulli/update_weather_format
Browse files Browse the repository at this point in the history
Update NOAA Source Site
  • Loading branch information
JohnMarzulli authored Oct 19, 2023
2 parents 2a49d51 + 1807123 commit e5179c3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
29 changes: 12 additions & 17 deletions data_sources/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,28 +646,23 @@ def get_metar_reports_from_web(

metars = {}
metar_list = "%20".join(airport_icao_codes)
request_url = 'http://www.aviationweather.gov/metar/data?ids={}&format=raw&hours=0&taf=off&layout=off&date=0'.format(
metar_list)
request_url = 'https://aviationweather.gov/cgi-bin/data/metar.php?ids={}&hours=0&order=id%2C-obs&sep=true'.format(metar_list)
stream = urllib.request.urlopen(request_url, timeout=2)
data_found = False

stream_lines = stream.readlines()
stream.close()
for line in stream_lines:
line_as_string = line.decode("utf-8")
if '<!-- Data starts here -->' in line_as_string:
data_found = True
elif '<!-- Data ends here -->' in line_as_string:
break
elif data_found:
identifier, metar = get_metar_from_report_line(line_as_string)

if identifier is None:
continue

# If we get a good report, go ahead and shove it into the results.
if metar is not None:
metars[identifier] = metar
__station_last_called__[identifier] = datetime.utcnow()

identifier, metar = get_metar_from_report_line(line_as_string)

if identifier is None:
continue

# If we get a good report, go ahead and shove it into the results.
if metar is not None:
metars[identifier] = metar
__station_last_called__[identifier] = datetime.utcnow()

return metars

Expand Down
17 changes: 11 additions & 6 deletions lib/local_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
from sys import platform as os_platform
import platform

REQUIRED_PYTHON_VERSION = 3.5
REQUIRED_PYTHON_MAJOR_VERSION = 3
REQUIRED_PYTHON_REVISION_VERSION = 5

IS_LINUX = 'linux' in os_platform
DETECTED_CPU = platform.machine()
IS_PI = "arm" in DETECTED_CPU
Expand All @@ -22,15 +24,18 @@ def validate_python_version():
Exception -- If the version of Python is not new enough.
"""

python_version = float('{}.{}'.format(
version_info.major, version_info.minor))
error_text = 'Requires Python {}'.format(REQUIRED_PYTHON_VERSION)
error_text = None

if REQUIRED_PYTHON_MAJOR_VERSION != version_info.major:
error_text = 'Requires Python 3.x, found {}.x'.format(version_info.major)

if python_version < REQUIRED_PYTHON_VERSION:
if REQUIRED_PYTHON_REVISION_VERSION > version_info.minor:
error_text = 'Requires Python 3.5 or newer, found 3.{}'.format(version_info.minor)

if error_text != None:
print(error_text)
raise Exception(error_text)


def is_debug():
"""
returns True if this should be run as a local debug (Mac or Windows).
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ This mode cycles all of the stations through the spectrum, but all stations shif

| Version | Change |
| ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 2.1.1 | Fix issue where newer versions of Python would not let the code to run. Update to newer NOAA source. Show name of visualizer.
| 2.1 | Change precipitation visualizer to pulse the snow color to make it distinct from "nothing"
| 2.0.1 | Minor tweak to ceiling categorization. |
| 2.0 | Add a remote control app that allows for brightness, night effects, and more to be changed on the fly. Add support for WS2811 and WS2812 based lights. Major performance improvements for adressable RGB LEDs. Selectable visualizers. Removed support for hard wired GPIO based LEDs. |
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

setup(
name='cateorical-sectional',
version='2.1',
version='2.2.1',
python_requires='>=3.7',
description='VFR weathermap supporting Adafruit WS2801 lights.',
url='https://github.com/JohnMarzulli/categorical-sectional',
Expand Down

0 comments on commit e5179c3

Please sign in to comment.