Giter Site home page Giter Site logo

pywu's Introduction

pywu

image

pywu is a simple python script for fetching data from Weather Underground's API. You need an API key to use the script (get it here).

Note: Weather Underground has discontinued free API keys. If you already have an API key from them, pywu will continue to work with it, otherwise there is not a way to get pywu working for the time being.

Installation

pywu is available on PyPI. You can install it with pip:

pip3 install pywu

If installing from source run:

python3 setup.py build install

You can also run the script locally if preferred. Download pywu/pywu.py to a directory of your choosing and run it with python:

python3 pywu.py

Usage

pywu [-h] [-v] [-f <min>] {fetch,current,forecast,info} ...

You must first fetch the data using the fetch command. This stores a file in /tmp that contains the data. All other commands (current, forecast, and info) read from this file.

fetch

Pull weather data from server. Use the format '<API key> <city>,<state>' or simply your API key and zip code.

pywu fetch <apikey> 'New York,NY'
pywu fetch <apikey> 10001

If you want to specify a specific weather station, use the format "pws:" followed by the station code. For example:

pywu fetch <apikey> pws:KNYNEWYO395

You can also specify a language (the default is English). For example:

pywu fetch <apikey> <location> FR

A list of possible language codes can be found here.

Instead of the above, you may also use a ~/.pywu.conf file and simply call pywu fetch. See below for more information.

current

Display current statistics. Possible commands:

pywu current condition
pywu current temp_f
pywu current temp_c
pywu current humidity
pywu current icon
pywu current wind
pywu current wind_dir
pywu current wind_mph
pywu current wind_kph
pywu current wind_gust_mph
pywu current wind_gust_kph
pywu current wind_string_mph
pywu current wind_string_kph
pywu current pressure_mb
pywu current pressure_in
pywu current dewpoint_c
pywu current dewpoint_f
pywu current heat_index_c
pywu current heat_index_f
pywu current windchill_c
pywu current windchill_f
pywu current feelslike_c
pywu current feelslike_f
pywu current visibility_mi
pywu current visibility_km
pywu current prec_hour_in
pywu current prec_hour_cm
pywu current prec_day_in
pywu current prec_day_cm

forecast

Display forecast statistics. Possible commands:

pywu forecast day
pywu forecast shortdate
pywu forecast longdate
pywu forecast low_f
pywu forecast low_c
pywu forecast high_f
pywu forecast high_c
pywu forecast icon
pywu forecast condition
pywu forecast rain_in
pywu forecast rain_mm
pywu forecast snow_in
pywu forecast snow_cm

You can also specify a day:

-d {0,1,2,3,4,5,6,7,8,9}, --day {0,1,2,3,4,5,6,7,8,9}

Default is 0 (today).

Example:

pywu forecast condition --day 1

alert ~~~~

Display alert information. Possible commands:

pywu alert start
pywu alert expires
pywu alert description
pywu alert message

You can also specify a number for multiple alerts (default is 1):

-n NUM, --num NUM

info

Display forecast information. Possible commands:

pywu info city
pywu info postal
pywu info datetime
pywu info location
pywu info country
pywu info latitude
pywu info longitude
pywu info elevation
pywu info observation

Verbose Output

pywu is designed to stay quiet instead of print information or errors. This is so these messages will not appear when used with Conky. To override this, specify the -v parameter:

pywu -v fetch

Fetching Inline

This requires a config file at ~/.pywu.conf. You can also fetch new information at the same time as you print current/forecast information:

pywu --fetch <min> current condition
pywu -f <min> forecast condition -d 3

pywu will fetch new information if the current information is older than <min>.

Config file

pywu supports reading from a config file as well as passing your API key/location via command line. A sample configuration:

~/.pywu.conf:

[PYWU]
apikey=<yourapikey>
location=New York City, NY

You can also specify a language within the config file:

[PYWU]
...
language=FR

Conky

pywu can be used with Conky. An example conkyrc is provided in the examples directory. It's recommended to have a script call pywu fetch before conky starts and then periodcally from within the conkyrc (the example shows every 15 minutes or 900 seconds).

pywu's People

Contributors

dh4 avatar jfx2006 avatar jonestristand avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.