Still, I like the NOAA data set because it includes, when appropriate, the wind gust speed and heat index, items that neither Google nor Yahoo! provide. Which is a simple dictionary with only current conditions, no forecasts. The modification is on Line 5, where I’ve changed the argument to my zip code. Here’s pywapi-google-example.py, modified to return values for my town rather than New York: 1: import pywapiĥ: result = pywapi.get_weather_from_google('60566') To see what kind of data are available from the different services, open the examples directory in the pywapi distribution and try them out. The revised code succeeds regardless of whether the data are reported or not.Īfter saving the edited file, execute python setup.py buildįrom the command line, give your administrator password at the prompt, and the pywapi library will be installed in /Library/Python/2.5/site-packages directory. In those situations, the original code fails when the get_weather_from_noaa function is called. As it turns out, sometimes NOAA stations don’t report wind gust, wind chill, or heat index values. The original code only works if NOAA is returning every bit of information in the data_structure tuple. Weather_data = current_observation.getElementsByTagName(tag).firstChild.data Change this code for tag in data_structure: Open the pywapi.py file and scroll to the bottom of the get_weather_from_noaa function. Until then, follow these instructions to get a working version of pywapi:ĭownload the tarball to a convenient location and extract the code. I’ve described the bug and provided my fix on the pywapi Issues page-perhaps the fix will be rolled into the official pywapi distribution soon. Fortunately, this bug is easy to fix before installation. The current version of pywapi, version 0.2.0, has a bug that causes it to fail when accessing NOAA data. The Gismeteo service is in Russian, so I can’t give any advice on using it. Google doesn’t have a weather page, per se, but it does provide weather info through an API. It provides a simple Pythonic interface to weather data supplied by The pywapi library is the creation of Eugene Kaznacheev. I’ve rewritten my GeekTool script to use this new library. Now there’s a new Python weather library, called pywapi, that simplifies the process of getting the data and extends it beyond just NOAA’s weather stations. I like having GeekTool display the current weather on my desktop, and I’ve written a script that gets the information from a NOAA website and formats it for GeekTool. Just install it as is using setup.py, and the weathertext script will work fine. Just enter that as the Unix command, and you should see your external IP address in GeekTool.The current pywapi.py, version 0.2.1, has the bug fix described in this post, so there’s no need to edit it. To save you the digging, though, here’s the command: curl -silent | awk '' | cut -f 1 -d "<". The Unix source for that entry can be found buried in In the video, I show one GeekTool entry that displays my external IP address, which can be useful if you’re trying to debug a network connectivity problem.Mega Roundup of GeekTool Scripts on Francesco Mugnai’s blog (which contains links to many other sites).Geek to Live: Monitor your Mac and more with GeekTool on Lifehacker.GeekTool and bash one liners on Mac Geekery.Ultimate GeekTool Setup on Keynote 2 Keynote.In the course of the video, I reference a collection of sites where you can find more powerful examples of what you can do with GeekTool.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |