Пример #1
0
    def buildList(self, xml):
        root = cet_fromstring(xml)
        weatherlocationname = ''
        searchresult = ''
        weatherlocationcode = ''
        list = []
        for childs in root:
            if childs.tag == 'weather':
                weatherlocationname = childs.attrib.get('weatherlocationname').encode('utf-8', 'ignore')
                searchresult = childs.attrib.get('searchresult').encode('utf-8', 'ignore')
                weatherlocationcode = childs.attrib.get('weatherlocationcode').encode('utf-8', 'ignore')
                res = [(weatherlocationcode, weatherlocationname), (eListboxPythonMultiContent.TYPE_TEXT,
                  5,
                  0,
                  500,
                  20,
                  1,
                  RT_HALIGN_LEFT | RT_VALIGN_CENTER,
                  weatherlocationname), (eListboxPythonMultiContent.TYPE_TEXT,
                  5,
                  22,
                  500,
                  20,
                  1,
                  RT_HALIGN_LEFT | RT_VALIGN_CENTER,
                  searchresult)]
                list.append(res)

        self.list = list
        self.l.setList(list)
        self.moveToIndex(0)
	def downloadCallback(self, result = None):
		if result:
			root = cet_fromstring(result)
			statetext = root.findtext("e2statetext")
			if statetext:
				text =  statetext.encode("utf-8", 'ignore')
				self.session.open(MessageBox,text,MessageBox.TYPE_INFO, timeout = 10)
Пример #3
0
	def update(self, suggestions):
		if suggestions and len(suggestions) > 0:
			if not self.shown:
				self.show()
			suggestions_tree = cet_fromstring( suggestions )
			if suggestions_tree:
				self.list = []
				self.suggestlist = []
				for suggestion in suggestions_tree.findall("CompleteSuggestion"):
					name = None
					numresults = None
					for subelement in suggestion:
						if subelement.attrib.has_key('data'):
							name = subelement.attrib['data'].encode("UTF-8")
						if subelement.attrib.has_key('int'):
							numresults = subelement.attrib['int']
						if name and numresults:
							self.suggestlist.append((name, numresults ))
				if len(self.suggestlist):
					self.suggestlist.sort(key=lambda x: int(x[1]))
					self.suggestlist.reverse()
					for entry in self.suggestlist:
						self.list.append((entry[0], entry[1] + _(" Results") ))
					self["suggestionslist"].setList(self.list)
					self["suggestionslist"].setIndex(0)
		else:
			self.hide()
Пример #4
0
	def buildList(self, xml):
		root = cet_fromstring(xml)
		searchlocation = ""
		searchresult = ""
		weatherlocationcode = ""
		list = []
		for childs in root:
			if childs.tag == "weather":
				searchlocation = childs.attrib.get("searchlocation").encode("utf-8", 'ignore')
				searchresult = childs.attrib.get("searchresult").encode("utf-8", 'ignore')
				weatherlocationcode = childs.attrib.get("weatherlocationcode").encode("utf-8", 'ignore')
				if getDesktop(0).size().width() == 1920:
					res = [
						(weatherlocationcode, searchlocation),
						(eListboxPythonMultiContent.TYPE_TEXT, 5, 0, 500, 50, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, searchlocation),
						(eListboxPythonMultiContent.TYPE_TEXT, 5, 22, 500, 50, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, searchresult),
					]
					list.append(res)
				else:
					res = [
						(weatherlocationcode, searchlocation),
						(eListboxPythonMultiContent.TYPE_TEXT, 5, 0, 500, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, searchlocation),
						(eListboxPythonMultiContent.TYPE_TEXT, 5, 22, 500, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, searchresult),
					]
					list.append(res)
					
		self.list = list
		self.l.setList(list)
		self.moveToIndex(0)
Пример #5
0
    def readXml(self, **kwargs):
        if "xml_string" in kwargs:
            # reset time
            self.configMtime = -1

            # Parse Config
            configuration = cet_fromstring(kwargs["xml_string"])
        else:
            # Abort if no config found
            if not os_path.exists(XML_CONFIG):
                doLog("No configuration file present")
                return

            # Parse if mtime differs from whats saved
            mtime = os_path.getmtime(XML_CONFIG)
            if mtime == self.configMtime:
                doLog("No changes in configuration, won't parse")
                return

            # Save current mtime
            self.configMtime = mtime

            # Parse Config
            configuration = cet_parse(XML_CONFIG).getroot()

        # Empty out timers and reset Ids
        del self.timers[:]
        self.defaultTimer.clear(-1, True)

        parseConfig(configuration, self.timers, configuration.get("version"),
                    0, self.defaultTimer)
        self.uniqueTimerId = len(self.timers)
Пример #6
0
 def buildList(self, xml):
     sizes = componentSizes[
         MSNWeatherPluginSearchResultList.SKIN_COMPONENT_KEY]
     textHeight = sizes.get(
         MSNWeatherPluginSearchResultList.SKIN_COMPONENT_TEXT_HEIGHT, 23)
     textWidth = sizes.get(
         MSNWeatherPluginSearchResultList.SKIN_COMPONENT_TEXT_WIDTH, 500)
     lineSpacing = sizes.get(
         MSNWeatherPluginSearchResultList.SKIN_COMPONENT_LINE_SPACING, 2)
     root = cet_fromstring(xml)
     searchlocation = ""
     searchresult = ""
     weatherlocationcode = ""
     list = []
     for childs in root:
         if childs.tag == "weather":
             searchlocation = childs.attrib.get(
                 "weatherlocationname").encode("utf-8", 'ignore')
             searchresult = childs.attrib.get("weatherfullname").encode(
                 "utf-8", 'ignore')
             weatherlocationcode = childs.attrib.get(
                 "weatherlocationcode").encode("utf-8", 'ignore')
             res = [
                 (weatherlocationcode, searchlocation),
                 (eListboxPythonMultiContent.TYPE_TEXT, 5, 0, textWidth,
                  textHeight, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER,
                  searchlocation),
                 (eListboxPythonMultiContent.TYPE_TEXT, 5,
                  textHeight + lineSpacing, textWidth, textHeight, 0,
                  RT_HALIGN_LEFT | RT_VALIGN_CENTER, searchresult),
             ]
             list.append(res)
     self.list = list
     self.l.setList(list)
     self.moveToIndex(0)
Пример #7
0
	def downloadCallback(self, result=None):
		if result:
			root = cet_fromstring(result)
			statetext = root.findtext("e2statetext")
			if statetext:
				text = statetext.encode("utf-8", 'ignore')
				self.session.open(MessageBox, text, MessageBox.TYPE_INFO, timeout=10)
Пример #8
0
	def buildList(self, xml):
		root = cet_fromstring(xml)
		searchlocation = ""
		searchresult = ""
		weatherlocationcode = ""
		list = []
		for childs in root:
			if childs.tag == "weather":
				searchlocation = childs.attrib.get("weatherlocationname").encode("utf-8", 'ignore')
				searchresult = childs.attrib.get("weatherfullname").encode("utf-8", 'ignore')
				weatherlocationcode = childs.attrib.get("weatherlocationcode").encode("utf-8", 'ignore')
				if skinwidth == 1280:
					x1, y1, w1, h1 = skinparameter.get("WeatherPluginSearchlocation", (5, 0, 500, 20))
					x2, y2, w2, h2 = skinparameter.get("WeatherPluginSearchresult", (5, 22, 500, 20))
				else:
					x1, y1, w1, h1 = skinparameter.get("WeatherPluginSearchlocation", (5, 0, 500, 30))
					x2, y2, w2, h2 = skinparameter.get("WeatherPluginSearchresult", (5, 27, 500, 26))
					res = [
						(weatherlocationcode, searchlocation),
						(eListboxPythonMultiContent.TYPE_TEXT, x1, y1, w1, h1, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, searchlocation),
						(eListboxPythonMultiContent.TYPE_TEXT, x2, y2, w2, h2, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, searchresult),
					]

					list.append(res)
		self.list = list
		self.l.setList(list)
		self.moveToIndex(0)
Пример #9
0
 def buildList(self, xml):
     root = cet_fromstring(xml)
     searchlocation = ""
     searchresult = ""
     weatherlocationcode = ""
     list = []
     for childs in root:
         if childs.tag == "weather":
             searchlocation = childs.attrib.get("searchlocation").encode(
                 "utf-8", 'ignore')
             searchresult = childs.attrib.get("searchresult").encode(
                 "utf-8", 'ignore')
             weatherlocationcode = childs.attrib.get(
                 "weatherlocationcode").encode("utf-8", 'ignore')
             res = [
                 (weatherlocationcode, searchlocation),
                 (eListboxPythonMultiContent.TYPE_TEXT, 5, 0, 500, 20, 1,
                  RT_HALIGN_LEFT | RT_VALIGN_CENTER, searchlocation),
                 (eListboxPythonMultiContent.TYPE_TEXT, 5, 22, 500, 20, 1,
                  RT_HALIGN_LEFT | RT_VALIGN_CENTER, searchresult),
             ]
             list.append(res)
     self.list = list
     self.l.setList(list)
     self.moveToIndex(0)
Пример #10
0
	def buildList(self, xml):
		root = cet_fromstring(xml)
		searchlocation = ""
		searchresult = ""
		weatherlocationcode = ""
		list = []
		for childs in root:
			if childs.tag == "weather":
				searchlocation = childs.attrib.get("weatherlocationname").encode("utf-8", 'ignore')
				searchresult = childs.attrib.get("weatherfullname").encode("utf-8", 'ignore')
				weatherlocationcode = childs.attrib.get("weatherlocationcode").encode("utf-8", 'ignore')
				sz_w = getDesktop(0).size().width()
				if sz_w and sz_w == 1920:
					res = [
						(weatherlocationcode, searchlocation),
						(eListboxPythonMultiContent.TYPE_TEXT, 5, 0, 1250, 45, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, searchlocation),
						(eListboxPythonMultiContent.TYPE_TEXT, 5, 45, 1250, 40, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, searchresult),
					]
				else:
					res = [
						(weatherlocationcode, searchlocation),
						(eListboxPythonMultiContent.TYPE_TEXT, 5, 0, 1250, 35, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, searchlocation),
						(eListboxPythonMultiContent.TYPE_TEXT, 5, 35, 1250, 35, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, searchresult),
					]
				list.append(res)
		self.list = list
		self.l.setList(list)
		self.moveToIndex(0)
Пример #11
0
 def buildList(self, xml):
     if DBG: printDEBUG('MSNWeatherSearchResultList:buildList(%s)' % xml,'>>>')
     root = cet_fromstring(xml)
     searchlocation = ""
     weatherlocationcode = ""
     weatherSearchFullName = ""
     geolatitude = ""
     geolongitude = ""
     list = []
     for childs in root:
         if childs.tag == "weather":
             weatherlocationcode = childs.attrib.get("weatherlocationcode").encode("utf-8", 'ignore')
             searchlocation = childs.attrib.get("weatherlocationname").encode("utf-8", 'ignore')
             weatherSearchFullName = childs.attrib.get("weatherfullname").encode("utf-8", 'ignore')
             geolatitude = childs.attrib.get("lat").encode("utf-8", 'ignore')
             geolongitude = childs.attrib.get("long").encode("utf-8", 'ignore')
             res = [
                 (weatherlocationcode, searchlocation, weatherSearchFullName, geolatitude, geolongitude),
                 (eListboxPythonMultiContent.TYPE_TEXT, self.DimText0[0], self.DimText0[1], self.DimText0[2], self.DimText0[3], self.DimText0[4], RT_HALIGN_LEFT|RT_VALIGN_CENTER, searchlocation),
                 (eListboxPythonMultiContent.TYPE_TEXT, self.DimText1[0], self.DimText1[1], self.DimText1[2], self.DimText1[3], self.DimText1[4], RT_HALIGN_LEFT|RT_VALIGN_CENTER, '%s , (lat=%s, long=%s)' % (weatherSearchFullName, geolatitude, geolongitude)),
             ]
             list.append(res)
     self.list = list
     self.l.setList(list)
     self.moveToIndex(0)
Пример #12
0
    def buildList(self, xml):
        root = cet_fromstring(xml)
        weatherlocationname = ''
        searchresult = ''
        weatherlocationcode = ''
        list = []
        for childs in root:
            if childs.tag == 'weather':
                weatherlocationname = childs.attrib.get(
                    'weatherlocationname').encode('utf-8', 'ignore')
                searchresult = childs.attrib.get('searchresult').encode(
                    'utf-8', 'ignore')
                weatherlocationcode = childs.attrib.get(
                    'weatherlocationcode').encode('utf-8', 'ignore')
                res = [
                    (weatherlocationcode, weatherlocationname),
                    (eListboxPythonMultiContent.TYPE_TEXT, 5, 0, 500, 20, 1,
                     RT_HALIGN_LEFT | RT_VALIGN_CENTER, weatherlocationname),
                    (eListboxPythonMultiContent.TYPE_TEXT, 5, 22, 500, 20, 1,
                     RT_HALIGN_LEFT | RT_VALIGN_CENTER, searchresult)
                ]
                list.append(res)

        self.list = list
        self.l.setList(list)
        self.moveToIndex(0)
Пример #13
0
	def xmlCallback(self, xmlstring):
		self["statustext"].text = ""
		metric = 0
		index = 0
		UnitSystemText = "F"
		IconDownloadList = []
		root = cet_fromstring(xmlstring)
		for childs in root.findall("weather"):
			for items in childs:
				if items.tag == "problem_cause":
					self["statustext"].text = items.attrib.get("data").encode("utf-8", 'ignore')
				elif items.tag == "forecast_information":
					for items2 in items:
						if items2.tag == "city":
							self["caption"].text = items2.attrib.get("data").encode("utf-8", 'ignore')
						elif items2.tag == "unit_system":
							if items2.attrib.get("data").encode("utf-8", 'ignore') == "SI":
								metric = 1
								UnitSystemText = "C"
				elif items.tag == "current_conditions":
					for items2 in items:
						if items2.tag == "condition":
							self["condition"].text = _("Current: %s") % items2.attrib.get("data").encode("utf-8", 'ignore')
						elif items2.tag == "temp_f" and metric == 0:
							self["currentTemp"].text =  ("%s °F" % items2.attrib.get("data").encode("utf-8", 'ignore')) 
						elif items2.tag == "temp_c" and metric == 1:
							self["currentTemp"].text =  ("%s °C" % items2.attrib.get("data").encode("utf-8", 'ignore')) 
						elif items2.tag == "humidity":
							self["humidity"].text = items2.attrib.get("data").encode("utf-8", 'ignore')
						elif items2.tag == "wind_condition":
							self["wind_condition"].text = items2.attrib.get("data").encode("utf-8", 'ignore')
				elif items.tag == "forecast_conditions":
					index = index + 1
					lowTemp = ""
					highTemp = ""
					icon = ""
					for items2 in items:
						if items2.tag == "day_of_week":
							self["weekday%s" % index].text = items2.attrib.get("data").encode("utf-8", 'ignore')
						elif items2.tag == "low":
							lowTemp = items2.attrib.get("data").encode("utf-8", 'ignore')
						elif items2.tag == "high":
							highTemp = items2.attrib.get("data").encode("utf-8", 'ignore')
							self["weekday%s_temp" % index].text = "%s °%s | %s °%s" % (highTemp, UnitSystemText, lowTemp, UnitSystemText)
						elif items2.tag == "icon":
							url = items2.attrib.get("data").encode("utf-8", 'ignore')
							if not url.startswith("http://"):
								url = "http://www.google.com%s" % items2.attrib.get("data").encode("utf-8", 'ignore')
							parts = url.split("/")
							filename = self.appdir + parts[-1]
							if not os_path.exists(filename):
								IconDownloadList.append(WeatherIconItem(url = url,filename = filename, index = index))
							else:
								self.showIcon(index,filename)
		if len(IconDownloadList) != 0:
			ds = defer.DeferredSemaphore(tokens=len(IconDownloadList))
			downloads = [ds.run(download,item ).addErrback(self.errorIconDownload, item).addCallback(self.finishedIconDownload,item) for item in IconDownloadList]
			finished = defer.DeferredList(downloads).addErrback(self.error)
Пример #14
0
	def xmlCallback(self, xmlstring):
		self["statustext"].text = ""
		metric = 0
		index = 0
		UnitSystemText = "F"
		IconDownloadList = []
		root = cet_fromstring(xmlstring)
		for childs in root.findall("weather"):
			for items in childs:
				if items.tag == "problem_cause":
					self["statustext"].text = items.attrib.get("data").encode("utf-8", 'ignore')
				elif items.tag == "forecast_information":
					for items2 in items:
						if items2.tag == "city":
							self["caption"].text = items2.attrib.get("data").encode("utf-8", 'ignore')
						elif items2.tag == "unit_system":
							if items2.attrib.get("data").encode("utf-8", 'ignore') == "SI":
								metric = 1
								UnitSystemText = "C"
				elif items.tag == "current_conditions":
					for items2 in items:
						if items2.tag == "condition":
							self["condition"].text = _("Current: %s") % items2.attrib.get("data").encode("utf-8", 'ignore')
						elif items2.tag == "temp_f" and metric == 0:
							self["currentTemp"].text =  ("%s °F" % items2.attrib.get("data").encode("utf-8", 'ignore')) 
						elif items2.tag == "temp_c" and metric == 1:
							self["currentTemp"].text =  ("%s °C" % items2.attrib.get("data").encode("utf-8", 'ignore')) 
						elif items2.tag == "humidity":
							self["humidity"].text = items2.attrib.get("data").encode("utf-8", 'ignore')
						elif items2.tag == "wind_condition":
							self["wind_condition"].text = items2.attrib.get("data").encode("utf-8", 'ignore')
				elif items.tag == "forecast_conditions":
					index = index + 1
					lowTemp = ""
					highTemp = ""
					icon = ""
					for items2 in items:
						if items2.tag == "day_of_week":
							self["weekday%s" % index].text = items2.attrib.get("data").encode("utf-8", 'ignore')
						elif items2.tag == "low":
							lowTemp = items2.attrib.get("data").encode("utf-8", 'ignore')
						elif items2.tag == "high":
							highTemp = items2.attrib.get("data").encode("utf-8", 'ignore')
							self["weekday%s_temp" % index].text = "%s °%s | %s °%s" % (highTemp, UnitSystemText, lowTemp, UnitSystemText)
						elif items2.tag == "icon":
							url = items2.attrib.get("data").encode("utf-8", 'ignore')
							if not url.startswith("http://"):
								url = "http://www.google.com%s" % items2.attrib.get("data").encode("utf-8", 'ignore')
							parts = url.split("/")
							filename = self.appdir + parts[-1]
							if not os_path.exists(filename):
								IconDownloadList.append(WeatherIconItem(url = url,filename = filename, index = index))
							else:
								self.showIcon(index,filename)
		if len(IconDownloadList) != 0:
			ds = defer.DeferredSemaphore(tokens=len(IconDownloadList))
			downloads = [ds.run(download,item ).addErrback(self.errorIconDownload, item).addCallback(self.finishedIconDownload,item) for item in IconDownloadList]
			finished = defer.DeferredList(downloads).addErrback(self.error)
Пример #15
0
 def thingSpeakCallback(self, xmlstring):
     self.DEBUGfull('getWeather().thingSpeakCallback %s' % xmlstring)
     try:
         root = cet_fromstring(xmlstring)
         for childs in root:
             #self.DEBUG('\titem= ' ,'%s' % childs.tag)
             if childs.tag in ('name', 'description'):
                 self.thingSpeakItems[childs.tag] = childs.text
             elif childs.tag.startswith('field'):
                 #self.DEBUG('\t' ,"childs.tag.startswith('field'):")
                 tmpName = '%sName' % childs.tag
                 self.thingSpeakItems[tmpName] = childs.text
                 tmpTXT = childs.text.lower().replace(' ', '').replace(
                     '.', '').replace(',', '')
                 #self.DEBUG('\t tmpTXT = ' ,"'%s'" % tmpTXT)
                 if tmpTXT.find('pm') >= 0 and tmpTXT.find('25') >= 0:
                     #self.DEBUG('\t' ,'tmpTXT.find(pm) and tmpTXT.find(25):')
                     self.thingSpeakItems['PM2.5'] = childs.tag
                     self.thingSpeakItems['PM2.5Name'] = childs.text
                 elif tmpTXT.find('pm') >= 0 and tmpTXT.find('10') >= 0:
                     #self.DEBUG('\t' ,'tmpTXT.find(pm) and tmpTXT.find(10):')
                     self.thingSpeakItems['PM10'] = childs.tag
                     self.thingSpeakItems['PM10Name'] = childs.text
                 elif tmpTXT.find('pm') and tmpTXT.find('1'):
                     self.thingSpeakItems['PM1'] = childs.tag
                     self.thingSpeakItems['PM1Name'] = childs.text
             elif childs.tag == 'feeds':
                 for feeds in childs:
                     #self.DEBUG('\tfeeds= ' ,'%s' % feeds.tag)
                     if feeds.tag == 'feed':
                         for feed in feeds:
                             #self.DEBUG('\tfeed= ' ,'%s' % feed.tag)
                             if feed.tag == 'created-at':
                                 self.thingSpeakItems[
                                     'ObservationTime'] = feed.text
                             elif feed.tag.startswith('field'):
                                 tmpName = '%sValue' % feed.tag
                                 self.thingSpeakItems[tmpName] = feed.text
                                 if feed.tag == self.thingSpeakItems.get(
                                         'PM2.5', '?!?!?!?'):
                                     self.thingSpeakItems[
                                         'PM2.5Value'] = feed.text
                                 elif feed.tag == self.thingSpeakItems.get(
                                         'PM10', '?!?!?!?'):
                                     self.thingSpeakItems[
                                         'PM10Value'] = feed.text
                                 elif feed.tag == self.thingSpeakItems.get(
                                         'PM1', '?!?!?!?'):
                                     self.thingSpeakItems[
                                         'PM1Value'] = feed.text
     except Exception as e:
         self.thingSpeakItems = {}
         self.thingSpeakItems['name'] = 'xml error'
         self.thingSpeakItems['description'] = str(e)
         EXCEPTIONDEBUG(
             'getWeather().thingSpeakCallback EXCEPTIONDEBUG %s' % str(e))
     self.DEBUG('getWeather().thingSpeakCallback() <<<')
Пример #16
0
    def readXmlTimer(self, xml_string):
        # Parse xml string
        configuration = cet_fromstring(xml_string)

        parseConfig(configuration, self.timers, configuration.get("version"),
                    self.getUniqueId(), self.defaultTimer)

        # reset time
        self.configMtime = -1
Пример #17
0
	def gotSubscriptionList(self, res = None, defer = None):
		l = []
		if res:
			dom = cet_fromstring(res)
			for item in dom.getiterator():
				if item.tag == 'string':
					if item.get('name') == 'id' and item.text.startswith('feed/'):
						l.append(UniversalFeed(item.text[5:], True, True))
		if defer:
			defer.callback(l)
Пример #18
0
	def gotSubscriptionList(self, res = None, defer = None):
		l = []
		if res:
			dom = cet_fromstring(res)
			for item in dom.getiterator():
				if item.tag == 'string':
					if item.get('name') == 'id' and item.text.startswith('feed/'):
						l.append(UniversalFeed(item.text[5:], True, True))
		if defer:
			defer.callback(l)
Пример #19
0
	def xmlCallback(self, xmlstring):
		self["statustext"].text = ""
		IconDownloadList = []
		root = cet_fromstring(xmlstring)
		index = 0
		degreetype = "C"
		imagerelativeurl = ""
		errormessage = ""
		for childs in root:
			if childs.tag == "weather":
				errormessage = childs.attrib.get("errormessage")
				if errormessage:
					self["statustext"].text = errormessage.encode("utf-8", 'ignore')
					break
				self["caption"].text = self.weatherPluginEntry.city.value #childs.attrib.get("weatherlocationname").encode("utf-8", 'ignore')
				degreetype = childs.attrib.get("degreetype").encode("utf-8", 'ignore')
				imagerelativeurl = "%slaw/" % childs.attrib.get("imagerelativeurl").encode("utf-8", 'ignore')
				self.webSite = childs.attrib.get("url").encode("utf-8", 'ignore')
			for items in childs:
				if items.tag == "current":
					self["currentTemp"].text = "%s°%s" % (items.attrib.get("temperature").encode("utf-8", 'ignore') , degreetype)
					self["condition"].text = items.attrib.get("skytext").encode("utf-8", 'ignore')
					self["humidity"].text = _("Humidity: %s %%") % items.attrib.get("humidity").encode("utf-8", 'ignore')
					self["wind_condition"].text = items.attrib.get("winddisplay").encode("utf-8", 'ignore')
					c =  time.strptime(items.attrib.get("observationtime").encode("utf-8", 'ignore'), "%H:%M:%S")
					self["observationtime"].text = _("Observation time: %s") %  time.strftime("%H:%M",c)
					self["observationpoint"].text = _("Observation point: %s") % items.attrib.get("observationpoint").encode("utf-8", 'ignore')
					self["feelsliketemp"].text = _("Feels like %s") % items.attrib.get("feelslike").encode("utf-8", 'ignore') + "°" +  degreetype
					skycode = "%s.gif" % items.attrib.get("skycode").encode("utf-8", 'ignore')
					filename = self.appdir + skycode
					if not os_path.exists(filename):
						url = "%s%s" % (imagerelativeurl, skycode)
						IconDownloadList.append(WeatherIconItem(url = url,filename = filename, index = -1))
					else:
						self.showIcon(-1,filename)
				elif items.tag == "forecast" and index <= 4:
					index +=1
					c = time.strptime(items.attrib.get("date").encode("utf-8", 'ignore'),"%Y-%m-%d")
					self["weekday%s" % index].text = "%s\n%s" % (items.attrib.get("day").encode("utf-8", 'ignore'), time.strftime("%d. %b",c))
					lowTemp = items.attrib.get("low").encode("utf-8", 'ignore')
					highTemp = items.attrib.get("high").encode("utf-8", 'ignore')
					self["weekday%s_temp" % index].text = "%s°%s|%s°%s\n%s" % (highTemp, degreetype, lowTemp, degreetype, items.attrib.get("skytextday").encode("utf-8", 'ignore'))
					skycodeday = "%s.gif" % items.attrib.get("skycodeday").encode("utf-8", 'ignore')
					filename = self.appdir + skycodeday
					if not os_path.exists(filename):
						url = "%s%s" % (imagerelativeurl, skycodeday)
						IconDownloadList.append(WeatherIconItem(url = url,filename = filename, index = index))
					else:
						self.showIcon(index,filename)
		if len(IconDownloadList) != 0:
			ds = defer.DeferredSemaphore(tokens=len(IconDownloadList))
			downloads = [ds.run(download,item ).addErrback(self.errorIconDownload, item).addCallback(self.finishedIconDownload,item) for item in IconDownloadList]
			finished = defer.DeferredList(downloads).addErrback(self.error)
Пример #20
0
	def xmlCallback(self, xmlstring):
		if xmlstring:
			errormessage = ""
			root = cet_fromstring(xmlstring)
			for childs in root:
				if childs.tag == "weather" and childs.attrib.has_key("errormessage"):
					errormessage = childs.attrib.get("errormessage").encode("utf-8", 'ignore')
					break
			if len(errormessage) !=0:
				self.session.open(MessageBox, errormessage, MessageBox.TYPE_ERROR)					
			else:
				self.session.openWithCallback(self.searchCallback, MSNWeatherPluginSearch, xmlstring)
Пример #21
0
	def readXmlTimer(self, xml_string):
		# Parse xml string
		configuration = cet_fromstring(xml_string)
		
		parseConfig(
			configuration,
			self.timers,
			configuration.get("version"),
			self.uniqueTimerId,
			self.defaultTimer
		)
		self.uniqueTimerId += 1
		
		# reset time
		self.configMtime = -1
Пример #22
0
 def xmlCallback(self, xmlstring):
     if xmlstring:
         errormessage = ""
         root = cet_fromstring(xmlstring)
         for childs in root:
             if childs.tag == "weather" and "errormessage" in childs.attrib:
                 errormessage = six.ensure_str(
                     childs.attrib.get("errormessage"), errors='ignore')
                 break
         if len(errormessage) != 0:
             self.session.open(MessageBox, errormessage,
                               MessageBox.TYPE_ERROR)
         else:
             self.session.openWithCallback(self.searchCallback,
                                           MSNWeatherPluginSearch,
                                           xmlstring)
Пример #23
0
def search_title(id):
	url = 'http://weather.service.msn.com/find.aspx?outputview=search&weasearchstr=%s&culture=en-US&src=outlook' % id
	watchrequest = Request(url)
	try:
		watchvideopage = urlopen(watchrequest)
	except (URLError, HTTPException, socket.error) as err:
		print '[Location] Error: Unable to retrieve page - Error code: ', str(err)
	content = watchvideopage.read()
	root = cet_fromstring(content)
	search_results = []
	if content:
		for childs in root:
			if childs.tag == 'weather':
				locationcode = childs.attrib.get('weatherlocationname').encode('utf-8', 'ignore')
				search_results.append(locationcode)
	return search_results
Пример #24
0
	def readXmlTimer(self, xml_string):
		# Parse xml string
		try:
			configuration = cet_fromstring(xml_string)
		except:
			doLog("[AutoTimer] fatal error, the xml_string not read")
			return
		parseConfig(
			configuration,
			self.timers,
			configuration.get("version"),
			self.uniqueTimerId,
			self.defaultTimer
		)
		self.uniqueTimerId += 1

		# reset time
		self.configMtime = -1
Пример #25
0
	def readXmlTimer(self, xml_string):
		# Parse xml string
		try:
			configuration = cet_fromstring(xml_string)
		except:
			doLog("[AutoTimer] fatal error, the xml_string not read")
			return
		parseConfig(
			configuration,
			self.timers,
			configuration.get("version"),
			self.uniqueTimerId,
			self.defaultTimer
		)
		self.uniqueTimerId += 1

		# reset time
		self.configMtime = -1
Пример #26
0
def search_title(id):
	url = 'http://weather.service.msn.com/find.aspx?outputview=search&weasearchstr=%s&culture=en-US&src=outlook' % id
	msnrequest = Request(url)
	try:
		msnpage = urlopen(msnrequest)
	except (URLError) as err:
		print '[WeatherSettingsView] Error: Unable to retrieve page - Error code: ', str(err)
		return "error"

	content = msnpage.read()
	msnpage.close()
	root = cet_fromstring(content)
	search_results = []
	if content:
		for childs in root:
			if childs.tag == 'weather':
				locationcode = childs.attrib.get('weatherlocationname').encode('utf-8', 'ignore')
				search_results.append(locationcode)
	return search_results
Пример #27
0
def search_title(id):
	url = 'http://weather.service.msn.com/find.aspx?outputview=search&weasearchstr=%s&culture=en-US&src=outlook' % id
	msnrequest = Request(url)
	try:
		msnpage = urlopen(msnrequest)
	except (URLError) as err:
		print '[WeatherSettingsView] Error: Unable to retrieve page - Error code: ', str(err)
		return "error"

	content = msnpage.read()
	msnpage.close()
	root = cet_fromstring(content)
	search_results = []
	if content:
		for childs in root:
			if childs.tag == 'weather':
				locationcode = childs.attrib.get('weatherlocationname').encode('utf-8', 'ignore')
				search_results.append(locationcode)
	return search_results
Пример #28
0
	def update(self, suggestions):
		if suggestions and len(suggestions) > 0:
			if not self.shown:
				self.show()
			suggestions_tree = cet_fromstring( suggestions )
			if suggestions_tree:
				self.list = []
				self.suggestlist = []
				for suggestion in suggestions_tree.findall("CompleteSuggestion"):
					name = None
					for subelement in suggestion:
						if subelement.attrib.has_key('data'):
							name = subelement.attrib['data'].encode("UTF-8")
						if name:
							self.suggestlist.append(name)
				if len(self.suggestlist):
					for entry in self.suggestlist:
						self.list.append((entry, ''))
					self["suggestionslist"].setList(self.list)
					self["suggestionslist"].setIndex(0)
		else:
			self.hide()
Пример #29
0
 def update(self, suggestions):
     if suggestions and len(suggestions) > 0:
         if not self.shown:
             self.show()
         suggestions_tree = cet_fromstring(suggestions)
         if suggestions_tree:
             self.list = []
             self.suggestlist = []
             for suggestion in suggestions_tree.findall(
                     "CompleteSuggestion"):
                 name = None
                 for subelement in suggestion:
                     if subelement.attrib.has_key('data'):
                         name = subelement.attrib['data'].encode("UTF-8")
                     if name:
                         self.suggestlist.append(name)
             if len(self.suggestlist):
                 for entry in self.suggestlist:
                     self.list.append((entry, ''))
                 self["suggestionslist"].setList(self.list)
                 self["suggestionslist"].setIndex(0)
     else:
         self.hide()
Пример #30
0
	def readXml(self, **kwargs):
		if "xml_string" in kwargs:
			# reset time
			self.configMtime = -1

			# Parse Config
			configuration = cet_fromstring(kwargs["xml_string"])
		else:
			# Abort if no config found
			if not os_path.exists(XML_CONFIG):
				doLog("No configuration file present")
				return

			# Parse if mtime differs from whats saved
			mtime = os_path.getmtime(XML_CONFIG)
			if mtime == self.configMtime:
				doLog("No changes in configuration, won't parse")
				return

			# Save current mtime
			self.configMtime = mtime

			# Parse Config
			configuration = cet_parse(XML_CONFIG).getroot()

		# Empty out timers and reset Ids
		del self.timers[:]
		self.defaultTimer.clear(-1, True)

		parseConfig(
			configuration,
			self.timers,
			configuration.get("version"),
			0,
			self.defaultTimer
		)
		self.uniqueTimerId = len(self.timers)
Пример #31
0
    def xmlCallback(self, xmlstring):
        IconDownloadList = []
        root = cet_fromstring(xmlstring)
        index = 0
        self.degreetype = 'C'
        errormessage = ''
        for childs in root:
            if childs.tag == 'weather':
                errormessage = childs.attrib.get('errormessage')
                if errormessage:
                    if self.callback is not None:
                        self.callback(self.ERROR,
                                      errormessage.encode('utf-8', 'ignore'))
                    break
                self.degreetype = childs.attrib.get('degreetype').encode(
                    'utf-8', 'ignore')
                self.imagerelativeurl = '%slaw/' % childs.attrib.get(
                    'imagerelativeurl').encode('utf-8', 'ignore')
                self.url = childs.attrib.get('url').encode('utf-8', 'ignore')
            for items in childs:
                if items.tag == 'current':
                    currentWeather = MSNWeatherItem()
                    currentWeather.temperature = items.attrib.get(
                        'temperature').encode('utf-8', 'ignore')
                    currentWeather.skytext = items.attrib.get(
                        'skytext').encode('utf-8', 'ignore')
                    currentWeather.humidity = items.attrib.get(
                        'humidity').encode('utf-8', 'ignore')
                    currentWeather.winddisplay = items.attrib.get(
                        'winddisplay').encode('utf-8', 'ignore')
                    currentWeather.observationtime = items.attrib.get(
                        'observationtime').encode('utf-8', 'ignore')
                    currentWeather.observationpoint = items.attrib.get(
                        'observationpoint').encode('utf-8', 'ignore')
                    currentWeather.feelslike = items.attrib.get(
                        'feelslike').encode('utf-8', 'ignore')
                    currentWeather.skycode = '%s%s' % (
                        items.attrib.get('skycode').encode(
                            'utf-8', 'ignore'), self.iconextension)
                    currentWeather.code = items.attrib.get('skycode').encode(
                        'utf-8', 'ignore')
                    filename = '%s%s' % (self.iconpath, currentWeather.skycode)
                    currentWeather.iconFilename = filename
                    if not os_path.exists(filename):
                        url = '%s%s' % (self.imagerelativeurl,
                                        currentWeather.skycode)
                        IconDownloadList.append(
                            WeatherIconItem(url=url,
                                            filename=filename,
                                            index=-1))
                    else:
                        self.showIcon(-1, filename)
                    self.weatherItems[str(-1)] = currentWeather
                elif items.tag == 'forecast' and index <= 4:
                    index += 1
                    weather = MSNWeatherItem()
                    weather.date = items.attrib.get('date').encode(
                        'utf-8', 'ignore')
                    weather.day = items.attrib.get('day').encode(
                        'utf-8', 'ignore')
                    weather.shortday = items.attrib.get('shortday').encode(
                        'utf-8', 'ignore')
                    weather.low = items.attrib.get('low').encode(
                        'utf-8', 'ignore')
                    weather.high = items.attrib.get('high').encode(
                        'utf-8', 'ignore')
                    weather.skytextday = items.attrib.get('skytextday').encode(
                        'utf-8', 'ignore')
                    weather.skycodeday = '%s%s' % (
                        items.attrib.get('skycodeday').encode(
                            'utf-8', 'ignore'), self.iconextension)
                    weather.code = items.attrib.get('skycodeday').encode(
                        'utf-8', 'ignore')
                    filename = '%s%s' % (self.iconpath, weather.skycodeday)
                    weather.iconFilename = filename
                    weather.iconFilename = filename
                    self.weatherItems[str(index)] = weather
                    if items.attrib.get('precip').encode('utf-8',
                                                         'ignore') == '':
                        index -= 1
                    else:
                        self.showIcon(index, filename)

        if len(IconDownloadList) != 0:
            ds = defer.DeferredSemaphore(tokens=len(IconDownloadList))
            downloads = [
                ds.run(download,
                       item).addErrback(self.errorIconDownload,
                                        item).addCallback(
                                            self.finishedIconDownload, item)
                for item in IconDownloadList
            ]
            finished = defer.DeferredList(downloads).addErrback(
                self.error).addCallback(self.finishedAllDownloadFiles)
        else:
            self.finishedAllDownloadFiles(None)
        if self.callback is not None:
            self.callback(self.OK, None)
        return
Пример #32
0
    def xmlCallback(self, xmlstring):
        self['statustext'].text = ''
        IconDownloadList = []
        root = cet_fromstring(xmlstring)
        index = 0
        degreetype = 'C'
        imagerelativeurl = ''
        errormessage = ''
        for childs in root:
            if childs.tag == 'weather':
                errormessage = childs.attrib.get('errormessage')
                if errormessage:
                    self['statustext'].text = errormessage.encode(
                        'utf-8', 'ignore')
                    break
                self['CurrentCity'].text = self.weatherPluginEntry.city.value
                degreetype = childs.attrib.get('degreetype').encode(
                    'utf-8', 'ignore')
                imagerelativeurl = '%slaw/' % childs.attrib.get(
                    'imagerelativeurl').encode('utf-8', 'ignore')
                self.webSite = childs.attrib.get('url').encode(
                    'utf-8', 'ignore')
            for items in childs:
                if items.tag == 'current':
                    self['currentTemp'].text = '%s\xc2\xb0%s' % (
                        items.attrib.get('temperature').encode(
                            'utf-8', 'ignore'), degreetype)
                    self['condition'].text = items.attrib.get(
                        'skytext').encode('utf-8', 'ignore')
                    self['humidity'].text = _(
                        'Humidity: %s %%') % items.attrib.get(
                            'humidity').encode('utf-8', 'ignore')
                    self['wind_condition'].text = items.attrib.get(
                        'winddisplay').encode('utf-8', 'ignore')
                    c = time.strptime(
                        items.attrib.get('observationtime').encode(
                            'utf-8', 'ignore'), '%H:%M:%S')
                    self['observationtime'].text = _(
                        'Observation time: %s') % time.strftime('%H:%M', c)
                    self['observationpoint'].text = _(
                        'Observation point: %s') % items.attrib.get(
                            'observationpoint').encode('utf-8', 'ignore')
                    self['feelsliketemp'].text = _(
                        'Feels like %s') % items.attrib.get(
                            'feelslike').encode(
                                'utf-8', 'ignore') + '\xc2\xb0' + degreetype
                    skycode = '%s.gif' % items.attrib.get('skycode').encode(
                        'utf-8', 'ignore')
                    filename = path + 'icons/' + skycode
                    skycodepng = '%s.png' % items.attrib.get('skycode').encode(
                        'utf-8', 'ignore')
                    filenamepng = path + 'icons/' + skycodepng
                    if not pathExists(filenamepng):
                        if not pathExists(filename):
                            url = '%s%s' % (imagerelativeurl, skycode)
                            IconDownloadList.append(
                                WeatherIconItem(url=url,
                                                filename=filename,
                                                index=-1))
                    else:
                        self.showIcon(-1, filenamepng)
                elif items.tag == 'forecast' and index <= 4:
                    index += 1
                    c = time.strptime(
                        items.attrib.get('date').encode('utf-8', 'ignore'),
                        '%Y-%m-%d')
                    self['weekday%s' % index].text = '%s\n%s' % (
                        items.attrib.get('day').encode(
                            'utf-8', 'ignore'), time.strftime('%d. %b', c))
                    lowTemp = items.attrib.get('low').encode('utf-8', 'ignore')
                    highTemp = items.attrib.get('high').encode(
                        'utf-8', 'ignore')
                    self[
                        'weekday%s_temp' %
                        index].text = 'Min: %s\xc2\xb0%s \n Max: %s\xc2\xb0%s' % (
                            lowTemp, degreetype, highTemp, degreetype)
                    self['weekday%s_tempname' %
                         index].text = '%s' % items.attrib.get(
                             'skytextday').encode('utf-8', 'ignore')
                    skycodeday = '%s.gif' % items.attrib.get(
                        'skycodeday').encode('utf-8', 'ignore')
                    skycodedaypng = '%s.png' % items.attrib.get(
                        'skycodeday').encode('utf-8', 'ignore')
                    filename = self.appdir + skycodeday
                    filenamepng = self.appdir + skycodedaypng
                    if not pathExists(filenamepng):
                        if not pathExists(filename):
                            url = '%s%s' % (imagerelativeurl, skycodeday)
                            IconDownloadList.append(
                                WeatherIconItem(url=url,
                                                filename=filename,
                                                index=index))
                    else:
                        self.showIcon(index, filenamepng)

        if len(IconDownloadList) != 0:
            ds = defer.DeferredSemaphore(tokens=len(IconDownloadList))
            downloads = [
                ds.run(download,
                       item).addErrback(self.errorIconDownload,
                                        item).addCallback(
                                            self.finishedIconDownload, item)
                for item in IconDownloadList
            ]
            finished = defer.DeferredList(downloads).addErrback(self.error)
        stadt = config.plugins.mc_wi.Entry[self.weatherPluginEntryIndex -
                                           1].city.value
        stadt = stadt.split(',')[0]
        stadt = stadt.replace('\xc3\x84', 'Ae')
        stadt = stadt.replace('\xc3\xa4', 'ae')
        stadt = stadt.replace('\xc3\x96', 'Oe')
        stadt = stadt.replace('\xc3\xb6', 'oe')
        stadt = stadt.replace('\xc3\x9c', 'Ue')
        stadt = stadt.replace('\xc3\xbc', 'ue')
        stadt = stadt.replace('\xc3\x9f', 'ss')
        stadt = stadt.lower()
        if self.mvion == True:
            self.showiframe.finishStillPicture()
        bild = '/tmp/' + stadt + '.m1v'
        if fileExists(bild):
            self.showiframe.showStillpicture(bild)
            self.mvion = True
        else:
            self.mvidown(stadt)
Пример #33
0
 def xmlCallback(self, xmlstring):
     self["statustext"].text = ""
     IconDownloadList = []
     root = cet_fromstring(xmlstring)
     index = 0
     degreetype = "C"
     imagerelativeurl = ""
     errormessage = ""
     for childs in root:
         if childs.tag == "weather":
             errormessage = childs.attrib.get("errormessage")
             if errormessage:
                 self["statustext"].text = errormessage.encode(
                     "utf-8", 'ignore')
                 break
             self[
                 "caption"].text = self.weatherPluginEntry.city.value  #childs.attrib.get("weatherlocationname").encode("utf-8", 'ignore')
             degreetype = childs.attrib.get("degreetype").encode(
                 "utf-8", 'ignore')
             imagerelativeurl = "%slaw/" % childs.attrib.get(
                 "imagerelativeurl").encode("utf-8", 'ignore')
             self.webSite = childs.attrib.get("url").encode(
                 "utf-8", 'ignore')
         for items in childs:
             if items.tag == "current":
                 self["currentTemp"].text = "%s°%s" % (items.attrib.get(
                     "temperature").encode("utf-8", 'ignore'), degreetype)
                 self["condition"].text = items.attrib.get(
                     "skytext").encode("utf-8", 'ignore')
                 self["humidity"].text = _(
                     "Humidity: %s %%") % items.attrib.get(
                         "humidity").encode("utf-8", 'ignore')
                 self["wind_condition"].text = items.attrib.get(
                     "winddisplay").encode("utf-8", 'ignore')
                 c = time.strptime(
                     items.attrib.get("observationtime").encode(
                         "utf-8", 'ignore'), "%H:%M:%S")
                 self["observationtime"].text = _(
                     "Observation time: %s") % time.strftime("%H:%M", c)
                 self["observationpoint"].text = _(
                     "Observation point: %s") % items.attrib.get(
                         "observationpoint").encode("utf-8", 'ignore')
                 self["feelsliketemp"].text = _(
                     "Feels like %s") % items.attrib.get(
                         "feelslike").encode("utf-8",
                                             'ignore') + "°" + degreetype
                 skycode = "%s.gif" % items.attrib.get("skycode").encode(
                     "utf-8", 'ignore')
                 filename = self.appdir + skycode
                 if not os_path.exists(filename):
                     url = "%s%s" % (imagerelativeurl, skycode)
                     IconDownloadList.append(
                         WeatherIconItem(url=url,
                                         filename=filename,
                                         index=-1))
                 else:
                     self.showIcon(-1, filename)
             elif items.tag == "forecast" and index <= 4:
                 index += 1
                 c = time.strptime(
                     items.attrib.get("date").encode("utf-8", 'ignore'),
                     "%Y-%m-%d")
                 self["weekday%s" % index].text = "%s\n%s" % (
                     items.attrib.get("day").encode(
                         "utf-8", 'ignore'), time.strftime("%d. %b", c))
                 lowTemp = items.attrib.get("low").encode("utf-8", 'ignore')
                 highTemp = items.attrib.get("high").encode(
                     "utf-8", 'ignore')
                 self["weekday%s_temp" % index].text = "%s°%s|%s°%s\n%s" % (
                     highTemp, degreetype, lowTemp, degreetype,
                     items.attrib.get("skytextday").encode(
                         "utf-8", 'ignore'))
                 skycodeday = "%s.gif" % items.attrib.get(
                     "skycodeday").encode("utf-8", 'ignore')
                 filename = self.appdir + skycodeday
                 if not os_path.exists(filename):
                     url = "%s%s" % (imagerelativeurl, skycodeday)
                     IconDownloadList.append(
                         WeatherIconItem(url=url,
                                         filename=filename,
                                         index=index))
                 else:
                     self.showIcon(index, filename)
     if len(IconDownloadList) != 0:
         ds = defer.DeferredSemaphore(tokens=len(IconDownloadList))
         downloads = [
             ds.run(download,
                    item).addErrback(self.errorIconDownload,
                                     item).addCallback(
                                         self.finishedIconDownload, item)
             for item in IconDownloadList
         ]
         finished = defer.DeferredList(downloads).addErrback(self.error)
Пример #34
0
    def xmlCallback(self, xmlstring):
        IconDownloadList = []
        root = cet_fromstring(xmlstring)
        index = 0
        self.degreetype = 'C'
        errormessage = ''
        for childs in root:
            if childs.tag == 'weather':
                errormessage = childs.attrib.get('errormessage')
                if errormessage:
                    if self.callback is not None:
                        self.callback(self.ERROR, errormessage.encode('utf-8', 'ignore'))
                    break
                self.degreetype = childs.attrib.get('degreetype').encode('utf-8', 'ignore')
                self.imagerelativeurl = '%slaw/' % childs.attrib.get('imagerelativeurl').encode('utf-8', 'ignore')
                self.url = childs.attrib.get('url').encode('utf-8', 'ignore')
            for items in childs:
                if items.tag == 'current':
                    currentWeather = MSNWeatherItem()
                    currentWeather.temperature = items.attrib.get('temperature').encode('utf-8', 'ignore')
                    currentWeather.skytext = items.attrib.get('skytext').encode('utf-8', 'ignore')
                    currentWeather.humidity = items.attrib.get('humidity').encode('utf-8', 'ignore')
                    currentWeather.winddisplay = items.attrib.get('winddisplay').encode('utf-8', 'ignore')
                    currentWeather.observationtime = items.attrib.get('observationtime').encode('utf-8', 'ignore')
                    currentWeather.observationpoint = items.attrib.get('observationpoint').encode('utf-8', 'ignore')
                    currentWeather.feelslike = items.attrib.get('feelslike').encode('utf-8', 'ignore')
                    currentWeather.skycode = '%s%s' % (items.attrib.get('skycode').encode('utf-8', 'ignore'), self.iconextension)
                    currentWeather.code = items.attrib.get('skycode').encode('utf-8', 'ignore')
                    filename = '%s%s' % (self.iconpath, currentWeather.skycode)
                    currentWeather.iconFilename = filename
                    if not os_path.exists(filename):
                        url = '%s%s' % (self.imagerelativeurl, currentWeather.skycode)
                        IconDownloadList.append(WeatherIconItem(url=url, filename=filename, index=-1))
                    else:
                        self.showIcon(-1, filename)
                    self.weatherItems[str(-1)] = currentWeather
                elif items.tag == 'forecast' and index <= 4:
                    index += 1
                    weather = MSNWeatherItem()
                    weather.date = items.attrib.get('date').encode('utf-8', 'ignore')
                    weather.day = items.attrib.get('day').encode('utf-8', 'ignore')
                    weather.shortday = items.attrib.get('shortday').encode('utf-8', 'ignore')
                    weather.low = items.attrib.get('low').encode('utf-8', 'ignore')
                    weather.high = items.attrib.get('high').encode('utf-8', 'ignore')
                    weather.skytextday = items.attrib.get('skytextday').encode('utf-8', 'ignore')
                    weather.skycodeday = '%s%s' % (items.attrib.get('skycodeday').encode('utf-8', 'ignore'), self.iconextension)
                    weather.code = items.attrib.get('skycodeday').encode('utf-8', 'ignore')
                    filename = '%s%s' % (self.iconpath, weather.skycodeday)
                    weather.iconFilename = filename
                    weather.iconFilename = filename
                    self.weatherItems[str(index)] = weather
                    if items.attrib.get('precip').encode('utf-8', 'ignore') == '':
                        index -= 1	
                    else:
                        self.showIcon(index, filename)

        if len(IconDownloadList) != 0:
            ds = defer.DeferredSemaphore(tokens=len(IconDownloadList))
            downloads = [ ds.run(download, item).addErrback(self.errorIconDownload, item).addCallback(self.finishedIconDownload, item) for item in IconDownloadList ]
            finished = defer.DeferredList(downloads).addErrback(self.error).addCallback(self.finishedAllDownloadFiles)
        else:
            self.finishedAllDownloadFiles(None)
        if self.callback is not None:
            self.callback(self.OK, None)
        return
Пример #35
0
	def xmlCallback(self, xmlstring):
		self["statustext"].text = ""
		IconDownloadList = []
		root = cet_fromstring(xmlstring)
		index = 0
		degreetype = "C"
		imagerelativeurl = ""
		errormessage = ""
		for childs in root:
			if childs.tag == "weather":
				
				errormessage = childs.attrib.get("errormessage")
				if errormessage:
					self["statustext"].text = errormessage.encode("utf-8", 'ignore')
					break
				self["CurrentCity"].text = self.weatherPluginEntry.city.value #childs.attrib.get("weatherlocationname").encode("utf-8", 'ignore')
				degreetype = childs.attrib.get("degreetype").encode("utf-8", 'ignore')
				imagerelativeurl = "%slaw/" % childs.attrib.get("imagerelativeurl").encode("utf-8", 'ignore')
				self.webSite = childs.attrib.get("url").encode("utf-8", 'ignore')
			for items in childs:
				if items.tag == "current":
					self["currentTemp"].text = "%s°%s" % (items.attrib.get("temperature").encode("utf-8", 'ignore') , degreetype)
					self["condition"].text = items.attrib.get("skytext").encode("utf-8", 'ignore')
					self["humidity"].text = _("Humidity: %s %%") % items.attrib.get("humidity").encode("utf-8", 'ignore')
					self["wind_condition"].text = items.attrib.get("winddisplay").encode("utf-8", 'ignore')
					c =  time.strptime(items.attrib.get("observationtime").encode("utf-8", 'ignore'), "%H:%M:%S")
					self["observationtime"].text = _("Observation time: %s") %  time.strftime("%H:%M",c)
					self["observationpoint"].text = _("Observation point: %s") % items.attrib.get("observationpoint").encode("utf-8", 'ignore')
					self["feelsliketemp"].text = _("Feels like %s") % items.attrib.get("feelslike").encode("utf-8", 'ignore') + "°" +  degreetype
					skycode = "%s.gif" % items.attrib.get("skycode").encode("utf-8", 'ignore')
					filename = path +"icons/" + skycode
					skycodepng = "%s.png" % items.attrib.get("skycode").encode("utf-8", 'ignore')
					filenamepng = path +"icons/" + skycodepng
					if not pathExists(filenamepng):
						if not pathExists(filename):
							url = "%s%s" % (imagerelativeurl, skycode)
							IconDownloadList.append(WeatherIconItem(url = url,filename = filename, index = -1))
					else:
						self.showIcon(-1,filenamepng)
				elif items.tag == "forecast" and index <= 4:
					index +=1
					c = time.strptime(items.attrib.get("date").encode("utf-8", 'ignore'),"%Y-%m-%d")
					self["weekday%s" % index].text = "%s\n%s" % (items.attrib.get("day").encode("utf-8", 'ignore'), time.strftime("%d. %b",c))
					lowTemp = items.attrib.get("low").encode("utf-8", 'ignore')
					highTemp = items.attrib.get("high").encode("utf-8", 'ignore')
					self["weekday%s_temp" % index].text = "Min: %s°%s \n Max: %s°%s" % (lowTemp, degreetype, highTemp, degreetype)
					self["weekday%s_tempname" % index].text = "%s" % (items.attrib.get("skytextday").encode("utf-8", 'ignore'))
					skycodeday = "%s.gif" % items.attrib.get("skycodeday").encode("utf-8", 'ignore')
					skycodedaypng = "%s.png" % items.attrib.get("skycodeday").encode("utf-8", 'ignore')
					filename = self.appdir + skycodeday
					filenamepng = self.appdir + skycodedaypng
					if not pathExists(filenamepng):
						if not pathExists(filename):
							url = "%s%s" % (imagerelativeurl, skycodeday)
							IconDownloadList.append(WeatherIconItem(url = url,filename = filename, index = index))
					else:
						self.showIcon(index,filenamepng)
		if len(IconDownloadList) != 0:
			ds = defer.DeferredSemaphore(tokens=len(IconDownloadList))
			downloads = [ds.run(download,item ).addErrback(self.errorIconDownload, item).addCallback(self.finishedIconDownload,item) for item in IconDownloadList]
			finished = defer.DeferredList(downloads).addErrback(self.error)
		stadt = config.plugins.mc_wi.Entry[self.weatherPluginEntryIndex - 1].city.value
		stadt = stadt.split(",")[0]
		stadt = stadt.replace('Ä', 'Ae')
		stadt = stadt.replace('ä', 'ae')
		stadt = stadt.replace('Ö', 'Oe')
		stadt = stadt.replace('ö', 'oe')
		stadt = stadt.replace('Ü', 'Ue')
		stadt = stadt.replace('ü', 'ue')
		stadt = stadt.replace('ß', 'ss')
		stadt = stadt.lower()
		if self.mvion == True:
			self.showiframe.finishStillPicture()
		bild = "/tmp/"+ stadt +".m1v"
		if fileExists(bild):
			self.showiframe.showStillpicture(bild)
			self.mvion = True
		else:
			self.mvidown(stadt)
Пример #36
0
	def readXml(self, **kwargs):
		if "xml_string" in kwargs:
			# reset time
			self.configMtime = -1
			# Parse Config
			try:
				configuration = cet_fromstring(kwargs["xml_string"])
			except:
				doLog("[AutoTimer] fatal error, the xml_string not read")
				return
		else:
			# Abort if no config found
			if not os.path.exists(XML_CONFIG):
				doLog("[AutoTimer] No configuration file present")
				return

			# Parse if mtime differs from whats saved
			mtime = os.path.getmtime(XML_CONFIG)
			if mtime == self.configMtime:
				doLog("[AutoTimer] No changes in configuration, won't parse")
				return

			# Save current mtime
			self.configMtime = mtime

			# Parse Config
			try:
				configuration = cet_parse(XML_CONFIG).getroot()
			except:
				try:
					if os.path.exists(XML_CONFIG + "_old"):
						os.rename(XML_CONFIG + "_old", XML_CONFIG + "_old(1)")
					os.rename(XML_CONFIG, XML_CONFIG + "_old")
					doLog("[AutoTimer] autotimer.xml is corrupt rename file to /etc/enigma2/autotimer.xml_old")
				except:
					pass
				if Standby.inStandby is None:
					AddPopup(_("The autotimer file (/etc/enigma2/autotimer.xml) is corrupt and could not be loaded.") + "\n" + _("A new and empty config was created. A backup of the config can be found here (/etc/enigma2/autotimer.xml_old)."), type=MessageBox.TYPE_ERROR, timeout=0, id="AutoTimerLoadFailed")

				self.timers = []
				self.defaultTimer = preferredAutoTimerComponent(
					0,		# Id
					"",		# Name
					"",		# Match
					True	# Enabled
				)

				try:
					self.writeXml()
					configuration = cet_parse(XML_CONFIG).getroot()
				except:
					doLog("[AutoTimer] fatal error, the autotimer.xml cannot create")
					return

		# Empty out timers and reset Ids
		del self.timers[:]
		self.defaultTimer.clear(-1, True)

		parseConfig(
			configuration,
			self.timers,
			configuration.get("version"),
			0,
			self.defaultTimer
		)
		self.uniqueTimerId = len(self.timers)
Пример #37
0
	def readXml(self, **kwargs):
		if "xml_string" in kwargs:
			# reset time
			self.configMtime = -1
			# Parse Config
			configuration = cet_fromstring(kwargs["xml_string"])
			# TODO : check config and create backup if wrong
		else:

			# Abort if no config found
			if not os_path.exists(XML_CONFIG):
				print("[AutoTimer] No configuration file present")
				return
	
			# Parse if mtime differs from whats saved
			mtime = os_path.getmtime(XML_CONFIG)
			if mtime == self.configMtime:
				print("[AutoTimer] No changes in configuration, won't parse")
				return
	
			# Save current mtime
			self.configMtime = mtime
	
			# Parse Config
			try:
				configuration = cet_parse(XML_CONFIG).getroot()
			except:
				try:
					if os_path.exists(XML_CONFIG + "_old"):
						os_rename(XML_CONFIG + "_old", XML_CONFIG + "_old(1)")
					os_rename(XML_CONFIG, XML_CONFIG + "_old")
					print("[AutoTimer] autotimer.xml is corrupt rename file to /etc/enigma2/autotimer.xml_old")
				except:
					pass
				if Standby.inStandby is None:
					AddPopup(_("The autotimer file (/etc/enigma2/autotimer.xml) is corrupt. A new and empty config was created. A backup of the config can be found here (/etc/enigma2/autotimer.xml_old) "), type = MessageBox.TYPE_ERROR, timeout = 0, id = "AutoTimerLoadFailed")
	
				self.timers = []
				self.defaultTimer = preferredAutoTimerComponent(
					0,		# Id
					"",		# Name
					"",		# Match
					True	# Enabled
				)
	
				try:
					self.writeXml()
					configuration = cet_parse(XML_CONFIG).getroot()
				except:
					print("[AutoTimer] fatal error, the autotimer.xml cannot create")
					return

		# Empty out timers and reset Ids
		del self.timers[:]
		self.defaultTimer.clear(-1, True)

		parseConfig(
			configuration,
			self.timers,
			configuration.get("version"),
			0,
			self.defaultTimer
		)
		self.uniqueTimerId = len(self.timers)
Пример #38
0
    def xmlCallback(self, xmlstring):
        self["statustext"].text = ""
        IconDownloadList = []
        root = cet_fromstring(xmlstring)
        index = 0
        degreetype = "C"
        imagerelativeurl = ""
        errormessage = ""
        for childs in root:
            if childs.tag == "weather":

                errormessage = childs.attrib.get("errormessage")
                if errormessage:
                    self["statustext"].text = errormessage.encode(
                        "utf-8", 'ignore')
                    break
                self[
                    "CurrentCity"].text = self.weatherPluginEntry.city.value  #childs.attrib.get("weatherlocationname").encode("utf-8", 'ignore')
                degreetype = childs.attrib.get("degreetype").encode(
                    "utf-8", 'ignore')
                imagerelativeurl = "%slaw/" % childs.attrib.get(
                    "imagerelativeurl").encode("utf-8", 'ignore')
                self.webSite = childs.attrib.get("url").encode(
                    "utf-8", 'ignore')
            for items in childs:
                if items.tag == "current":
                    self["currentTemp"].text = "%s°%s" % (items.attrib.get(
                        "temperature").encode("utf-8", 'ignore'), degreetype)
                    self["condition"].text = items.attrib.get(
                        "skytext").encode("utf-8", 'ignore')
                    self["humidity"].text = _(
                        "Humidity: %s %%") % items.attrib.get(
                            "humidity").encode("utf-8", 'ignore')
                    self["wind_condition"].text = items.attrib.get(
                        "winddisplay").encode("utf-8", 'ignore')
                    c = time.strptime(
                        items.attrib.get("observationtime").encode(
                            "utf-8", 'ignore'), "%H:%M:%S")
                    self["observationtime"].text = _(
                        "Observation time: %s") % time.strftime("%H:%M", c)
                    self["observationpoint"].text = _(
                        "Observation point: %s") % items.attrib.get(
                            "observationpoint").encode("utf-8", 'ignore')
                    self["feelsliketemp"].text = _(
                        "Feels like %s") % items.attrib.get(
                            "feelslike").encode("utf-8",
                                                'ignore') + "°" + degreetype
                    skycode = "%s.gif" % items.attrib.get("skycode").encode(
                        "utf-8", 'ignore')
                    filename = path + "icons/" + skycode
                    skycodepng = "%s.png" % items.attrib.get("skycode").encode(
                        "utf-8", 'ignore')
                    filenamepng = path + "icons/" + skycodepng
                    if not pathExists(filenamepng):
                        if not pathExists(filename):
                            url = "%s%s" % (imagerelativeurl, skycode)
                            IconDownloadList.append(
                                WeatherIconItem(url=url,
                                                filename=filename,
                                                index=-1))
                    else:
                        self.showIcon(-1, filenamepng)
                elif items.tag == "forecast" and index <= 4:
                    index += 1
                    c = time.strptime(
                        items.attrib.get("date").encode("utf-8", 'ignore'),
                        "%Y-%m-%d")
                    self["weekday%s" % index].text = "%s\n%s" % (
                        items.attrib.get("day").encode(
                            "utf-8", 'ignore'), time.strftime("%d. %b", c))
                    lowTemp = items.attrib.get("low").encode("utf-8", 'ignore')
                    highTemp = items.attrib.get("high").encode(
                        "utf-8", 'ignore')
                    self["weekday%s_temp" %
                         index].text = "Min: %s°%s \n Max: %s°%s" % (
                             lowTemp, degreetype, highTemp, degreetype)
                    self["weekday%s_tempname" %
                         index].text = "%s" % (items.attrib.get(
                             "skytextday").encode("utf-8", 'ignore'))
                    skycodeday = "%s.gif" % items.attrib.get(
                        "skycodeday").encode("utf-8", 'ignore')
                    skycodedaypng = "%s.png" % items.attrib.get(
                        "skycodeday").encode("utf-8", 'ignore')
                    filename = self.appdir + skycodeday
                    filenamepng = self.appdir + skycodedaypng
                    if not pathExists(filenamepng):
                        if not pathExists(filename):
                            url = "%s%s" % (imagerelativeurl, skycodeday)
                            IconDownloadList.append(
                                WeatherIconItem(url=url,
                                                filename=filename,
                                                index=index))
                    else:
                        self.showIcon(index, filenamepng)
        if len(IconDownloadList) != 0:
            ds = defer.DeferredSemaphore(tokens=len(IconDownloadList))
            downloads = [
                ds.run(download,
                       item).addErrback(self.errorIconDownload,
                                        item).addCallback(
                                            self.finishedIconDownload, item)
                for item in IconDownloadList
            ]
            finished = defer.DeferredList(downloads).addErrback(self.error)
        stadt = config.plugins.mc_wi.Entry[self.weatherPluginEntryIndex -
                                           1].city.value
        stadt = stadt.split(",")[0]
        stadt = stadt.replace('Ä', 'Ae')
        stadt = stadt.replace('ä', 'ae')
        stadt = stadt.replace('Ö', 'Oe')
        stadt = stadt.replace('ö', 'oe')
        stadt = stadt.replace('Ü', 'Ue')
        stadt = stadt.replace('ü', 'ue')
        stadt = stadt.replace('ß', 'ss')
        stadt = stadt.lower()
        if self.mvion == True:
            self.showiframe.finishStillPicture()
        bild = "/tmp/" + stadt + ".m1v"
        if fileExists(bild):
            self.showiframe.showStillpicture(bild)
            self.mvion = True
        else:
            self.mvidown(stadt)
Пример #39
0
    def xmlCallback(self, xmlstring):
        IconDownloadList = []
        root = cet_fromstring(xmlstring)
        index = 0
        self.degreetype = "C"
        errormessage = ""
        for childs in root:
            if childs.tag == "weather":
                errormessage = childs.attrib.get("errormessage")
                if errormessage:
                    if self.callback is not None:
                        self.callback(self.ERROR,
                                      errormessage.encode("utf-8", 'ignore'))
                    break
                self.degreetype = childs.attrib.get("degreetype").encode(
                    "utf-8", 'ignore')
                self.imagerelativeurl = "%slaw/" % childs.attrib.get(
                    "imagerelativeurl").encode("utf-8", 'ignore')
                self.url = childs.attrib.get("url").encode("utf-8", 'ignore')
            for items in childs:
                if items.tag == "current":
                    currentWeather = MSNWeatherItem()
                    currentWeather.temperature = items.attrib.get(
                        "temperature").encode("utf-8", 'ignore')
                    currentWeather.skytext = items.attrib.get(
                        "skytext").encode("utf-8", 'ignore')
                    currentWeather.humidity = items.attrib.get(
                        "humidity").encode("utf-8", 'ignore')
                    currentWeather.winddisplay = items.attrib.get(
                        "winddisplay").encode("utf-8", 'ignore')
                    currentWeather.observationtime = items.attrib.get(
                        "observationtime").encode("utf-8", 'ignore')
                    currentWeather.observationpoint = items.attrib.get(
                        "observationpoint").encode("utf-8", 'ignore')
                    currentWeather.feelslike = items.attrib.get(
                        "feelslike").encode("utf-8", 'ignore')
                    currentWeather.skycode = "%s%s" % (
                        items.attrib.get("skycode").encode(
                            "utf-8", 'ignore'), self.iconextension)
                    currentWeather.code = items.attrib.get("skycode").encode(
                        "utf-8", 'ignore')
                    filename = "%s%s" % (self.iconpath, currentWeather.skycode)
                    currentWeather.iconFilename = filename
                    if not os_path.exists(filename):
                        url = "%s%s" % (self.imagerelativeurl,
                                        currentWeather.skycode)
                        IconDownloadList.append(
                            WeatherIconItem(url=url,
                                            filename=filename,
                                            index=-1))
                    else:
                        self.showIcon(-1, filename)
                    self.weatherItems[str(-1)] = currentWeather
                elif items.tag == "forecast" and index <= 4:
                    index += 1
                    weather = MSNWeatherItem()
                    weather.date = items.attrib.get("date").encode(
                        "utf-8", 'ignore')
                    weather.day = items.attrib.get("day").encode(
                        "utf-8", 'ignore')
                    weather.shortday = items.attrib.get("shortday").encode(
                        "utf-8", 'ignore')
                    weather.low = items.attrib.get("low").encode(
                        "utf-8", 'ignore')
                    weather.high = items.attrib.get("high").encode(
                        "utf-8", 'ignore')
                    weather.skytextday = items.attrib.get("skytextday").encode(
                        "utf-8", 'ignore')
                    weather.skycodeday = "%s%s" % (
                        items.attrib.get("skycodeday").encode(
                            "utf-8", 'ignore'), self.iconextension)
                    weather.code = items.attrib.get("skycodeday").encode(
                        "utf-8", 'ignore')
                    filename = "%s%s" % (self.iconpath, weather.skycodeday)
                    weather.iconFilename = filename
                    if not os_path.exists(filename):
                        url = "%s%s" % (self.imagerelativeurl,
                                        weather.skycodeday)
                        IconDownloadList.append(
                            WeatherIconItem(url=url,
                                            filename=filename,
                                            index=index))
                    else:
                        self.showIcon(index, filename)
                    self.weatherItems[str(index)] = weather

        if len(IconDownloadList) != 0:
            ds = defer.DeferredSemaphore(tokens=len(IconDownloadList))
            downloads = [
                ds.run(download,
                       item).addErrback(self.errorIconDownload,
                                        item).addCallback(
                                            self.finishedIconDownload, item)
                for item in IconDownloadList
            ]
            finished = defer.DeferredList(downloads).addErrback(
                self.error).addCallback(self.finishedAllDownloadFiles)
        else:
            self.finishedAllDownloadFiles(None)

        if self.callback is not None:
            self.callback(self.OK, None)
Пример #40
0
 def xmlCallback(self, xmlstring):
     self.DEBUGfull('getWeather().xmlCallback(%s)' %
                    xmlstring.replace('/><', '/>\n<'))
     IconDownloadList = []
     root = cet_fromstring(xmlstring)
     index = 0
     self.degreetype = 'C'
     errormessage = ''
     for childs in root:
         if childs.tag == 'weather':
             errormessage = childs.attrib.get('errormessage')
             if errormessage:
                 if self.callback is not None:
                     self.callback(self.ERROR,
                                   errormessage.encode('utf-8', 'ignore'))
                 break
             self.degreetype = childs.attrib.get('degreetype').encode(
                 'utf-8', 'ignore')
             self.imagerelativeurl = '%slaw/' % childs.attrib.get(
                 'imagerelativeurl').encode('utf-8', 'ignore')
             self.url = childs.attrib.get('url').encode('utf-8', 'ignore')
         for items in childs:
             if items.tag == 'current':
                 currentWeather = MSNWeatherItem()
                 currentWeather.temperature = items.attrib.get(
                     'temperature').encode('utf-8', 'ignore')
                 currentWeather.skytext = items.attrib.get(
                     'skytext').encode('utf-8', 'ignore')
                 currentWeather.humidity = items.attrib.get(
                     'humidity').encode('utf-8', 'ignore')
                 currentWeather.winddisplay = items.attrib.get(
                     'winddisplay').encode('utf-8', 'ignore')
                 currentWeather.observationtime = items.attrib.get(
                     'observationtime').encode('utf-8', 'ignore')
                 currentWeather.observationpoint = items.attrib.get(
                     'observationpoint').encode('utf-8', 'ignore')
                 currentWeather.feelslike = items.attrib.get(
                     'feelslike').encode('utf-8', 'ignore')
                 currentWeather.skycode = '%s%s' % (
                     items.attrib.get('skycode').encode(
                         'utf-8', 'ignore'), self.iconextension)
                 currentWeather.code = items.attrib.get('skycode').encode(
                     'utf-8', 'ignore')
                 filename = '%s%s' % (self.iconpath, currentWeather.skycode)
                 currentWeather.iconFilename = filename
                 self.DEBUG(
                     'MSNWeather().xmlCallback() current: temp=%s, humidity=%s, wind=%s'
                     % (currentWeather.temperature, currentWeather.humidity,
                        currentWeather.winddisplay))
                 if not os_path.exists(filename):
                     url = '%s%s' % (self.imagerelativeurl,
                                     currentWeather.skycode)
                     IconDownloadList.append(
                         WeatherIconItem(url=url,
                                         filename=filename,
                                         index=-1))
                 else:
                     self.showIcon(-1, filename)
                 self.weatherItems[str(-1)] = currentWeather
     #pobierz obecne dane o burzach
     motionBurze()
     if len(IconDownloadList) != 0:
         ds = defer.DeferredSemaphore(tokens=len(IconDownloadList))
         downloads = [
             ds.run(download,
                    item).addErrback(self.errorIconDownload,
                                     item).addCallback(
                                         self.finishedIconDownload, item)
             for item in IconDownloadList
         ]
         finished = defer.DeferredList(downloads).addErrback(
             self.xmlError).addCallback(self.finishedAllDownloadFiles)
     else:
         self.finishedAllDownloadFiles(None)
     self.DEBUG('getWeather().xmlCallback() <<<')
     getPage(self.urlWeb).addCallback(self.webCallback).addErrback(
         self.webError)
     return
Пример #41
0
	def xmlCallback(self, xmlstring):
		IconDownloadList = []
		root = cet_fromstring(xmlstring)
		index = 0
		self.degreetype = "C"
		errormessage = ""
		for childs in root:
			if childs.tag == "weather":
				errormessage = childs.attrib.get("errormessage")
				if errormessage:
					if self.callback is not None:
						self.callback(self.ERROR, errormessage.encode("utf-8", 'ignore'))
					break
				self.degreetype = childs.attrib.get("degreetype").encode("utf-8", 'ignore')
				self.imagerelativeurl = "%slaw/" % childs.attrib.get("imagerelativeurl").encode("utf-8", 'ignore')
				self.url = childs.attrib.get("url").encode("utf-8", 'ignore')
			for items in childs:
				if items.tag == "current":
					currentWeather = MSNWeatherItem()
					currentWeather.temperature = items.attrib.get("temperature").encode("utf-8", 'ignore')
					currentWeather.skytext = items.attrib.get("skytext").encode("utf-8", 'ignore')
					currentWeather.humidity = items.attrib.get("humidity").encode("utf-8", 'ignore')
					currentWeather.winddisplay = items.attrib.get("winddisplay").encode("utf-8", 'ignore')
					currentWeather.observationtime = items.attrib.get("observationtime").encode("utf-8", 'ignore')
					currentWeather.observationpoint = items.attrib.get("observationpoint").encode("utf-8", 'ignore')
					currentWeather.feelslike = items.attrib.get("feelslike").encode("utf-8", 'ignore')
					currentWeather.skycode = "%s%s" % (items.attrib.get("skycode").encode("utf-8", 'ignore'), self.iconextension)
					currentWeather.code = items.attrib.get("skycode").encode("utf-8", 'ignore')
					filename = "%s%s"  % (self.iconpath, currentWeather.skycode)
					currentWeather.iconFilename = filename
					if not os_path.exists(filename):
						url = "%s%s" % (self.imagerelativeurl, currentWeather.skycode)
						IconDownloadList.append(WeatherIconItem(url = url,filename = filename, index = -1))
					else:
						self.showIcon(-1,filename)
					self.weatherItems[str(-1)] = currentWeather
				elif items.tag == "forecast" and index <= 4:
					index +=1
					weather = MSNWeatherItem()
					weather.date = items.attrib.get("date").encode("utf-8", 'ignore')
					weather.day = items.attrib.get("day").encode("utf-8", 'ignore')
					weather.shortday = items.attrib.get("shortday").encode("utf-8", 'ignore')
					weather.low = items.attrib.get("low").encode("utf-8", 'ignore')
					weather.high = items.attrib.get("high").encode("utf-8", 'ignore')
					weather.skytextday = items.attrib.get("skytextday").encode("utf-8", 'ignore')
					weather.skycodeday = "%s%s" % (items.attrib.get("skycodeday").encode("utf-8", 'ignore'), self.iconextension)
					weather.code = items.attrib.get("skycodeday").encode("utf-8", 'ignore')
					filename = "%s%s"  % (self.iconpath, weather.skycodeday)
					weather.iconFilename = filename
					if not os_path.exists(filename):
						url = "%s%s" % (self.imagerelativeurl, weather.skycodeday)
						IconDownloadList.append(WeatherIconItem(url = url,filename = filename, index = index))
					else:
						self.showIcon(index,filename)
					self.weatherItems[str(index)] = weather
		
		if len(IconDownloadList) != 0:
			ds = defer.DeferredSemaphore(tokens=len(IconDownloadList))
			downloads = [ds.run(download,item ).addErrback(self.errorIconDownload, item).addCallback(self.finishedIconDownload,item) for item in IconDownloadList]
			finished = defer.DeferredList(downloads).addErrback(self.error).addCallback(self.finishedAllDownloadFiles)
		else:
			self.finishedAllDownloadFiles(None)
			
		if self.callback is not None:
			self.callback(self.OK, None)