You are not logged in.

#1 2006-08-03 22:13:28

T-Dawg
Forum Fellow
From: Wilmington, NC
Registered: 2005-01-29
Posts: 2,734

weatherget - CLI weather reporting tool

I've had a programming bug up my a** the last couple of days and made this.

[tyler@eLINUXe ~]$ weatherget -h

usage: weatherget [options]

options:
  -h, --help                             show this help message and exit
  -v, --version                          display version and exit
  -s ID, --station-id=ID                 station id (U.S. users can use zip)
  -l CITY, --lookup=CITY                 lookup station id for CITY
  -c CITY, --city=CITY                   lookup and use station id for CITY
  -S, --standard                         use standard units
  -m, --metric                           use metric units
  -e NUMDAYS, --extended-day=NUMDAYS     provide and extended day forecast as
                                         specified in NUMDAYS

You can use a --station-id=ID  (for US users zip code will work) or --city=CITY enclosed in double quotes which will translate it automaticaly. I do however, suggest using --lookup=CITY once to get your station id and using that instead because weather.com's server doesn't like having to do too many translations at once. You must also specify --standard or --metric for the units. An extended day forecast is optional through --extended-day=NUMDAYS.

A simple example:

[tyler@eLINUXe ~]$ weatherget --lookup="Wilmington, NC"
station id for Wilmington, NC is USNC0760
[tyler@eLINUXe ~]$ weatherget --station-id=USNC0760 --extended-day=3 --standard
New Hanover International Airport, NC  8/3/06 5:25 PM EDT
  time zone:     -4 GMT
  sunrise:       6:24 AM
  sunset:        8:11 PM
  uv:            Moderate, 3
  temperature:   92 F
  feels like:    103 F
  conditions:    Sunny
  wind:          12 mph, 0 mph gusts, S
  humidity:      58 %
  barometer:     29.88 in, falling
  dewpoint:      75 F
  visibility:    8.0 mi
  moon:          Waxing Gibbous
HEAT WARNING UNTIL THU AUG 03 2006 07:00 PM EDT
http://www.weather.com/weather/alerts?alertId=53941

Tonight:
  sunrise:       6:24 AM
  sunset:        8:11 PM
  high:          N/A F
  low:           79 F
  conditions:    IsolatedT-Storms
  wind:          11 mph, 0 mph gusts, S
  precipitation: 30 %
  humidity:      83 %

Friday:
  sunrise:       6:24 AM
  sunset:        8:10 PM
  high:          94 F
  low:           78 F
  conditions:    IsolatedT-Storms
  wind:          10 mph, N/A mph gusts, S
  precipitation: 30 %
  humidity:      66 %

Saturday:
  sunrise:       6:25 AM
  sunset:        8:09 PM
  high:          88 F
  low:           76 F
  conditions:    ScatteredT-Storms
  wind:          8 mph, N/A mph gusts, S
  precipitation: 40 %
  humidity:      73 %

The read out style is not hardcoated and in fact can be configured in ~/.weathergetrc. It should be self explanitary. Realize however, it must follow python syntax so keep the indentions where they're at.

The coolest thing about this is that you can use it in something like conky using exec <interval> . My line in .conkyrc:

${color #0077ff}Local Weather:
$color ${execi 1200 /usr/bin/weatherget --station-id=28403 --standard}

This should work in most platforms but I haven't properly packaged it yet with a setup.py file so installation will have to be done manually for now.
EDIT:
uploaded to AUR

Enjoy or whatever.

Offline

#2 2006-08-03 22:39:30

barebones
Member
Registered: 2006-04-30
Posts: 235

Re: weatherget - CLI weather reporting tool

Thanks Penguin, this looks pretty cool. I used a weather checker that was on the conky project page, but this one seems much nicer.

Offline

#3 2006-08-03 22:48:48

Chman
Member
Registered: 2006-01-31
Posts: 169
Website

Re: weatherget - CLI weather reporting tool

Simply awesome. Thanks.

Offline

#4 2006-08-04 00:31:11

codemac
Member
From: Cliche Tech Place
Registered: 2005-05-13
Posts: 776
Website

Re: weatherget - CLI weather reporting tool

Cool stuff dude.

Offline

#5 2006-08-04 01:19:21

T-Dawg
Forum Fellow
From: Wilmington, NC
Registered: 2005-01-29
Posts: 2,734

Re: weatherget - CLI weather reporting tool

thanks guys. I added another switch to specify an alternate config file and uploaded it to AUR

Offline

#6 2006-08-04 01:24:00

PeteMo
Member
From: H'Burg, VA
Registered: 2006-01-26
Posts: 191
Website

Re: weatherget - CLI weather reporting tool

Great stuff.  I have been working on a perl version using the noaa's SOAP service, off and on (mostly off) for the last few months.  This is great.  Thanks.

One thing, though.  It chokes if you give it an invalid number of days:

Traceback (most recent call last):
  File "./bin/devel/weather/weatherget.py", line 479, in ?
    day_dict = dayf().index_and_day(NUMDAYS)
  File "./bin/devel/weather/weatherget.py", line 286, in index_and_day
    line = reg_tag('day d="'+str(day_index)+'"', self.dayf)[0]
IndexError: list index out of range

Offline

#7 2006-08-04 01:31:24

T-Dawg
Forum Fellow
From: Wilmington, NC
Registered: 2005-01-29
Posts: 2,734

Re: weatherget - CLI weather reporting tool

Are you using version from AUR I just uploaded? I fixed that to not accept anymore than 10 days.

Offline

#8 2006-08-04 02:02:24

PeteMo
Member
From: H'Burg, VA
Registered: 2006-01-26
Posts: 191
Website

Re: weatherget - CLI weather reporting tool

Aahhh.  I grabbed it before you had it up on the AUR.  Thanks.

Offline

#9 2006-08-05 00:46:46

deficite
Member
From: Augusta, GA
Registered: 2005-06-02
Posts: 693

Re: weatherget - CLI weather reporting tool

Sweet. I like simple and elegant programs like this. It's what makes the Linux world go 'round.

Offline

#10 2006-08-08 20:06:33

djpharoah
Member
From: SoCal
Registered: 2006-06-18
Posts: 185

Re: weatherget - CLI weather reporting tool

nice program - good to have in a root tail running in the background


IBM T41p - 2373-xXx - kernel26thinkpad

Offline

#11 2006-08-09 02:51:01

benplaut
Member
From: Not-so-sunny Hawaii
Registered: 2006-06-13
Posts: 383

Re: weatherget - CLI weather reporting tool

Very nice!

This now gets added to my screen session specifically for system monitors and the like smile


<zyth> OH GOD IT HURTS rauble
<Monk-e> rauble, roflrofl
<Monk-e> wtf?
<rauble> arpil fooz!

Offline

#12 2006-08-09 02:59:53

codemac
Member
From: Cliche Tech Place
Registered: 2005-05-13
Posts: 776
Website

Re: weatherget - CLI weather reporting tool

Why does http://xoap.weather.com/search/search?w … burg,%20VA work, and weatherget --location="Blacksburg, VA" not?

Offline

#13 2006-08-09 08:26:25

smarcher
Member
From: Calcutta
Registered: 2003-12-12
Posts: 41
Website

Re: weatherget - CLI weather reporting tool

codemac wrote:

Why does http://xoap.weather.com/search/search?w … burg,%20VA work, and weatherget --location="Blacksburg, VA" not?

Hi

I have the same problem. In my case instead of Blackburg, it is Calcutta. When I try to check:

weatherget --lookup=Calcutta
no station id found for `Calcutta'

I get no station id found. But the url works:

http://xoap.weather.com/search/search?where=calcutta


What seems to be wrong?

Thanks in advance and it is a great script, will help me learn Python smile
Sudeep

Offline

#14 2006-08-09 10:11:16

T-Dawg
Forum Fellow
From: Wilmington, NC
Registered: 2005-01-29
Posts: 2,734

Re: weatherget - CLI weather reporting tool

codemac wrote:

Why does http://xoap.weather.com/search/search?w … burg,%20VA work, and weatherget --location="Blacksburg, VA" not?

There is no --location switch. --lookup doesn't work for you?

[tyler@eLINUXe ~]$ weatherget --lookup="Blacksburg, VA"
station id for Blacksburg, VA is USVA0068

Remember you can't query the server too many times for city translations, it just locks up.

Offline

#15 2006-08-09 10:16:51

T-Dawg
Forum Fellow
From: Wilmington, NC
Registered: 2005-01-29
Posts: 2,734

Re: weatherget - CLI weather reporting tool

smarcher wrote:
codemac wrote:

Why does http://xoap.weather.com/search/search?w … burg,%20VA work, and weatherget --location="Blacksburg, VA" not?

Hi

I have the same problem. In my case instead of Blackburg, it is Calcutta. When I try to check:

weatherget --lookup=Calcutta
no station id found for `Calcutta'

I get no station id found. But the url works:

http://xoap.weather.com/search/search?where=calcutta


What seems to be wrong?

Thanks in advance and it is a great script, will help me learn Python smile
Sudeep

You have to be more specific than just "calcutta". It matches what is between the tag points (> and <) exactly.
If I type in just the city for my location I would get four or five different matches. Use the state/country as well: "Calcutta, India". The case however shouldn't matter, I'll change that next time to not be case sensitive.

Offline

#16 2006-08-13 00:41:51

T-Dawg
Forum Fellow
From: Wilmington, NC
Registered: 2005-01-29
Posts: 2,734

Re: weatherget - CLI weather reporting tool

ok, changed the behavior of --lookup=CITY to display all matches instead of exact only and to not be case sensitive. It should help people find there station id a little easier. Also some very minor cosmetic changes to the default ~/.weathergetrc file.
It does work in windows just fine...if anyone here cares.

AUR

Offline

#17 2006-08-13 02:01:57

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: weatherget - CLI weather reporting tool

I've gotta start writing more POS apps. I get lazy and never maintain them and you take the idea and make something nice out of it. Maybe you can do a text editor or 3D virtual environment next.

I still had finding my station id because I can't spell the name of my city:

dusty:~ $ weatherget -l sucksass
no station id found for `sucksass'

Perhaps you need a spell correction feature too.

Nice work! Oh, and nice choice of language!

Dusty

Offline

#18 2006-08-15 23:57:42

T-Dawg
Forum Fellow
From: Wilmington, NC
Registered: 2005-01-29
Posts: 2,734

Re: weatherget - CLI weather reporting tool

I've put this up at berlios now so I can finally put my server to rest.
Please direct all your bug reports/feature requests/etc there, it will be easier for me to keep track of.
http://developer.berlios.de/projects/weatherget

Offline

#19 2006-10-12 14:59:39

Echo
Member
From: Ohio, United States
Registered: 2006-05-16
Posts: 239

Re: weatherget - CLI weather reporting tool

Very nice app. Perfect for the command line, no desktop clutter.

Offline

#20 2006-11-30 01:12:36

lilsirecho
Veteran
Registered: 2003-10-24
Posts: 5,000

Re: weatherget - CLI weather reporting tool

Enjoying the excellent weatherget program very much.  Thanks and thanks again!


Sign of the times: Navajo blanket..made in China
Hard work does not kill people but why risk it: Charlie Mccarthy
A man is not complete until he is married..then..he is finished.
When ALL is lost, what can be found? Even bytes get lonely for a little bit!     X-ray confirms Iam spineless!

Offline

#21 2006-11-30 02:11:42

T-Dawg
Forum Fellow
From: Wilmington, NC
Registered: 2005-01-29
Posts: 2,734

Re: weatherget - CLI weather reporting tool

Thanks. Glad you find it useful. smile

Offline

#22 2006-11-30 02:29:45

slackhack
Member
Registered: 2004-06-30
Posts: 738

Re: weatherget - CLI weather reporting tool

excellent! great little program.

for now i just have an alias, but it would be cool to be able to specifiy the ID and the -S or -m in the config file -- or not knowing python am i just missing how to do it?

thanks, very useful smile

Offline

#23 2006-11-30 02:39:20

T-Dawg
Forum Fellow
From: Wilmington, NC
Registered: 2005-01-29
Posts: 2,734

Re: weatherget - CLI weather reporting tool

Your not missing anything. Adding those variables to the rc file won't make it work either. Given its nature, my intention was to be able to alias it as you did or include it with all the needed args in a periodic script like conky...

Offline

#24 2006-12-01 00:20:41

lilsirecho
Veteran
Registered: 2003-10-24
Posts: 5,000

Re: weatherget - CLI weather reporting tool

Google:  weather (zip) gives weather report also......


Sign of the times: Navajo blanket..made in China
Hard work does not kill people but why risk it: Charlie Mccarthy
A man is not complete until he is married..then..he is finished.
When ALL is lost, what can be found? Even bytes get lonely for a little bit!     X-ray confirms Iam spineless!

Offline

#25 2006-12-01 00:27:26

T-Dawg
Forum Fellow
From: Wilmington, NC
Registered: 2005-01-29
Posts: 2,734

Re: weatherget - CLI weather reporting tool

yeah but can it run without X?  wink

Offline

Board footer

Powered by FluxBB