The branch, frodo has been updated
via 764833238a2b57c8907c1da8ea2bfb94d31e1f8b (commit)
from 192a9b39f84762d767814c29bc81259eb409f40e (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=764833238a2b57c8907c1da8ea2bfb94d31e1f8b
commit 764833238a2b57c8907c1da8ea2bfb94d31e1f8b
Author: Martijn Kaijser <[email protected]>
Date: Sun Aug 11 12:07:51 2013 +0200
[weather.ozweather ] 0.6.5
diff --git a/weather.ozweather/addon.xml b/weather.ozweather/addon.xml
index 871c2e6..7db95a2 100644
--- a/weather.ozweather/addon.xml
+++ b/weather.ozweather/addon.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="weather.ozweather" name="Oz Weather" version="0.6.4"
provider-name="Bossanova808">
+<addon id="weather.ozweather" name="Oz Weather" version="0.6.5"
provider-name="Bossanova808">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.parsedom" version="1.2.0"/>
diff --git a/weather.ozweather/changelog.txt b/weather.ozweather/changelog.txt
index 8d55c54..4d9de53 100644
--- a/weather.ozweather/changelog.txt
+++ b/weather.ozweather/changelog.txt
@@ -1,3 +1,6 @@
+V0.6.5
+- Bit of defensive programming to deal with parsedom and weatherzone issue
+
V0.6.4
- pan2 changes merged - adds date labels
diff --git a/weather.ozweather/default.py b/weather.ozweather/default.py
index e444221..fed4061 100644
--- a/weather.ozweather/default.py
+++ b/weather.ozweather/default.py
@@ -47,6 +47,94 @@ HTTPSTUB =
"http://www.bom.gov.au/products/radar_transparencies/"
RADAR_BACKGROUNDS_PATH = ""
LOOP_IMAGES_PATH = ""
+# this is fetchpage from parseDOM...
+# added emergency latin 1 decoding for wierd char issues on Weatherzone
+
+def fetchPage(params={}):
+ get = params.get
+ link = get("link")
+ ret_obj = {}
+ if get("post_data"):
+ log("called for : " + repr(params['link']))
+ else:
+ log("called for : " + repr(params))
+
+ if not link or int(get("error", "0")) > 2:
+ log("giving up")
+ ret_obj["status"] = 500
+ return ret_obj
+
+ if get("post_data"):
+ if get("hide_post_data"):
+ log("Posting data", 2)
+ else:
+ log("Posting data: " + urllib.urlencode(get("post_data")), 2)
+
+ request = urllib2.Request(link, urllib.urlencode(get("post_data")))
+ request.add_header('Content-Type', 'application/x-www-form-urlencoded')
+ else:
+ log("Got request", 2)
+ request = urllib2.Request(link)
+
+ if get("headers"):
+ for head in get("headers"):
+ request.add_header(head[0], head[1])
+
+ request.add_header('User-Agent', USERAGENT)
+
+ if get("cookie"):
+ request.add_header('Cookie', get("cookie"))
+
+ if get("refering"):
+ request.add_header('Referer', get("refering"))
+
+ try:
+ log("connecting to server...", 1)
+
+ con = urllib2.urlopen(request)
+ ret_obj["header"] = con.info()
+ ret_obj["new_url"] = con.geturl()
+ if get("no-content", "false") == u"false" or get("no-content",
"false") == "false":
+ inputdata = con.read()
+ #data_type = chardet.detect(inputdata)
+ #inputdata = inputdata.decode(data_type["encoding"]
+ try:
+ ret_obj["content"] = inputdata.decode("utf-8")
+ except:
+ try:
+ ret_obj["content"] = inputdata.decode("latin-1")
+ except:
+ raise
+
+ con.close()
+
+ log("Done")
+ ret_obj["status"] = 200
+ return ret_obj
+
+ except urllib2.HTTPError, e:
+ err = str(e)
+ log("HTTPError : " + err)
+ log("HTTPError - Headers: " + str(e.headers) + " - Content: " +
e.fp.read())
+
+ params["error"] = str(int(get("error", "0")) + 1)
+ ret = fetchPage(params)
+
+ if not "content" in ret and e.fp:
+ ret["content"] = e.fp.read()
+ return ret
+
+ ret_obj["status"] = 500
+ return ret_obj
+
+ except urllib2.URLError, e:
+ err = str(e)
+ log("URLError : " + err)
+
+ time.sleep(3)
+ params["error"] = str(int(get("error", "0")) + 1)
+ ret_obj = fetchPage(params)
+ return ret_obj
################################################################################
@@ -172,10 +260,16 @@ def forecast(url, radarCode):
#and now get and set all the temperatures etc.
log("Get the forecast data from weatherzone.com.au: " + url)
try:
- data = common.fetchPage({"link":url})
+ data = fetchPage({"link":url})
except Exception as inst:
- log("Error, couldn't retrieve weather page from WeatherZone - error:
", inst)
- if data != '':
+ log("Error, couldn't fetchPage weather page from WeatherZone [" + url
+ "]- error: ", inst)
+ try:
+ data = {}
+ data["content"] = urllib2.urlopen(url)
+ except:
+ log("Error, couldn't urlopen weather page from WeatherZone [" +
url + "]- error: ", inst)
+
+ if data != '' and data is not None:
propertiesPDOM(data["content"], extendedFeatures)
else:
log("Weatherzone returned empty data??!")
@@ -284,9 +378,15 @@ def buildImages(radarCode):
#we need make the directories to store stuff if they don't exist
if not xbmcvfs.exists( RADAR_BACKGROUNDS_PATH ):
- os.makedirs( RADAR_BACKGROUNDS_PATH )
+ try:
+ os.makedirs( RADAR_BACKGROUNDS_PATH )
+ except:
+ log("xbmcvfs.exists was false, but couldn't make the directory?!")
if not xbmcvfs.exists( LOOP_IMAGES_PATH ):
- os.makedirs( LOOP_IMAGES_PATH )
+ try:
+ os.makedirs( LOOP_IMAGES_PATH )
+ except:
+ log("xbmcvfs.exists was false, but couldn't make the directory?!")
log("Prepare the backgrounds if necessary...")
prepareBackgrounds(radarCode)
-----------------------------------------------------------------------
Summary of changes:
weather.ozweather/addon.xml | 2 +-
weather.ozweather/changelog.txt | 3 +
weather.ozweather/default.py | 110 +++++++++++++++++++++++++++++++++++++--
3 files changed, 109 insertions(+), 6 deletions(-)
hooks/post-receive
--
Scripts
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons