Ejemplo n.º 1
0
 def runanim1(self, pic1, pic2):
     self.slide = 2
     self.steps = 9
     self.pics = []
     self.pics.append(loadPic(pic1, self.piconWidth, self.piconHeight, 0, 0, 0, 1))
     self.pics.append(loadPic(pic2, self.piconWidth, self.piconHeight, 0, 0, 0, 1))
     self.timerpicsPS1.start(100, True)
 def runanim2(self, pic1, pic2):
     size = self.instance.size()
     self.slide2 = 2
     self.pics2 = []
     self.pics2.append(
         loadPic(pic1, size.width(), size.height(), 0, 0, 0, 1))
     self.pics2.append(
         loadPic(pic2, size.width(), size.height(), 0, 0, 0, 1))
     self.timerpics2.start(100, True)
Ejemplo n.º 3
0
 def runanim1(self, pic1, pic2):
     self.slide = 2
     self.steps = 9
     self.pics = []
     self.pics.append(
         loadPic(pic1, self.piconWidth, self.piconHeight, 0, 0, 0, 1))
     self.pics.append(
         loadPic(pic2, self.piconWidth, self.piconHeight, 0, 0, 0, 1))
     self.timerpicsPS1.start(100, True)
 def runanim(self, pic1, pic2, pic3, pic4):
     size = self.instance.size()
     self.slide = 4
     self.pics = []
     self.pics.append(loadPic(pic1, size.width(), size.height(), 0, 0, 0,
                              1))
     self.pics.append(loadPic(pic2, size.width(), size.height(), 0, 0, 0,
                              1))
     self.pics.append(loadPic(pic3, size.width(), size.height(), 0, 0, 0,
                              1))
     self.pics.append(loadPic(pic4, size.width(), size.height(), 0, 0, 0,
                              1))
     self.timerpics.start(100, True)
Ejemplo n.º 5
0
    def Cover(self):
        try:
            self.Loop.stop()
        except:
            pass

        try:
            png = loadPic(str(self.getCurrentConfigPath()), self.SizeY, self.SizeX, 0, 0, 0, 1)
            self['cover'].instance.setPixmap(png)
            self['cover'].show()
        except:
            pass
Ejemplo n.º 6
0
Archivo: plugin.py Proyecto: aassww/xta
    def Cover(self):
        try:
            self.Loop.stop()
        except:
            pass

        try:
            png = loadPic(str(self.getCurrentConfigPath()), self.SizeY, self.SizeX, 0, 0, 0, 1)
            self['cover'].instance.setPixmap(png)
            self['cover'].show()
        except:
            pass
Ejemplo n.º 7
0
	def runAnim(self):
		txt=[]
		text = ""
		if len(self.pics) == 0:
			for x in self.pixmaps:
				self.pics.append(loadPic(resolveFilename(SCOPE_SKIN_IMAGE, x), int(self.size[0]), int(self.size[1]), 0, 0, 0, 1))
			self.slide = len(self.pics)
			self.timer = eTimer()
			self.timer.callback.append(self.timerEvent)
			self.timer.start(self.pixdelay, True)
		else:
			self.instance.setPixmap(self.png)
Ejemplo n.º 8
0
	def changed(self, what):
		if self.instance:
			pngname = ''
			if (what[0] != self.CHANGED_CLEAR):
				sname = self.source.text
				pngname = self.nameCache.get(sname, '')
				if (pngname == ''):
					pngname = self.findPicon(sname)
					if (pngname != ''):
						self.nameCache[sname] = pngname
			if (pngname == ''):
				pngname = self.nameCache.get('default', '')
				if (pngname == ''):
                                        pngname = self.findPicon('picon_default')
                                        if (pngname == ''):
					    tmp = '/usr/lib/enigma2/python/Plugins/Extensions/TMBD/picon_default_big.png'
					    if fileExists(tmp):
						    pngname = tmp
					    self.nameCache['default'] = pngname
			if (self.pngname != pngname):
				self.pngname = pngname
				png = loadPic(self.pngname, int(self.size[0]), int(self.size[1]), 0, 0, 0, 1)
				self.instance.setPixmap(png)
Ejemplo n.º 9
0
 def runAnim(self):
     txt = []
     text = ""
     IMAGE_PATH2 = resolveFilename(SCOPE_CURRENT_SKIN, 'Movieanim')
     path2 = resolveFilename(SCOPE_SKIN_IMAGE, IMAGE_PATH2)
     if fileExists(path2):
         l = os.listdir(path2)
         for x in l:
             x = os.path.join(path2, x)
             txt.append(x)
         text = ','.join(txt)
         self.pixmaps = text.split(',')
         if len(self.pics) == 0:
             for x in self.pixmaps:
                 self.pics.append(
                     loadPic(resolveFilename(SCOPE_SKIN_IMAGE, x),
                             int(self.size[0]), int(self.size[1]), 0, 0, 0,
                             1))
         self.slide = len(self.pics)
         self.timer = eTimer()
         self.timer.callback.append(self.timerEvent)
         self.timer.start(self.pixdelay, True)
     else:
         self.instance.setPixmap(self.png)
Ejemplo n.º 10
0
 def addonsconn(self):
     myicon = '/tmp/' + self.fileP
     png = loadPic(myicon, 1280, 720, 0, 0, 0, 1)
     self['lab1'].instance.setPixmap(png)
     os_remove(myicon)
Ejemplo n.º 11
0
    def updateInfo(self):
        myurl = self.get_Url()
        req = Request(myurl)
        try:
            handler = urlopen(req)
        except HTTPError as e:
            maintext = 'Error: connection failed !'
        except URLError as e:
            maintext = 'Error: Page not available !'
        else:
            dom = minidom.parse(handler)
            handler.close()
            maintext = ''
            tmptext = ''
            if dom:
                weather_data = {}
                weather_data['title'] = dom.getElementsByTagName('title')[0].firstChild.data
                txt = str(weather_data['title'])
                if txt.find('Error') != -1 or self.bhv < 2:
                    self['lab1'].setText(_('Sorry, wrong WOEID'))
                    return
                ns_data_structure = {'location': ('city', 'region', 'country'),
                 'units': ('temperature', 'distance', 'pressure', 'speed'),
                 'wind': ('chill', 'direction', 'speed'),
                 'atmosphere': ('humidity', 'visibility', 'pressure', 'rising'),
                 'astronomy': ('sunrise', 'sunset'),
                 'condition': ('text', 'code', 'temp', 'date')}
                for tag, attrs in ns_data_structure.items():
                    weather_data[tag] = self.xml_get_ns_yahoo_tag(dom, 'http://xml.weather.yahoo.com/ns/rss/1.0', tag, attrs)

                weather_data['geo'] = {}
                weather_data['geo']['lat'] = dom.getElementsByTagName('geo:lat')[0].firstChild.data
                weather_data['geo']['long'] = dom.getElementsByTagName('geo:long')[0].firstChild.data
                weather_data['condition']['title'] = dom.getElementsByTagName('item')[0].getElementsByTagName('title')[0].firstChild.data
                weather_data['html_description'] = dom.getElementsByTagName('item')[0].getElementsByTagName('description')[0].firstChild.data
                forecasts = []
                for forecast in dom.getElementsByTagNameNS('http://xml.weather.yahoo.com/ns/rss/1.0', 'forecast'):
                    forecasts.append(self.xml_get_attrs(forecast, ('day', 'date', 'low', 'high', 'text', 'code')))

                weather_data['forecasts'] = forecasts
                dom.unlink()
                maintext = 'Data provider: '
                self['lab1b'].setText(_('Yahoo Weather'))
                city = '%s' % str(weather_data['location']['city'])
                self['lab2'].setText(city)
                txt = str(weather_data['condition']['date'])
                parts = txt.strip().split(' ')
                txt = _('Last Updated:') + ' %s %s %s %s %s' % (parts[1],
                 parts[2],
                 parts[3],
                 parts[4],
                 parts[5])
                self['lab3'].setText(txt)
                txt = str(weather_data['condition']['temp'])
                self['lab4'].setText(txt)
                self['lab4b'].setText('\xc2\xb0C')
                icon = '/usr/lib/enigma2/python/Plugins/Extensions/YahooWeather/Icon/%s.png' % str(weather_data['condition']['code'])
                myicon = self.checkIcon(icon)
                #png = loadPic(myicon, 220, 195, 0, 0, 0, 0)
                png = loadPic(myicon, 219, 160, 0, 0, 0, 0)
                self['lab5'].instance.setPixmap(png)
                #txt = str(weather_data['condition']['text'])
                txt = self.extend_name(str(weather_data['condition']['text']))
                self['lab6'].setText(txt)
                self['lab7'].setText(_('Humidity   :'))
                txt = str(weather_data['atmosphere']['humidity']) + ' %'
                self['lab7b'].setText(txt)
                self['lab8'].setText(_('Pressure   :'))
                txt = str(weather_data['atmosphere']['pressure']) + ' mb'
                self['lab8b'].setText(txt)
                self['lab9'].setText(_('Visibility :'))
                txt = str(weather_data['atmosphere']['visibility']) + ' km'
                self['lab9b'].setText(txt)
                self['lab10'].setText(_('Sunrise    :'))
                txt = str(weather_data['astronomy']['sunrise'])
                self['lab10b'].setText(txt)
                self['lab11'].setText(_('Sunset     :'))
                txt = str(weather_data['astronomy']['sunset'])
                self['lab11b'].setText(txt)
                self['lab12'].setText(_('Wind       :'))
                direction = self.wind_direction(str(weather_data['wind']['direction']))
                txt = _('Wind') + ' ' + _('From') + ' %s : %s kmh' % (direction, str(weather_data['wind']['speed']))
                self['lab12b'].setText(txt)
                txt = self.extend_day(str(weather_data['forecasts'][0]['day']))
                self['lab13'].setText(txt)
                self['lab14'].setText(_('Max :'))
                txt = str(weather_data['forecasts'][0]['high']) + '\xc2\xb0C'
                self['lab14b'].setText(txt)
                self['lab15'].setText(_('Min :'))
                txt = str(weather_data['forecasts'][0]['low']) + '\xc2\xb0C'
                self['lab15b'].setText(txt)
                txt = self.extend_name(str(weather_data['forecasts'][0]['text']))
                self['lab16'].setText(txt)
                txt = str(weather_data['forecasts'][0]['date'])
                self['daydate0'].setText(txt)
                icon = '/usr/lib/enigma2/python/Plugins/Extensions/YahooWeather/Icon/%s.png' % str(weather_data['forecasts'][0]['code'])
                myicon = self.checkIcon(icon)
                #png = loadPic(myicon, 81, 72, 0, 0, 0, 0)
                png = loadPic(myicon, 81, 59, 0, 0, 0, 0)
                self['lab17'].instance.setPixmap(png)
                txt = self.extend_day(str(weather_data['forecasts'][1]['day']))
                self['lab18'].setText(txt)
                self['lab19'].setText(_('Max :'))
                txt = str(weather_data['forecasts'][1]['high']) + '\xc2\xb0C'
                self['lab19b'].setText(txt)
                self['lab20'].setText(_('Min :'))
                txt = str(weather_data['forecasts'][1]['low']) + '\xc2\xb0C'
                self['lab20b'].setText(txt)
                txt = self.extend_name(str(weather_data['forecasts'][1]['text']))
                self['lab21'].setText(txt)
                txt = str(weather_data['forecasts'][1]['date'])
                self['daydate1'].setText(txt)
                icon = '/usr/lib/enigma2/python/Plugins/Extensions/YahooWeather/Icon/%s.png' % str(weather_data['forecasts'][1]['code'])
                myicon = self.checkIcon(icon)
                png = loadPic(myicon, 81, 59, 0, 0, 0, 0)
                self['lab22'].instance.setPixmap(png)
                ####################test day3######################
                txt = self.extend_day(str(weather_data['forecasts'][2]['day']))
                self['3lab18'].setText(txt)
                self['3lab19'].setText(_('Max :'))
                txt = str(weather_data['forecasts'][2]['high']) + '\xc2\xb0C'
                self['3lab19b'].setText(txt)
                self['3lab20'].setText(_('Min :'))
                txt = str(weather_data['forecasts'][2]['low']) + '\xc2\xb0C'
                self['3lab20b'].setText(txt)
                txt = self.extend_name(str(weather_data['forecasts'][2]['text']))
                self['3lab21'].setText(txt)
                txt = str(weather_data['forecasts'][2]['date'])
                self['daydate2'].setText(txt)
                icon = '/usr/lib/enigma2/python/Plugins/Extensions/YahooWeather/Icon/%s.png' % str(weather_data['forecasts'][2]['code'])
                myicon = self.checkIcon(icon)
                png = loadPic(myicon, 81, 59, 0, 0, 0, 0)
                self['3lab22'].instance.setPixmap(png)
                ####################test day4######################
                txt = self.extend_day(str(weather_data['forecasts'][3]['day']))
                self['4lab18'].setText(txt)
                self['4lab19'].setText(_('Max :'))
                txt = str(weather_data['forecasts'][3]['high']) + '\xc2\xb0C'
                self['4lab19b'].setText(txt)
                self['4lab20'].setText(_('Min :'))
                txt = str(weather_data['forecasts'][3]['low']) + '\xc2\xb0C'
                self['4lab20b'].setText(txt)
                txt = self.extend_name(str(weather_data['forecasts'][3]['text']))
                self['4lab21'].setText(txt)
                txt = str(weather_data['forecasts'][3]['date'])
                self['daydate3'].setText(txt)
                icon = '/usr/lib/enigma2/python/Plugins/Extensions/YahooWeather/Icon/%s.png' % str(weather_data['forecasts'][3]['code'])
                myicon = self.checkIcon(icon)
                png = loadPic(myicon, 81, 59, 0, 0, 0, 0)
                self['4lab22'].instance.setPixmap(png)
                ####################test day5######################
                txt = self.extend_day(str(weather_data['forecasts'][4]['day']))
                self['5lab18'].setText(txt)
                self['5lab19'].setText(_('Max :'))
                txt = str(weather_data['forecasts'][4]['high']) + '\xc2\xb0C'
                self['5lab19b'].setText(txt)
                self['5lab20'].setText(_('Min :'))
                txt = str(weather_data['forecasts'][4]['low']) + '\xc2\xb0C'
                self['5lab20b'].setText(txt)
                txt = self.extend_name(str(weather_data['forecasts'][4]['text']))
                self['5lab21'].setText(txt)
                txt = str(weather_data['forecasts'][4]['date'])
                self['daydate4'].setText(txt)
                icon = '/usr/lib/enigma2/python/Plugins/Extensions/YahooWeather/Icon/%s.png' % str(weather_data['forecasts'][4]['code'])
                myicon = self.checkIcon(icon)
                png = loadPic(myicon, 81, 59, 0, 0, 0, 0)
                self['5lab22'].instance.setPixmap(png)
                ###################################################
                self['lab23'].setText(city)
                self['lab24'].setText(_('Latitude :'))
                txt = str(weather_data['geo']['lat']) + '\xc2\xb0'
                self['lab24b'].setText(txt)
                self['lab25'].setText(_('Longitude :'))
                txt = str(weather_data['geo']['long']) + '\xc2\xb0'
                self['lab25b'].setText(txt)
                self['lab26'].setText(_('Region    :'))
                txt = str(weather_data['location']['region'])
                self['lab26b'].setText(txt)
                txt = str(weather_data['location']['country'])
                self['lab27'].setText(_('Country   :') + ' ' + (txt))
                myicon = '/usr/lib/enigma2/python/Plugins/Extensions/YahooWeather/Skin/1color.png'
                png = loadPic(myicon, 250, 30, 0, 0, 0, 0)
                self['lab28'].instance.setPixmap(png)
                self['lab28a'].setText(':')

                #check current day#
        #        checkday = (str(weather_data['forecasts'][0]['day']))
        #        currentday = strftime("%a")

        #        if not currentday == checkday:
        #        	return self.startConnection()

            else:
                maintext = 'Error getting XML document!'

        self['lab1'].setText(maintext)
Ejemplo n.º 12
0
	def addonsconn(self):
		myicon = "/tmp/" + self.fileP
		png = loadPic(myicon, 1280, 720, 0, 0, 0, 1)
		self["lab1"].instance.setPixmap(png)
		os_remove(myicon)
Ejemplo n.º 13
0
        				for tag in forecast_conditions:
            					tmp_forecast[tag] = forecast.getElementsByTagName(tag)[0].getAttribute('data')
        				forecasts.append(tmp_forecast)

    				weather_data['forecasts'] = forecasts
    				dom.unlink()
				
				maintext = "Il tempo di oggi a " + str(weather_data['forecast_information']['postal_code'])
				mytime =  str(weather_data['forecast_information']['current_date_time'])
				parts = mytime.strip().split(" ")
				mytime = parts[1]
				self["lab2"].setText("Condizioni del tempo aggiornate alle ore " + mytime)
				
				myicon = self.checkIcon(str(weather_data['current_conditions']['icon']))
# Damn'ed Google gifs .... (we cannot use loadPixmap)			
				png = loadPic(myicon, 40, 40, 0, 0, 0, 1)
				self["lab3"].instance.setPixmap(png)
				
				self["lab4"].setText(self.fixSlang(str(weather_data['current_conditions']['condition'])))
				
				tmptext = "Temperatura: " + str(weather_data['current_conditions']['temp_c']) + " gradi Celsius\n" + str(weather_data['current_conditions']['humidity']) + "   " + str(weather_data['current_conditions']['wind_condition'])
				self["lab5"].setText(tmptext)
				
				tmptext = "Previsioni " + self.eXtendedDay(str(weather_data['forecasts'][1]['day_of_week']))
				self["lab6"].setText(tmptext)
				
				myicon = self.checkIcon(str(weather_data['forecasts'][1]['icon']))
				png = loadPic(myicon, 40, 40, 0, 0, 0, 1)
				self["lab7"].instance.setPixmap(png)
				
				tmptext = self.fixSlang(str(weather_data['forecasts'][1]['condition'])) + "\nTemp. minima: " + str(weather_data['forecasts'][1]['low']) + "\nTemp. massima: " + str(weather_data['forecasts'][1]['high'])
Ejemplo n.º 14
0
                weather_data['forecasts'] = forecasts
                dom.unlink()

                maintext = "Tempo para hoje " + str(
                    weather_data['forecast_information']['postal_code'])
                mytime = str(
                    weather_data['forecast_information']['current_date_time'])
                parts = mytime.strip().split(" ")
                mytime = parts[1]
                self["lab2"].setText("Atuais condicoes do tempo em " + mytime)

                myicon = self.checkIcon(
                    str(weather_data['current_conditions']['icon']))
                # Damn'ed Google gifs .... (we cannot use loadPixmap)
                png = loadPic(myicon, 40, 40, 0, 0, 0, 1)
                self["lab3"].instance.setPixmap(png)

                self["lab4"].setText(
                    self.fixSlang(
                        str(weather_data['current_conditions']['condition'])))

                tmptext = "Temperatura: " + str(
                    weather_data['current_conditions']
                    ['temp_c']) + " graus Celsius\n" + str(
                        weather_data['current_conditions']['humidity']
                    ) + "   " + str(
                        weather_data['current_conditions']['wind_condition'])
                self["lab5"].setText(tmptext)

                tmptext = "Previsao " + self.eXtendedDay(
Ejemplo n.º 15
0
 def onImageLoaded(self, dummy):
     self.currPic = loadPic(self.tmpfile, self.width, self.height, 0, 1, 0,
                            1)
     os_remove(self.tmpfile)
     self.callBack(pixmap=self.currPic)
Ejemplo n.º 16
0
    def updateInfo(self):
        myurl = self.get_Url()
        req = Request(myurl)
        try:
            handler = urlopen(req)
        except HTTPError as e:
            maintext = 'Error: connection failed !'
        except URLError as e:
            maintext = 'Error: Page not available !'
        else:
            dom = minidom.parse(handler)
            handler.close()
            maintext = ''
            tmptext = ''
            if dom:
                weather_data = {}
                weather_data['title'] = dom.getElementsByTagName(
                    'title')[0].firstChild.data
                txt = str(weather_data['title'])
                if txt.find('Error') != -1:
                    self['lab1'].setText('Sorry, wrong WOEID')
                    return
                ns_data_structure = {
                    'location': ('city', 'region', 'country'),
                    'units': ('temperature', 'distance', 'pressure', 'speed'),
                    'wind': ('chill', 'direction', 'speed'),
                    'atmosphere':
                    ('humidity', 'visibility', 'pressure', 'rising'),
                    'astronomy': ('sunrise', 'sunset'),
                    'condition': ('text', 'code', 'temp', 'date')
                }
                for tag, attrs in ns_data_structure.items():
                    weather_data[tag] = self.xml_get_ns_yahoo_tag(
                        dom, 'http://xml.weather.yahoo.com/ns/rss/1.0', tag,
                        attrs)

                weather_data['geo'] = {}
                weather_data['geo']['lat'] = dom.getElementsByTagName(
                    'geo:lat')[0].firstChild.data
                weather_data['geo']['long'] = dom.getElementsByTagName(
                    'geo:long')[0].firstChild.data
                weather_data['condition']['title'] = dom.getElementsByTagName(
                    'item')[0].getElementsByTagName('title')[0].firstChild.data
                weather_data['html_description'] = dom.getElementsByTagName(
                    'item')[0].getElementsByTagName(
                        'description')[0].firstChild.data
                forecasts = []
                for forecast in dom.getElementsByTagNameNS(
                        'http://xml.weather.yahoo.com/ns/rss/1.0', 'forecast'):
                    forecasts.append(
                        self.xml_get_attrs(
                            forecast,
                            ('day', 'date', 'low', 'high', 'text', 'code')))

                weather_data['forecasts'] = forecasts
                dom.unlink()
                maintext = 'Data provider: '
                self['lab1b'].setText('Yahoo Weather')
                city = '%s' % str(weather_data['location']['city'])
                self['lab2'].setText(city)
                txt = str(weather_data['condition']['date'])
                parts = txt.strip().split(' ')
                txt = 'Last Updated: %s %s %s %s %s' % (
                    parts[1], parts[2], parts[3], parts[4], parts[5])
                self['lab3'].setText(txt)
                txt = str(weather_data['condition']['temp'])
                self['lab4'].setText(txt)
                self['lab4b'].setText('\xc2\xb0C')
                icon = resolveFilename(
                    SCOPE_PLUGINS, 'Extensions/PEWeather/weather/%s.png' %
                    str(weather_data['condition']['code']))
                myicon = self.checkIcon(icon)
                png = loadPic(myicon, 250, 180, 0, 0, 0, 0)
                self['lab5'].instance.setPixmap(png)
                txt = str(weather_data['condition']['text'])
                self['lab6'].setText(txt)
                self['lab7'].setText('Humidity :')
                txt = str(weather_data['atmosphere']['humidity']) + ' %'
                self['lab7b'].setText(txt)
                self['lab8'].setText('Pressure :')
                txt = str(weather_data['atmosphere']['pressure']) + ' mb'
                self['lab8b'].setText(txt)
                self['lab9'].setText('Visibility :')
                txt = str(weather_data['atmosphere']['visibility']) + ' km'
                self['lab9b'].setText(txt)
                self['lab10'].setText('Sunrise :')
                txt = str(weather_data['astronomy']['sunrise'])
                self['lab10b'].setText(txt)
                self['lab11'].setText('Sunset :')
                txt = str(weather_data['astronomy']['sunset'])
                self['lab11b'].setText(txt)
                self['lab12'].setText('Wind :')
                direction = self.wind_direction(
                    str(weather_data['wind']['direction']))
                txt = 'From %s at %s kmh' % (
                    direction, str(weather_data['wind']['speed']))
                self['lab12b'].setText(txt)
                txt = self.extend_day(str(weather_data['forecasts'][0]['day']))
                self['lab13'].setText(txt)
                self['lab14'].setText('High :')
                txt = str(weather_data['forecasts'][0]['high']) + '\xc2\xb0C'
                self['lab14b'].setText(txt)
                self['lab15'].setText('Low :')
                txt = str(weather_data['forecasts'][0]['low']) + '\xc2\xb0C'
                self['lab15b'].setText(txt)
                txt = str(weather_data['forecasts'][0]['text'])
                self['lab16'].setText(txt)
                icon = resolveFilename(
                    SCOPE_PLUGINS,
                    'Extensions/PEWeather/weather/small/%s.png' %
                    str(weather_data['forecasts'][0]['code']))
                myicon = self.checkIcon(icon)
                png = loadPic(myicon, 100, 100, 0, 0, 0, 0)
                self['lab17'].instance.setPixmap(png)
                txt = self.extend_day(str(weather_data['forecasts'][1]['day']))
                self['lab18'].setText(txt)
                self['lab19'].setText('High :')
                txt = str(weather_data['forecasts'][1]['high']) + '\xc2\xb0C'
                self['lab19b'].setText(txt)
                self['lab20'].setText('Low :')
                txt = str(weather_data['forecasts'][1]['low']) + '\xc2\xb0C'
                self['lab20b'].setText(txt)
                txt = str(weather_data['forecasts'][1]['text'])
                self['lab21'].setText(txt)
                icon = resolveFilename(
                    SCOPE_PLUGINS,
                    'Extensions/PEWeather/weather/small/%s.png' %
                    str(weather_data['forecasts'][1]['code']))
                myicon = self.checkIcon(icon)
                png = loadPic(myicon, 100, 100, 0, 0, 0, 0)
                self['lab22'].instance.setPixmap(png)
                self['lab23'].setText(city)
                self['lab24'].setText('Latitude :')
                txt = str(weather_data['geo']['lat']) + '\xc2\xb0'
                self['lab24b'].setText(txt)
                self['lab25'].setText('Longitude :')
                txt = str(weather_data['geo']['long']) + '\xc2\xb0'
                self['lab25b'].setText(txt)
                self['lab26'].setText('Region :')
                txt = str(weather_data['location']['region'])
                self['lab26b'].setText(txt)
                self['lab27'].setText('Country :')
                txt = str(weather_data['location']['country'])
                self['lab27b'].setText(txt)
                myicon = resolveFilename(
                    SCOPE_PLUGINS, 'Extensions/PEWeather/weather/red.png')
                png = loadPic(myicon, 16, 16, 0, 0, 0, 0)
                self['lab28'].instance.setPixmap(png)
                self['lab28a'].setText(':')
                self['lab28b'].setText('Change city')
            else:
                maintext = 'Error getting XML document!'

        self['lab1'].setText(maintext)
Ejemplo n.º 17
0
    def updateInfo(self):
        myurl = self.get_Url()
        req = Request(myurl)
        try:
            handler = urlopen(req)
        except HTTPError as e:
            maintext = 'Error: connection failed !'
        except URLError as e:
            maintext = 'Error: Page not available !'
        else:
            dom = minidom.parse(handler)
            handler.close()
            maintext = ''
            tmptext = ''	
            if dom:
                weather_data = {}
                weather_data['title'] = dom.getElementsByTagName('title')[0].firstChild.data
                txt = str(weather_data['title'])
                if txt.find('Error') != -1 or self.bhv < 2:
                    self['lab1'].setText(_('Sorry, wrong WOEID'))
                    return
                ns_data_structure = {'location': ('city', 'region', 'country'),
                 'units': ('temperature', 'distance', 'pressure', 'speed'),
                 'wind': ('chill', 'direction', 'speed'),
                 'atmosphere': ('humidity', 'visibility', 'pressure', 'rising'),
                 'astronomy': ('sunrise', 'sunset'),
                 'condition': ('text', 'code', 'temp', 'date')}
                for tag, attrs in ns_data_structure.items():
                    weather_data[tag] = self.xml_get_ns_yahoo_tag(dom, 'http://xml.weather.yahoo.com/ns/rss/1.0', tag, attrs)

                weather_data['geo'] = {}
                weather_data['geo']['lat'] = dom.getElementsByTagName('geo:lat')[0].firstChild.data
                weather_data['geo']['long'] = dom.getElementsByTagName('geo:long')[0].firstChild.data
                weather_data['condition']['title'] = dom.getElementsByTagName('item')[0].getElementsByTagName('title')[0].firstChild.data
                weather_data['html_description'] = dom.getElementsByTagName('item')[0].getElementsByTagName('description')[0].firstChild.data
                forecasts = []
                for forecast in dom.getElementsByTagNameNS('http://xml.weather.yahoo.com/ns/rss/1.0', 'forecast'):
                    forecasts.append(self.xml_get_attrs(forecast, ('day', 'date', 'low', 'high', 'text', 'code')))

                weather_data['forecasts'] = forecasts
                dom.unlink()
                maintext = 'Data provider: '
                self['lab1b'].setText(_('Yahoo Weather'))
                city = '%s' % str(weather_data['location']['city'])
                self['lab2'].setText(city)
                txt = str(weather_data['condition']['date'])
                parts = txt.strip().split(' ')
                txt = _('Last Updated:')+' %s %s %s %s %s' % (parts[1],
                 parts[2],
                 parts[3],
                 parts[4],
                 parts[5])
                self['lab3'].setText(txt)
                txt = str(weather_data['condition']['temp'])
                self['lab4'].setText(txt)
                self['lab4b'].setText('\xc2\xb0C')
                icon = '/usr/lib/enigma2/python/Plugins/Extensions/YahooWeather/Icon/%s.png' % str(weather_data['condition']['code'])
                myicon = self.checkIcon(icon)
                #png = loadPic(myicon, 220, 195, 0, 0, 0, 0)
                png = loadPic(myicon, 219, 160, 0, 0, 0, 0)
                self['lab5'].instance.setPixmap(png)
                #txt = str(weather_data['condition']['text'])
                txt = self.extend_name(str(weather_data['condition']['text']))
                self['lab6'].setText(txt)
                self['lab7'].setText(_('Humidity   :'))
                txt = str(weather_data['atmosphere']['humidity']) + ' %'
                self['lab7b'].setText(txt)
                self['lab8'].setText(_('Pressure   :'))
                txt = str(weather_data['atmosphere']['pressure']) + ' mb'
                self['lab8b'].setText(txt)
                self['lab9'].setText(_('Visibility :'))
                txt = str(weather_data['atmosphere']['visibility']) + ' km'
                self['lab9b'].setText(txt)
                self['lab10'].setText(_('Sunrise    :'))
                txt = str(weather_data['astronomy']['sunrise'])
                self['lab10b'].setText(txt)
                self['lab11'].setText(_('Sunset     :'))
                txt = str(weather_data['astronomy']['sunset'])
                self['lab11b'].setText(txt)
                self['lab12'].setText(_('Wind       :'))
                direction = self.wind_direction(str(weather_data['wind']['direction']))
                txt = _('Wind') + ' ' + _('From')+' %s : %s kmh' % (direction, str(weather_data['wind']['speed']))
                self['lab12b'].setText(txt)
                txt = self.extend_day(str(weather_data['forecasts'][0]['day']))
                self['lab13'].setText(txt)
                self['lab14'].setText(_('Max :'))
                txt = str(weather_data['forecasts'][0]['high']) + '\xc2\xb0C'
                self['lab14b'].setText(txt)
                self['lab15'].setText(_('Min :'))
                txt = str(weather_data['forecasts'][0]['low']) + '\xc2\xb0C'
                self['lab15b'].setText(txt)
                txt = self.extend_name(str(weather_data['forecasts'][0]['text']))
                self['lab16'].setText(txt)
                txt = str(weather_data['forecasts'][0]['date'])
                self['daydate0'].setText(txt)
                icon = '/usr/lib/enigma2/python/Plugins/Extensions/YahooWeather/Icon/%s.png' % str(weather_data['forecasts'][0]['code'])
                myicon = self.checkIcon(icon)
                #png = loadPic(myicon, 81, 72, 0, 0, 0, 0)
                png = loadPic(myicon, 81, 59, 0, 0, 0, 0)
                self['lab17'].instance.setPixmap(png)
                txt = self.extend_day(str(weather_data['forecasts'][1]['day']))
                self['lab18'].setText(txt)
                self['lab19'].setText(_('Max :'))
                txt = str(weather_data['forecasts'][1]['high']) + '\xc2\xb0C'
                self['lab19b'].setText(txt)
                self['lab20'].setText(_('Min :'))
                txt = str(weather_data['forecasts'][1]['low']) + '\xc2\xb0C'
                self['lab20b'].setText(txt)
                txt = self.extend_name(str(weather_data['forecasts'][1]['text']))
                self['lab21'].setText(txt)
                txt = str(weather_data['forecasts'][1]['date'])
                self['daydate1'].setText(txt)
                icon = '/usr/lib/enigma2/python/Plugins/Extensions/YahooWeather/Icon/%s.png' % str(weather_data['forecasts'][1]['code'])
                myicon = self.checkIcon(icon)
                png = loadPic(myicon, 81, 59, 0, 0, 0, 0)
                self['lab22'].instance.setPixmap(png)
                ####################test day3######################
                txt = self.extend_day(str(weather_data['forecasts'][2]['day']))
                self['3lab18'].setText(txt)
                self['3lab19'].setText(_('Max :'))
                txt = str(weather_data['forecasts'][2]['high']) + '\xc2\xb0C'
                self['3lab19b'].setText(txt)
                self['3lab20'].setText(_('Min :'))
                txt = str(weather_data['forecasts'][2]['low']) + '\xc2\xb0C'
                self['3lab20b'].setText(txt)
                txt = self.extend_name(str(weather_data['forecasts'][2]['text']))
                self['3lab21'].setText(txt)
                txt = str(weather_data['forecasts'][2]['date'])
                self['daydate2'].setText(txt)
                icon = '/usr/lib/enigma2/python/Plugins/Extensions/YahooWeather/Icon/%s.png' % str(weather_data['forecasts'][2]['code'])
                myicon = self.checkIcon(icon)
                png = loadPic(myicon, 81, 59, 0, 0, 0, 0)
                self['3lab22'].instance.setPixmap(png)
                ####################test day4######################
                txt = self.extend_day(str(weather_data['forecasts'][3]['day']))
                self['4lab18'].setText(txt)
                self['4lab19'].setText(_('Max :'))
                txt = str(weather_data['forecasts'][3]['high']) + '\xc2\xb0C'
                self['4lab19b'].setText(txt)
                self['4lab20'].setText(_('Min :'))
                txt = str(weather_data['forecasts'][3]['low']) + '\xc2\xb0C'
                self['4lab20b'].setText(txt)
                txt = self.extend_name(str(weather_data['forecasts'][3]['text']))
                self['4lab21'].setText(txt)
                txt = str(weather_data['forecasts'][3]['date'])
                self['daydate3'].setText(txt)
                icon = '/usr/lib/enigma2/python/Plugins/Extensions/YahooWeather/Icon/%s.png' % str(weather_data['forecasts'][3]['code'])
                myicon = self.checkIcon(icon)
                png = loadPic(myicon, 81, 59, 0, 0, 0, 0)
                self['4lab22'].instance.setPixmap(png)
                ####################test day5######################
                txt = self.extend_day(str(weather_data['forecasts'][4]['day']))
                self['5lab18'].setText(txt)
                self['5lab19'].setText(_('Max :'))
                txt = str(weather_data['forecasts'][4]['high']) + '\xc2\xb0C'
                self['5lab19b'].setText(txt)
                self['5lab20'].setText(_('Min :'))
                txt = str(weather_data['forecasts'][4]['low']) + '\xc2\xb0C'
                self['5lab20b'].setText(txt)
                txt = self.extend_name(str(weather_data['forecasts'][4]['text']))
                self['5lab21'].setText(txt)
                txt = str(weather_data['forecasts'][4]['date'])
                self['daydate4'].setText(txt)
                icon = '/usr/lib/enigma2/python/Plugins/Extensions/YahooWeather/Icon/%s.png' % str(weather_data['forecasts'][4]['code'])
                myicon = self.checkIcon(icon)
                png = loadPic(myicon, 81, 59, 0, 0, 0, 0)
                self['5lab22'].instance.setPixmap(png)
                ###################################################
                self['lab23'].setText(city)
                self['lab24'].setText(_('Latitude :'))
                txt = str(weather_data['geo']['lat']) + '\xc2\xb0'
                self['lab24b'].setText(txt)
                self['lab25'].setText(_('Longitude :'))
                txt = str(weather_data['geo']['long']) + '\xc2\xb0'
                self['lab25b'].setText(txt)
                self['lab26'].setText(_('Region    :'))
                txt = str(weather_data['location']['region'])
                self['lab26b'].setText(txt)
                txt = str(weather_data['location']['country'])
                self['lab27'].setText(_('Country   :') + ' ' + (txt))
                myicon = '/usr/lib/enigma2/python/Plugins/Extensions/YahooWeather/Skin/1color.png'
                png = loadPic(myicon, 250, 30, 0, 0, 0, 0)
                self['lab28'].instance.setPixmap(png)
                self['lab28a'].setText(':')
                
                #check current day#
        #        checkday = (str(weather_data['forecasts'][0]['day']))
        #        currentday = strftime("%a")
                
        #        if not currentday == checkday:
        #        	return self.startConnection()
                
            else:
                maintext = 'Error getting XML document!'

        self['lab1'].setText(maintext)
Ejemplo n.º 18
0
 def onImageLoaded(self, dummy):
         self.currPic = loadPic(self.tmpfile, self.width, self.height, 0, 1, 0, 1)
         os_remove(self.tmpfile)
         self.callBack(pixmap=self.currPic)
Ejemplo n.º 19
0
	def updateInfo(self):
		myurl = self.get_Url()
		req = Request(myurl)
		try:
			handler = urlopen(req)
		except HTTPError as e:
			maintext = "Error: connection failed !"
		except URLError as e:
			maintext = "Error: Page not available !"
		else:
			xml_response = handler.read()
			#xml_response = handler.read().decode('iso-8859-1').encode('utf-8')
			xml_response = self.checkXmlSanity(xml_response)
			dom = minidom.parseString(xml_response)
			handler.close()
			maintext = ""
			tmptext = ""
			if (dom):
				weather_data = {}
				weather_dom = dom.getElementsByTagName('weather')[0]
				data_structure = {
					'forecast_information': ('postal_code', 'current_date_time'),
					'current_conditions': ('condition', 'temp_c', 'humidity', 'wind_condition', 'icon')
				}
				for (tag, list_of_tags2) in data_structure.iteritems():
					tmp_conditions = {}
					for tag2 in list_of_tags2:
						try:
							tmp_conditions[tag2] = weather_dom.getElementsByTagName(tag)[0].getElementsByTagName(tag2)[0].getAttribute('data')
						except IndexError:
							pass
					weather_data[tag] = tmp_conditions

				forecast_conditions = ('day_of_week', 'low', 'high', 'icon', 'condition')
				forecasts = []

				for forecast in dom.getElementsByTagName('forecast_conditions'):
						tmp_forecast = {}
						for tag in forecast_conditions:
								tmp_forecast[tag] = forecast.getElementsByTagName(tag)[0].getAttribute('data')
						forecasts.append(tmp_forecast)

				weather_data['forecasts'] = forecasts
				dom.unlink()

				maintext = "Il tempo di oggi a " + str(weather_data['forecast_information']['postal_code'])
				mytime = str(weather_data['forecast_information']['current_date_time'])
				parts = mytime.strip().split(" ")
				mytime = parts[1]
				self["lab2"].setText("Condizioni del tempo aggiornate alle ore " + mytime)

				myicon = self.checkIcon(str(weather_data['current_conditions']['icon']))
# Damn'ed Google gifs .... (we cannot use loadPixmap)
				png = loadPic(myicon, 40, 40, 0, 0, 0, 1)
				self["lab3"].instance.setPixmap(png)

				self["lab4"].setText(self.fixSlang(str(weather_data['current_conditions']['condition'])))

				tmptext = "Temperatura: " + str(weather_data['current_conditions']['temp_c']) + " gradi Celsius\n" + str(weather_data['current_conditions']['humidity']) + "   " + str(weather_data['current_conditions']['wind_condition'])
				self["lab5"].setText(tmptext)

				tmptext = "Previsioni " + self.eXtendedDay(str(weather_data['forecasts'][1]['day_of_week']))
				self["lab6"].setText(tmptext)

				myicon = self.checkIcon(str(weather_data['forecasts'][1]['icon']))
				png = loadPic(myicon, 40, 40, 0, 0, 0, 1)
				self["lab7"].instance.setPixmap(png)

				tmptext = self.fixSlang(str(weather_data['forecasts'][1]['condition'])) + "\nTemp. minima: " + str(weather_data['forecasts'][1]['low']) + "\nTemp. massima: " + str(weather_data['forecasts'][1]['high'])
				self["lab8"].setText(tmptext)

				tmptext = "Previsioni " + self.eXtendedDay(str(weather_data['forecasts'][2]['day_of_week']))
				self["lab9"].setText(tmptext)

				myicon = self.checkIcon(str(weather_data['forecasts'][2]['icon']))
				png = loadPic(myicon, 40, 40, 0, 0, 0, 1)
				self["lab10"].instance.setPixmap(png)

				tmptext = self.fixSlang(str(weather_data['forecasts'][2]['condition'])) + "\nTemp. minima: " + str(weather_data['forecasts'][2]['low']) + "\nTemp. massima: " + str(weather_data['forecasts'][2]['high'])
				self["lab11"].setText(tmptext)

				tmptext = "Previsioni " + self.eXtendedDay(str(weather_data['forecasts'][3]['day_of_week']))
				self["lab12"].setText(tmptext)

				myicon = self.checkIcon(str(weather_data['forecasts'][3]['icon']))
				png = loadPic(myicon, 40, 40, 0, 0, 0, 1)
				self["lab13"].instance.setPixmap(png)

				tmptext = self.fixSlang(str(weather_data['forecasts'][3]['condition'])) + "\nTemp. minima: " + str(weather_data['forecasts'][3]['low']) + "\nTemp. massima: " + str(weather_data['forecasts'][3]['high'])
				self["lab14"].setText(tmptext)

			else:
				maintext = "Error getting XML document!"

		self["lab1"].setText(maintext)