Merge lp:~saiarcot895/my-weather-indicator/time-zone-fix into lp:my-weather-indicator

Proposed by Saikrishna Arcot
Status: Merged
Approved by: Lorenzo Carbonell
Approved revision: 195
Merged at revision: 195
Proposed branch: lp:~saiarcot895/my-weather-indicator/time-zone-fix
Merge into: lp:my-weather-indicator
Diff against target: 53 lines (+11/-12)
2 files modified
debian/control (+1/-1)
src/geocodeapi.py (+10/-11)
To merge this branch: bzr merge lp:~saiarcot895/my-weather-indicator/time-zone-fix
Reviewer Review Type Date Requested Status
Lorenzo Carbonell Approve
Review via email: mp+173313@code.launchpad.net

Description of the change

Change the time zone provider to Geonames, which returns a time zone compatible with Olson's time zone database, and use python-tz to look up the UTC offset.

To post a comment you must log in.
Revision history for this message
Lorenzo Carbonell (lorenzo-carbonell) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2013-04-20 06:50:43 +0000
+++ debian/control 2013-07-06 14:30:35 +0000
@@ -2,7 +2,7 @@
2Section: utils2Section: utils
3Priority: extra3Priority: extra
4Maintainer: Lorenzo Carbonell Cerezo <lorenzo.carbonell.cerezo@gmail.com>4Maintainer: Lorenzo Carbonell Cerezo <lorenzo.carbonell.cerezo@gmail.com>
5Build-Depends: debhelper (>= 8), python, python-distutils-extra, python-polib5Build-Depends: debhelper (>= 8), python, python-distutils-extra, python-polib, python3-tz, python3-urllib3,
6Standards-Version: 3.9.36Standards-Version: 3.9.3
7Homepage: http://www.atareao.es7Homepage: http://www.atareao.es
88
99
=== modified file 'src/geocodeapi.py'
--- src/geocodeapi.py 2013-05-19 21:57:34 +0000
+++ src/geocodeapi.py 2013-07-06 14:30:35 +0000
@@ -28,6 +28,8 @@
28from sun import Sun28from sun import Sun
29import locale29import locale
30import datetime30import datetime
31import pytz
32import urllib
31locale.setlocale(locale.LC_MESSAGES, '')33locale.setlocale(locale.LC_MESSAGES, '')
32LANG = locale.getlocale(locale.LC_MESSAGES)[0]34LANG = locale.getlocale(locale.LC_MESSAGES)[0]
33'''35'''
@@ -99,19 +101,16 @@
99 if len(directions)>0:101 if len(directions)>0:
100 return directions[0]102 return directions[0]
101 return None103 return None
102
103104
104def get_rawOffset(lat,lon): 105def get_rawOffset(lat,lon):
105 url = 'http://www.earthtools.org/timezone/%s/%s'%(lat,lon)106 try:
106 response = read_from_url(url).decode('ISO-8859-1')107 response = read_from_url('http://api.geonames.org/timezoneJSON?lat=%s&lng=%s&username=saiarcot895'%(lat,lon)).decode('ISO-8859-1')
107 inicio = response.find('<offset>')+8108 json_response = json.loads(response)
108 fin = response.find('</offset>')109 timezone = pytz.timezone(json_response['timezoneId']);
109 ro = s2f(response[inicio:fin])110 strOffset = timezone.localize(datetime.datetime.now()).strftime("%z");
110 inicio = response.find('<dst>')+5111 return s2f(strOffset) / 100;
111 fin = response.find('</dst>')112 except urllib.error.URLError:
112 if response[inicio:fin]=='True':113 print('Geonames error')
113 ro = ro + 1.0
114 return ro
115 114
116def get_inv_direction(lat,lon):115def get_inv_direction(lat,lon):
117 directions = get_inv_directions(lat,lon)116 directions = get_inv_directions(lat,lon)

Subscribers

People subscribed via source and target branches

to status/vote changes: