Giter Site home page Giter Site logo

weatheralerts's Issues

Error running the sample from the documents

from weatheralerts import WeatherAlerts

# Alerts by a Samecode
nws = WeatherAlerts(samecodes='005029')
for alert in nws.alerts:
    print (alert.title)

(base) william@william:~/CODE/Weather-NOAA-Alert-Example$ python3.6 w.py

Traceback (most recent call last):
  File "w.py", line 7, in <module>
    nws = WeatherAlerts(samecodes='005029')
  File "/home/william/.local/lib/python3.6/site-packages/weatheralerts/weather_alerts.py", line 27, in __init__
    self.geo = GeoDB()
  File "/home/william/.local/lib/python3.6/site-packages/weatheralerts/geo.py", line 17, in __init__
    self.__same = SameCodes()
  File "/home/william/.local/lib/python3.6/site-packages/weatheralerts/geo.py", line 95, in __init__
    self._load_same_codes()
  File "/home/william/.local/lib/python3.6/site-packages/weatheralerts/geo.py", line 111, in _load_same_codes
    self._cached_same_codes()
  File "/home/william/.local/lib/python3.6/site-packages/weatheralerts/geo.py", line 148, in _cached_same_codes
    self.reload()
  File "/home/william/.local/lib/python3.6/site-packages/weatheralerts/geo.py", line 104, in reload
    self._load_same_codes(refresh=True)
  File "/home/william/.local/lib/python3.6/site-packages/weatheralerts/geo.py", line 109, in _load_same_codes
    self._get_same_codes()
  File "/home/william/.local/lib/python3.6/site-packages/weatheralerts/geo.py", line 121, in _get_same_codes
    code, local, state = str(row).strip().split(',')
ValueError: not enough values to unpack (expected 3, got 1)

ValueError: not enough values to unpack (expected 3, got 1)

Relatively dumb when it comes to coding. Tried specifying one SAMECODE, got that. Specified 2, got the same results. Same happened when I tried to use a state. Omitting most of the unnecessary code to save 180 or so lines.

import weatheralerts
from weatheralerts import WeatherAlerts

nws = WeatherAlerts(samecodes='022055') #not my SAMECODE, random one I planned on using to test as it had a flash flood warning in effect
for alert in nws.alerts:
     print(f"{alert.areadesc}: {alert.title}")

Originally was writing to a file as well, but shouldn't make a difference here whether or not I change it to a print string.

Expire cache/Reload without creating new alerts object

if a program using the alerts object is long running and then the cache time logic won't be hit and thus never reloaded. need to provide method to check the age of the alerts object and reload new data after the cache maxage is reached

Automating

Awesome job on this project! Very new to Python is there a way to run the script then have it sleep for say 2 minutes then automatically run again and check for any new alerts? Look forward to your response.

Support Zone/County only feeds

Currently, WeatherAlerts only supports National and State level feeds. The NWS does offer Zone and County feeds (but not samecode based feed) For basic use, pulling the zone/county needed for a samecode would save a lot of processing and bandwidth.

SameCodes assumes the cache is always correct

In geo.py, SameCodes._cached_same_codes() returns True regardless of the contents of the cache file. After a failed run, the cache file existed on my file system but was empty. Subsequent attempts all failed because no SAME codes were available.

In addition to checking if the file exists, please ensure that the cache also has useful information and if not, reload().

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.