• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pywapi.get_weather_from_yahoo函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pywapi.get_weather_from_yahoo函数的典型用法代码示例。如果您正苦于以下问题:Python get_weather_from_yahoo函数的具体用法?Python get_weather_from_yahoo怎么用?Python get_weather_from_yahoo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_weather_from_yahoo函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: run

        def run(self):
		old_temp = 0
		old_humidity = 0
		old_dewpoint = 0
                while (True):

			try:
				yahooweather_result = pywapi.get_weather_from_yahoo(readID)
				if yahooweather_result != "":
					condizioni = yahooweather_result['condition']['text']
					temperatura = float(yahooweather_result['condition']['temp'])
					umidita = float(yahooweather_result['atmosphere']['humidity'])
					dew = calc_dewpoint(temperatura, umidita)
					if temperatura != old_temp:
						if (readTempUnits == 'f' or readTempUnits == 'F'):
							tempF = round(celsius_to_fahrenheit(temperatura))
							client.emit_event(temp, "event.environment.temperaturechanged", tempF, "F")
						else:
       			                 		client.emit_event(temp, "event.environment.temperaturechanged", temperatura, "C")
					if umidita != old_humidity:
		       				client.emit_event(humidity, "event.environment.humiditychanged", umidita, "%")
		                        search_Rain = string.find(condizioni, "Rain")
					search_Drizzle = string.find(condizioni, "Drizzle")
		                        if (search_Rain >= 0) or (search_Drizzle >=0):
						client.emit_event(rain,"event.device.statechanged", "255", "")

		                        else :
						client.emit_event(rain,"event.device.statechanged", "0", "")

			except KeyError:
				print "Error retrieving weather data!"
			old_temp = temperatura
			old_humidity = umidita
			old_dewpoint = dew
			time.sleep (readWaitTime)
开发者ID:mce35,项目名称:agocontrol,代码行数:35,代码来源:agoweather.py


示例2: GenerateWeatherConditionsText

  def GenerateWeatherConditionsText(self):
    zipcode = '89129'
    weather = pywapi.get_weather_from_yahoo(zipcode)
    condition  = weather['condition']['text'].encode('UTF-8')
    humidity = weather['atmosphere']['humidity'].encode('UTF-8')
    temp_celsius = float(weather['condition']['temp'])
    temp = str( round(self.celsius2farenheight(temp_celsius),2)).encode('UTF-8')
    wind_mps = float( weather['wind']['speed'] )
    wind = str( round(self.mps2mph(wind_mps),2) ).encode('UTF-8')

    date_1 = weather['forecasts'][0]['date']
    date_2 = weather['forecasts'][1]['date']
    time_1 = time.strftime("%a, %b %d",time.strptime(date_1, "%d %b %Y")).encode('UTF-8')
    time_2 = time.strftime("%a, %b %d",time.strptime(date_2, "%d %b %Y")).encode('UTF-8')
    forecast_temp_low_1 = str(int(self.celsius2farenheight(float(weather['forecasts'][0]['low'])))).encode('UTF-8')
    forecast_temp_high_1 = str(int(self.celsius2farenheight(float(weather['forecasts'][0]['high'])))).encode('UTF-8')
    forecast_text_1 = weather['forecasts'][0]['text'].encode('UTF-8')
    forecast_temp_low_2 = str(int(self.celsius2farenheight(float(weather['forecasts'][1]['low'])))).encode('UTF-8')
    forecast_temp_high_2 = str(int(self.celsius2farenheight(float(weather['forecasts'][1]['high'])))).encode('UTF-8')
    forecast_text_2 = weather['forecasts'][1]['text'].encode('UTF-8')

    text = '{pause=5}{typesetOff}{fastest}{amber}{5x5}{moverightin}{moverightout}today: {7x6}{green}' + condition.encode('UTF-8') +'{nl}'
    text = text + '{5x5}{amber}{moveleftin}{moveleftout}Temp: {red}{7x6}' + temp + ' degrees{nl}'
    text = text + '{5x5}{amber}{moverightin}{moverightout}Humidity: {green}{7x6}' + humidity + '%{nl}'
    text = text + '{5x5}{amber}{moveleftin}{moveleftout}Wind: {red}{7x6}' + wind + 'mph{nl}'
    text = text + '{newframe}{fastest}{amber}{7x6}{moveupin}{movedownout}Forecast:{nl}'
    text = text + '{green}' + time_1 + '{nl}'
    text = text + '{red}Low:' + forecast_temp_low_1 + ' High: ' +forecast_temp_high_1 + '{nl}'
    text = text + '{amber}' + forecast_text_1 + '{nl}'
    text = text + '{newframe}{fastest}{amber}{7x6}{movedownin}{moveupout}Forecast:{nl}'
    text = text + '{green}' + time_2 + '{nl}'
    text = text + '{red}Low:' + forecast_temp_low_2 + ' High: ' +forecast_temp_high_2 + '{nl}'
    text = text + '{amber}' + forecast_text_2 + '{nl}'
    return text
开发者ID:decolector,项目名称:LEDSign,代码行数:34,代码来源:task.py


示例3: Weather

    def Weather(self):
        for i in self.trying:
            i.Destroy()
            
        self.trying = []
        sizer = wx.GridBagSizer()
        temp_actuel=T.time()
        weather_com_result = pywapi.get_weather_from_weather_com('10001')
        yahoo_result = pywapi.get_weather_from_yahoo('10001')
        noaa_result = pywapi.get_weather_from_noaa('KJFK')
        weather1 = self.trying.append(wx.StaticText(self.BoxStock,-1,str("Yahoo says: It is " + string.lower(yahoo_result['condition']['text']) + " and " +
         yahoo_result['condition']['temp'] + " C now "),pos=(50,50)))
       # labelStock = wx.StaticText(self.BoxStock,-1,label=weather1,pos=(30,30))
        #self.text.SetLabel(str(labelStock))
        #weather2 = "Weather.com says: It is " + string.lower(weather_com_result['current_conditions']['text']) + " and " + weather_com_result['current_conditions']['temperature'] + " C now "
        #labelStock = wx.StaticText(self.BoxStock,label=weather2,pos=(30,80))
        #self.text.SetLabel(str(labelStock))

        wx.CallLater(10000,self.Weather)
        message=string.lower(yahoo_result['condition']['text'])
        if message=="fair":
            #from PIL import Image
            #bidule = Image.open("image/nuage-noir-avec-de-la-pluie.jpg")
            #bidule.show()
            
            app= Application(redirect=True)
            app.MainLoop()
开发者ID:sebastien247,项目名称:sixthsensepy,代码行数:27,代码来源:weather.py


示例4: get_wind

def get_wind(zip, units):
    weather = pywapi.get_weather_from_yahoo(zip)
    wind = 'No wind'
    if weather['wind']['speed'] > 1:
        wind = 'Wind %dmph from %s' % (float(weather['wind']['speed']), \
               get_wind_direction(weather['wind']['direction']))
    return wind
开发者ID:cd34,项目名称:stravatweet,代码行数:7,代码来源:stravatweet.py


示例5: __init__

 def __init__(self):
     self.result = pywapi.get_weather_from_yahoo('SPXX0050', 'metric')
     icon = self.__code_to_something(self.result['condition']['code'])
     if icon:
         self.result['condition']['icon'] = icon
     if 'link' in self.result:
         self.result['condition']['link'] = self.result['link']
开发者ID:davidcaste,项目名称:temperature-service,代码行数:7,代码来源:temperature.py


示例6: getWeatherMemoized

def getWeatherMemoized():
	global lastweather, wTemp, wIcon
	#update hourly
	if (time.time() - lastweather > 60 * 60):
		lastweather = time.time()
		wres = pywapi.get_weather_from_yahoo('10001')
		wTemp = (wres['condition']['temp'] + u"°C"
			#+ wres['condition']['text']
		)

		#print wres

		cond = wres['condition']['text']
		if cond == u"Sunny":
			wIcon = u"⛭"
		elif cond == u"Mostly Sunny":
			wIcon = u"⛯"
		elif cond == u"Fair":
			wIcon = u"⚙"
		elif cond == u"Partly Cloudy":
			wIcon = u"⛅"
		elif cond == u"Cloudy":
			wIcon = u"☁"
		elif cond == u"Raining":
			wIcon = u"☔" #☂
		elif cond == u"Snowing":
			wIcon = u"⛄"
		else:
			wIcon = u"☭"
开发者ID:Adjective-Object,项目名称:menubar,代码行数:29,代码来源:barout.py


示例7: show_temp

def show_temp():
    yahoo_weather = pywapi.get_weather_from_yahoo('78728', 'imperial')
    for ch in yahoo_weather['condition']['temp']:
        display.display_char_fade(ch, color_tools.random_rgb(), 300)
    display.display_char_fade(chr(0xb0), color_tools.random_rgb(), 300)
    display.display_char_fade('f', color_tools.random_rgb(), 300)
    time.sleep(0.4)
开发者ID:JBarrada,项目名称:7seg,代码行数:7,代码来源:clock.py


示例8: get

    def get(self):
        auth = tweepy.OAuthHandler('wJynZvsXCJDbxFavJZMuvQ','Ua9HSGqJntKpBMfTYuldjuplo3XUlC3QovTn7EOQ')
        auth.set_access_token('400026591-XCtPsJABBP5MGF13Q4xFVXZurRcVtCcJ0VaU9Dr5', '635W0s9PIVYxlVktp0hWiNkBfNS4ntuW7c2thGsp8')
        api = tweepy.API(auth)
		
	location = 'Mataram'
	f = urllib2.urlopen('http://api.wunderground.com/api/da229b2203c824d3/geolookup/conditions/q/IA/' + location +'.json')
	json_string = f.read()
	parsed_json = json.loads(json_string)
	
	resYahoo = pywapi.get_weather_from_yahoo('IDXX0032', 'metric')
	
	time = datetime.datetime.utcnow() + datetime.timedelta(hours = 8)
	location = parsed_json['location']['city']
	current = parsed_json['current_observation']['weather']
	temp_c = parsed_json['current_observation']['temp_c']
	humidity = parsed_json['current_observation']['relative_humidity']
	visibility = parsed_json['current_observation']['visibility_km']
	f.close()
	
	sunrise = resYahoo['astronomy']['sunrise']
	sunset = resYahoo['astronomy']['sunset']
	wind = resYahoo['wind']['speed'] + ' km'
	winddir = resYahoo['wind']['direction'] 
	
	update = time.strftime("%Y-%m-%d, %H:%M") + ' WITA : ' + location + ' ' + current + ' ' + str(temp_c) +' C' + ', Humidity: ' + humidity  +', ' + ' Visibility: ' + visibility + ' km'
	update = update + ', Wind: ' + wind  + ', Sunrise: ' + sunrise + ', Sunset: ' + sunset
	self.response.out.write(update)
	api.update_status(update)
开发者ID:theclai,项目名称:Cuaca-kota-mataram,代码行数:29,代码来源:main.py


示例9: run

    def run(self, wcd, wci):
        """
        Displaying expected temperature
        """
        # Get current forecast
        if self.weather_service == "yahoo":
            current_weather_forecast = pywapi.get_weather_from_yahoo(self.location_id)
        elif self.weather_service == "weather_dot_com":
            current_weather_forecast = pywapi.get_weather_from_weather_com(self.location_id)
        else:
            print("Warning: No valid weather_forecast found!")
            return
        outdoor_temp = current_weather_forecast["current_conditions"]["temperature"]
        if self.temp_sensor_registered:
            try:
                indoor_temp = str(int(round(am2302_ths.get_temperature(4))))
                wcd.showText(outdoor_temp + "*", count=1, fps=8)
                wcd.showText(indoor_temp + "*", count=1, fg_color=wcc.GREEN, fps=8)
                wcd.showText(outdoor_temp + "*", count=1, fps=8)
                wcd.showText(indoor_temp + "*", count=1, fg_color=wcc.GREEN, fps=8)
            except:
                print("  Failed to read temperature sensor!")
                wcd.showText(outdoor_temp + "*   " + outdoor_temp + "*   " + outdoor_temp + "*", count=1, fps=8)
        else:
            wcd.showText(outdoor_temp + "*   " + outdoor_temp + "*   " + outdoor_temp + "*", count=1, fps=8)

        time.sleep(1)
开发者ID:KonsolenJockey,项目名称:rpi_wordclock,代码行数:27,代码来源:plugin.py


示例10: weather

def weather(args):
    

    try:
        result = pywapi.get_weather_from_yahoo(
            str(args[0]).replace("_", " "), "imperial")
        current_conditions = result["condition"][
            "title"] + ": " + result["condition"]["text"] + \
            ", " + result["condition"]["temp"]
        five_day_forecast = result["forecasts"]
        forecast_1 = str(five_day_forecast[0]["day"]) + ": " + str(five_day_forecast[0]["text"]) + ", " + str(
            five_day_forecast[0]["high"]) + ", " + str(five_day_forecast[0]["low"]) + " | "
        forecast_2 = str(five_day_forecast[1]["day"]) + ": " + str(five_day_forecast[1]["text"]) + ", " + str(
            five_day_forecast[1]["high"]) + ", " + str(five_day_forecast[1]["low"]) + " | "
        forecast_3 = str(five_day_forecast[2]["day"]) + ": " + str(five_day_forecast[2]["text"]) + ", " + str(
            five_day_forecast[2]["high"]) + ", " + str(five_day_forecast[2]["low"]) + " | "
        forecast_4 = str(five_day_forecast[3]["day"]) + ": " + str(five_day_forecast[3]["text"]) + ", " + str(
            five_day_forecast[3]["high"]) + ", " + str(five_day_forecast[3]["low"]) + " | "
        forecast_5 = str(five_day_forecast[4]["day"]) + ": " + str(five_day_forecast[4][
            "text"]) + ", " + str(five_day_forecast[4]["high"]) + ", " + str(five_day_forecast[4]["low"])
        forecasts = forecast_1 + forecast_2 + \
            forecast_3 + forecast_4 + forecast_5

        return current_conditions # + " | Forecasts: " + forecasts
    except:
        return "Zip codes only, at the moment, plz."
开发者ID:Loknar,项目名称:uppers-twitchbot,代码行数:26,代码来源:weather.py


示例11: run

    def run(self, wcd, wci):
        """
        Displaying expected temperature
        """
        # Get current forecast
        if self.weather_service == 'yahoo':
            current_weather_forecast = pywapi.get_weather_from_yahoo(self.location_id)
        elif self.weather_service == 'weather_dot_com':
            current_weather_forecast = pywapi.get_weather_from_weather_com(self.location_id)
        else:
            print('Warning: No valid weather_forecast found!')
            return
        outdoor_temp = current_weather_forecast['current_conditions']['temperature']
        if self.temp_sensor_registered:
            try:
                indoor_temp = str(int(round(am2302_ths.get_temperature(self.pin_temp_sensor))))
                wcd.showText(outdoor_temp + '*', count=1, fps=8)
                wcd.showText(indoor_temp + '*', count=1, fg_color=wcc.GREEN, fps=8)
                wcd.showText(outdoor_temp + '*', count=1, fps=8)
                wcd.showText(indoor_temp + '*', count=1, fg_color=wcc.GREEN, fps=8)
            except:
                print('  Failed to read temperature sensor!')
                wcd.showText(outdoor_temp + '*   ' + outdoor_temp + '*   ' + outdoor_temp + '*', count=1, fps=8)
        else:
            wcd.showText(outdoor_temp + '*   ' + outdoor_temp + '*   ' + outdoor_temp + '*', count=1, fps=8)

        if wci.waitForExit(1.0):
            return
开发者ID:plotaBot,项目名称:rpi_wordclock,代码行数:28,代码来源:plugin.py


示例12: post

 def post(self):
     invalid = False
     username = self.request.cookies.get("username")
     users = User.query(User.username == username).fetch()
     user = users[0]
     zip_code = str(self.request.get("zip"))
     user.zipcode = zip_code
     user.put()
     if self.postalValidate(zip_code):
         yahoo_result = pywapi.get_weather_from_yahoo(zip_code)
         currentTemp = ((float(yahoo_result['condition']['temp'])*1.8) + 32)
         conditions = str(yahoo_result['condition']['text'])
         location = str(yahoo_result['condition']['title'])
         location = location.replace("Conditions for ", "")
         template_values = {
             'currentTemp': currentTemp,
             'conditions': conditions,
             'location': location,
             'zip_code': zip_code,
             'user': user,
         }
         template = JINJA_ENVIRONMENT.get_template('weather.html')
         self.response.write(template.render(template_values))
     else:
         invalid = True
         template_values = {
             'invalid': invalid,
             'zip_code': zip_code
         }
         template = JINJA_ENVIRONMENT.get_template('weather.html')
         self.response.write(template.render(template_values))
开发者ID:dcfaber,项目名称:CS481-FinalProject-LazyCloset,代码行数:31,代码来源:main.py


示例13: weather_info

    def weather_info(self):
        details = pywapi.get_weather_from_yahoo(CITY_ID)

        if 'error' in details:
            logging.critical('City not found. Shutting down weather thread.')
            sys.exit()
        
        weather_data = {'{0}'  : details['location']['city'],
                        '{1}'  : details['condition']['date'],
                        '{2}'  : details['condition']['code'],
                        '{3}'  : details['condition']['temp'],
                        '{4}'  : details['condition']['text'],
                        '{5}'  : details['astronomy']['sunrise'],
                        '{6}'  : details['astronomy']['sunset'],
                        '{7}'  : details['atmosphere']['humidity'],
                        '{8}'  : details['atmosphere']['pressure'],
                        '{9}'  : details['forecasts'][0]['day'],
                        '{10}' : details['forecasts'][0]['text'],
                        '{11}' : details['forecasts'][0]['code'],
                        '{12}' : details['forecasts'][0]['low'],
                        '{13}' : details['forecasts'][0]['high'],
                        '{14}' : details['forecasts'][1]['day'],
                        '{15}' : details['forecasts'][1]['text'],
                        '{16}' : details['forecasts'][1]['code'],
                        '{17}' : details['forecasts'][1]['low'],
                        '{18}' : details['forecasts'][1]['high']}

        outstring = insert_data(self.format_string, weather_data)

        with open(os.path.expanduser('~/.local/share/skutter/weather'), 'w') as g:
            g.write(outstring)
开发者ID:Hombremaledicto,项目名称:skutter,代码行数:31,代码来源:skutter.py


示例14: get_weather_info

def get_weather_info(location):
    id = get_location_id(location)
    result = pywapi.get_weather_from_yahoo(id, 'metric')
    if not result:
        return {}
    output = dict(result)
    return output
开发者ID:chengdujin,项目名称:minerva,代码行数:7,代码来源:YahooWeatherApi.py


示例15: weather

def weather(request):
    locations = ["94041", "90008", "97202", "94110", "10024", 
                 "02111", "60605", "23454", "32804", "75204", 
                 "98112", ]
    forecasts = []
    for location in random.sample(locations, 4):
        forecasts.append(pywapi.get_weather_from_yahoo(location))
    return render_to_response("petclinic/weather/weather_basic.html", { 'forecasts': forecasts })
开发者ID:mmennis,项目名称:DjangoPetClinic,代码行数:8,代码来源:weather.py


示例16: forecast

def forecast():
  yahoo_result = pywapi.get_weather_from_yahoo(weather_code)
  del yahoo_result['forecasts'][0]
  text = ""
  for forecast in yahoo_result['forecasts']:
    text += "%s: %s %sC | " % (forecast['day'],string.lower(forecast['text']),forecast['high'])

  return text
开发者ID:r3ek0,项目名称:cdabot,代码行数:8,代码来源:forecast.py


示例17: checkOutdoorTemp

def checkOutdoorTemp(zip_code):
    """Gets outdoor temperature for our ZIP code from Yahoo!"""
    try:
        yahoo_com_result = pywapi.get_weather_from_yahoo( zip_code, units = 'metric' )
        outdoor_temperature = int(yahoo_com_result['condition']['temp'])
    except (KeyError, AttributeError, httplib.BadStatusLine):
        outdoor_temperature = 0
    return outdoor_temperature
开发者ID:040medien,项目名称:furnaceathome,代码行数:8,代码来源:furnace_client.py


示例18: weather_listener

def weather_listener(zip_code):
	print("called")
	while 1:
		msg = osc_message_builder.OscMessageBuilder(address = "/filter")
		yahoo_result = pywapi.get_weather_from_yahoo(zip_code)
		tempVal = round(int(yahoo_result['condition']['temp'])*9/5 + 32, 1)
		sendOSCMessage(tempVal, "/weather_sender")
		print (tempVal)
		sleep(60)
开发者ID:Huriphoonado,项目名称:User-Sonification,代码行数:9,代码来源:sub_weather_listener.py


示例19: setWeather

	def setWeather(self):
		''' get weather from yahoo.com for Torun: PLXX0028 '''
		print "Retrieving Yahoo's weather..."
		result = pywapi.get_weather_from_yahoo('PLXX0028', 'metric')

		(self.tempHistory, historyStr) = self.setHistory(self.tempHistory, result['condition']['temp'], Data.TEMP_HISTORY_LENGTH)
		self.writeHistory('tempHistory', self.tempHistory)

		return ('<LI>Forecast for Torun. Day: %s - %s. Preassure: %s. Condition: %s. Temp: <b>%s</b>. %s' %(result['astronomy']['sunrise'], result['astronomy']['sunset'], result['atmosphere']['pressure'], result['condition']['text'], result['condition']['temp'], historyStr))
开发者ID:mbaty001,项目名称:experimental,代码行数:9,代码来源:onePage.py


示例20: getWeatherInfo

def getWeatherInfo(zipcode):
    weatherList = []
    result = pywapi.get_weather_from_yahoo(zipcode)
    weatherList = [float(result['condition']['temp']), 
                   float(result['atmosphere']['humidity']), 
                   float(result['wind']['speed'])
                  ]

    return weatherList
开发者ID:Betcy,项目名称:QuantumLight-1,代码行数:9,代码来源:weather.py



注:本文中的pywapi.get_weather_from_yahoo函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pywatchman.client函数代码示例发布时间:2022-05-27
下一篇:
Python pywapi.get_weather_from_weather_com函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap