]]>-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.
#!/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
]]>--- /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
#!/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
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.
]]>-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
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
]]>