You are not logged in.

#26 2007-01-27 15:24:16

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

Re: weatherget - CLI weather reporting tool

-v0.3 (January 27, 2007)
   * Added manual page
   * Added /usr/share/doc info
   * Cosmetic improvements to default output in weathergetrc
   * Minor code improvements
   * More comments

Updated output syntax from weathergetrc:

Wilmington, NC (28403)  (-77.89, 34.22)
New Hanover International Airport, NC  1/27/07 10:00 AM EST
  Temperature    : 53 F
  Feels Like     : 53 F
  Conditions     : Fair
  Wind           : 15 mph, 0 mph gusts, SW
  Visibility     : 10.0 mi
  Humidity       : 30 %
  Barometer      : 30.10 in, rising
  Dewpoint       : 22 F
  UV             : Low, 2
  Sunrise        : 7:13 AM
  Sunset         : 5:37 PM
  Moon           : Waxing Gibbous
  Time Zone      : -5 GMT

Today
  High           : 66 F
  Low            : 46 F
  Conditions     : Sunny
  Precipitation  : 0 %
  Wind           : 16 mph, 0 mph gusts, SW
  Humidity       : 39 %
  Sunrise        : 7:13 AM
  Sunset         : 5:37 PM

Sunday
  High           : 59 F
  Low            : 26 F
  Conditions     : AM Showers
  Precipitation  : 60 %
  Wind           : 13 mph, 0 mph gusts, SW
  Humidity       : 56 %
  Sunrise        : 7:12 AM
  Sunset         : 5:38 PM

Offline

#27 2007-01-27 23:41:33

yankees26
Member
From: Connecticut, USA
Registered: 2006-09-29
Posts: 190

Re: weatherget - CLI weather reporting tool

Very nice T-Dawg...and say hello to your little friend for me tongue

Offline

#28 2007-02-22 05:25:57

milchan
Member
Registered: 2007-02-22
Posts: 2

Re: weatherget - CLI weather reporting tool

Hi, I tried to use this program in conky, it's great but when i don't have network connection conky doesn't run. when i plug in the cable it starts. this program blocks conky.

without connection console replies:

milchan@milchan:~/Progs/weatherget-0.3.2$ ./weatherget -s PLXX0029 --metric
Traceback (most recent call last):
  File "./weatherget", line 535, in ?
    temp_units  = head().ut()[0].strip()
  File "./weatherget", line 271, in __init__
    self.head = tag_contents('head', forecast().forecast)[0]
  File "./weatherget", line 264, in __init__
    self.forecast = retrieve_weather()
  File "./weatherget", line 253, in retrieve_weather
    f = urllib.urlopen(forecast_url)
  File "/usr/lib/python2.4/urllib.py", line 82, in urlopen
    return opener.open(url)
  File "/usr/lib/python2.4/urllib.py", line 190, in open
    return getattr(self, name)(url)
  File "/usr/lib/python2.4/urllib.py", line 313, in open_http
    h.endheaders()
  File "/usr/lib/python2.4/httplib.py", line 798, in endheaders
    self._send_output()
  File "/usr/lib/python2.4/httplib.py", line 679, in _send_output
    self.send(msg)
  File "/usr/lib/python2.4/httplib.py", line 646, in send
    self.connect()
  File "/usr/lib/python2.4/httplib.py", line 614, in connect
    socket.SOCK_STREAM):
IOError: [Errno socket error] (-3, 'Temporary failure in name resolution')

but when i have connection it works great.

milchan@milchan:~/Progs/weatherget-0.3.2$ ./weatherget -s PLXX0029 --metric
  Temperature:      1 C / 1 C
  Condition:            Light Rain
  Wind:                   3 km/h
  Barometer:          1010.2

it's after ~/.weathergetrc edition for my conky

please, help me.

Last edited by milchan (2007-02-22 05:30:22)

Offline

#29 2007-02-22 09:08:51

Purch
Member
From: Finland
Registered: 2006-02-23
Posts: 229

Re: weatherget - CLI weather reporting tool

Make a script that checks if internet connection is up before it executes the weatherget.

#!/bin/bash
# ifconfig line prints the inet IP address of the eth0
if [[ -n `ifconfig eth0 2>/dev/null | grep 'inet addr' | awk '{print $2}' | sed -e 's/.*://'` ]];then
   weatherget
else
   echo "no connection"
fi
exit 0

Offline

#30 2007-02-22 11:31:17

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

Re: weatherget - CLI weather reporting tool

hmm... strange it blocks conky. Not sure if this will help you but here is a patch that will catch url retrieve problems, print a friendly message to the screen and exit.

--- /usr/bin/weatherget.old     2007-02-22 06:21:16.000000000 -0500
+++ /usr/bin/weatherget 2007-02-22 06:27:08.000000000 -0500
@@ -142,7 +142,12 @@
 
 def id_lookup(city):
        lookup_url = 'http://xoap.weather.com/search/search?where='+city
-       f = urllib.urlopen(lookup_url)
+       try:
+               f = urllib.urlopen(lookup_url)
+       except Exection, e:
+               print >>sys.stderr.write('Error: could not fetch url '+lookup_url+':')
+               print >>sys.stderr.write(str(e))
+               sys.exit(1)
        lines = f.readlines()
        f.close()
        station_id = []
@@ -250,7 +255,12 @@
 
        global forecast_list
        if forecast_list == []:
-               f = urllib.urlopen(forecast_url)
+               try:
+                       f = urllib.urlopen(forecast_url)
+               except Exception, e:
+                       print >>sys.stderr.write('Error: could not fetch url '+forecast_url+':')
+                       print >>sys.stderr.write(str(e))
+                       sys.exit(1)
                lines = f.readlines()
                f.close
                forecast_list = lines

Offline

#31 2007-02-22 23:29:16

milchan
Member
Registered: 2007-02-22
Posts: 2

Re: weatherget - CLI weather reporting tool

i've decided to do something this: wink

#!/bin/bash
if [[ `ping google.com -c 1` ]];then
   /home/milchan/Progs/weatherget-0.3.2/weatherget -s PLXX0027 --metric
else
   echo "          NO CONNECTION"
   echo " "
fi
exit 0

and it works

Offline

#32 2007-02-23 19:52:32

icrave
Member
Registered: 2006-04-11
Posts: 193

Re: weatherget - CLI weather reporting tool

Great script. Using here.

Offline

#33 2007-04-16 02:19:17

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

Re: weatherget - CLI weather reporting tool

-v0.4.0.1 (April 15, 2007)
  * setup.py fixed for python 2.5 compatibility

-v0.4 (April 13, 2007)
  * Better network failure control via specialized threads.
   - Graceful exits on connection timeouts (20 seconds) and other network failures.
   - Control C now responds and exits gracefully during delayed network connections.
  * Terminal manipulations including colored text and background, underlining, bold, blinking, etc. via term_code() in weathergetrc. See the "TERM COLORS" section in the manpage for more information.

Offline

#34 2007-04-16 15:03:41

patroclo7
Member
From: Bassano del Grappa, ITALY
Registered: 2006-01-11
Posts: 915

Re: weatherget - CLI weather reporting tool

Simply nice. Very useful, you filled a niche for the CLI lover


Mortuus in anima, curam gero cutis

Offline

#35 2008-04-14 07:43:39

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: weatherget - CLI weather reporting tool

It's the second time I look for a CLI utility on Google, and I am directed to the Arch forums big_smile
Excellent! Thanks again T-Dawg smile


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

Board footer

Powered by FluxBB