Beispiel #1
0
 def get_sendWdata(self, sCity, sTopic):
     sPay = ""
     clsConst = com_appConst.appConstClass()
     clsWeaher = com_weather.weatherClass()
     dic = clsWeaher.get_wdata(sCity)
     print (len(dic))
     print (dic)
     if len(dic) < 1:
         return
         # city
     self.send_pubw(dic["city"], sTopic)
     # cond
     self.send_pubw(dic["cond"], sTopic)
     # temp-H
     print ("temp_H=")
     print (str(dic["temp_H"]))
     sTemp = "High Temp:" + str(dic["temp_H"]) + "(C)"
     self.send_pubw(sTemp, sTopic)
     # temp-L
     sTemp = "Low Temp:" + str(dic["temp_L"]) + "(C)"
     self.send_pubw(sTemp, sTopic)
     return
Beispiel #2
0
def get_wdata(sCity):
	sPay=""
	clsConst  = com_appConst.appConstClass()
	clsWeaher= com_weather.weatherClass()
	clsPub=com_mqttPub.mqttPubClass()
	dic= clsWeaher.get_wdata(sCity)
	print(len(dic))
	print(dic)
	if (len(dic) < 1):
		return
	#city
	clsPub.send_pubw(dic["city"] ,mTopic)
	#cond
	clsPub.send_pubw(dic["cond"] ,mTopic)
	#temp-H
	print("temp_H=")
	print(str(dic["temp_H"]))
	sTemp="High Temp:" + str(dic["temp_H"]) + "(C)"
	clsPub.send_pubw(sTemp ,mTopic)
	#temp-L
	sTemp="Low Temp:" + str(dic["temp_L"]) + "(C)"
	clsPub.send_pubw(sTemp ,mTopic)
	return
Beispiel #3
0
def get_wdata():
    clsConst  = com_appConst.appConstClass()
    clsWeaher= com_weather.weatherClass()
    sCity="Tokyo"
    clsWeaher.delete_dat(sCity)
    #tokyo
    result = pywapi.get_weather_from_yahoo('JAXX0085')
    #oosaka
    #result = pywapi.get_weather_from_yahoo('JAXX0071') 
    #fukuoka
    #result = pywapi.get_weather_from_yahoo('JAXX0009') 
    #sapporo
    #result = pywapi.get_weather_from_yahoo('JAXX0078') 
    
    print '---'
    print result['title']
    print 'city: ' + result['location']['city']
    print 'condition: ' + result['condition']['text']
    print 'temp: ' + result['condition']['temp'] + '(C)'
    print 'High Temp: ' + result['forecasts'][1]['high']
    print 'Low Temp: ' + result['forecasts'][1]['low']
    print '---'
    clsWeaher.saveData( result)