当前位置: 首页>>代码示例>>Python>>正文


Python weather.Weather类代码示例

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


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

示例1: WeatherClock

class WeatherClock(object):
    
    any_handler = None
    interval = 60
    
    def __init__(self, url):
        self._weather = Weather(url, 10)
        self.time = time.time()
        self._prev_time = time.time()
        self.temperature = 0
        self._prev_temperature = 0
        self.conditions = ''
        self._prev_conditions = ''

    def poll(self):
        self._weather.poll()
        self.time = time.time()
        self.temperature = int(float(self._weather.current_conditions()['Temperature']))
        self.conditions = self._weather.current_conditions()['Conditions']
        if self.time - self._prev_time > self.interval or self.temperature != self._prev_temperature or self.conditions != self._prev_conditions:
            if self.handler is not None:
                self.handler(self.time, self.temperature, self.conditions)
            self._prev_time = self.time
            self._prev_conditions = self.conditions
            self._prev_temperature = self.temperature
开发者ID:DrKylstein,项目名称:Media-Gizmo,代码行数:25,代码来源:weather_clock.py

示例2: weather_current

def weather_current():
    weather = Weather(unit=Unit.CELSIUS)
    location = weather.lookup_by_location('jaipur')
    condition = location.condition
    con = f'It\'s {condition.text} today'
    temp =f'With temp {condition.temp}𐤏C'
    call(['notify-send','-u','normal', con, temp])
开发者ID:ShivSoni5,项目名称:Vision,代码行数:7,代码来源:forecast.py

示例3: getWeather

def getWeather(forecastIndex):
    weather = Weather()
    lookup = weather.lookup(26237347) #TKO
    #condition = lookup.condition()
    forecasts = lookup.forecast()
    #0 is today, 1 is tomorrow, etc...
    f = forecasts[forecastIndex]
    return  f.text() + ": hight " + str(f2c(f.high())) + " / low " +  str(f2c(f.low()))
开发者ID:AlanFromJapan,项目名称:alanarduinotools,代码行数:8,代码来源:testWeatherInk.py

示例4: getWeather

def getWeather(forecastIndex):
    weather = Weather(unit=Unit.CELSIUS)
    lookup = weather.lookup(26237347) #TKO
    #condition = lookup.condition()
    forecasts = lookup.forecast
    #0 is today, 1 is tomorrow, etc...
    f = forecasts[forecastIndex]
#    return  [f.text, f2c(f.high), f2c(f.low)]
    return  [f.text, float(f.high), float(f.low)]
开发者ID:AlanFromJapan,项目名称:alanarduinotools,代码行数:9,代码来源:testLayout2.py

示例5: checkWeather

 def checkWeather(self):
     wi = WeatherInfo()
     wi.parse(self._location)
     
     newWeather = Weather()
     newWeather.extractData(wi,self._unit)
     self._weather = newWeather 
   
     self.update()
开发者ID:josemariaruiz,项目名称:plasma_pyweather2,代码行数:9,代码来源:main.py

示例6: checkWeather

    def checkWeather(self):
        wi = WeatherInfo()
        mapper = ConditionMapper()
        wi.parse()
        weather = Weather()
        weather.extractData(wi, self._unit)

        self.lb_location.setText("Location: " + weather.location)

        self.lb_temperature.setText(weather.current_temperature)
        self.lb_condition.setText("Condition: " + weather.current_condition)
        self.lb_humidity.setText(weather.current_humidity)
        self.lb_wind.setText(weather.current_wind)

        # current condition image
        self.svg_current.setImagePath(self._image_prefix + mapper.getMappedImageName(weather.current_condition))
        self.svg_current.resize(self._big_img_width, self._big_img_height)
        self.svg_w_current.setSvg(self.svg_current)

        # load forecast days
        fc_day = weather.fc_dl[0]
        # self.lb_day_fc1.setText("Tomorrow")
        self.lb_day_fc1.setText(fc_day)

        fc_day = weather.fc_dl[1]
        self.lb_day_fc2.setText(fc_day)

        fc_day = weather.fc_dl[2]
        self.lb_day_fc3.setText(fc_day)

        # load forecast images
        fc = weather.fc_conditions[0]
        print fc
        self.svg_fc1.setImagePath(self._image_prefix + mapper.getMappedImageName(fc))
        self.svg_fc1.resize(self._img_width, self._img_height)
        self.svg_w_fc1.setSvg(self.svg_fc1)

        fc = weather.fc_conditions[1]
        print fc
        self.svg_fc2.setImagePath(self._image_prefix + mapper.getMappedImageName(fc))
        self.svg_fc2.resize(self._img_width, self._img_height)
        self.svg_w_fc2.setSvg(self.svg_fc2)

        fc = weather.fc_conditions[2]
        print fc
        self.svg_fc3.setImagePath(self._image_prefix + mapper.getMappedImageName(fc))
        self.svg_fc3.resize(self._img_width, self._img_height)
        self.svg_w_fc3.setSvg(self.svg_fc3)

        self.lb_temp_fc1.setText(weather.fc_low_high[0])
        self.lb_temp_fc2.setText(weather.fc_low_high[1])
        self.lb_temp_fc3.setText(weather.fc_low_high[2])

        # self.layout.addItem(label)
        # self.setLayout(self.layout)
        self.update()
开发者ID:rangalo,项目名称:plasma_pyweather,代码行数:56,代码来源:main.py

示例7: StepOn

def StepOn(conn):
    try:
        conn.Process(1) # block 1 second
    except KeyboardInterrupt: return 0
    now = datetime.datetime.now()
    if now.hour == 8:
        log.debug("send weather...")
        from weather import Weather
        Weather.sendall(conn)
    return 1
开发者ID:vincentwyshan,项目名称:VGA,代码行数:10,代码来源:bot.py

示例8: WeatherTestCase

class WeatherTestCase(unittest.TestCase):

    def setUp(self):
        self.weather = Weather()

    def test_is_stormy_can_be_True(self):
        self.weather._number_generator = MagicMock(return_value=0)
        self.assertTrue(self.weather.is_stormy())

    def test_is_stormy_can_be_False(self):
        self.weather._number_generator = MagicMock(return_value=3)
        self.assertFalse(self.weather.is_stormy())
开发者ID:Andrew47,项目名称:airport-Python,代码行数:12,代码来源:test_weather.py

示例9: getWeather

    def getWeather(self,address):

        fullLocName,lat,lng = self.getLoaction(address)
        
        if fullLocName != None:
            webWeather = ServerCaller("https://api.forecast.io/forecast/0e75783f8a3fa4de5b49fff8115d93b4/"+str(lat)+","+str(lng))
            webWeather.callService()
            
            currently = Weather("Currently",webWeather.data["currently"])   
            return currently.getWeatherInfo(fullLocName)
        
        else:
            return "(wtf) - 404 Location not found!"
开发者ID:gediminasz,项目名称:curiosity,代码行数:13,代码来源:plugin.py

示例10: post_image_weather

 def post_image_weather(self):
     """ Create weather image and post to twitter """
     # get weather image
     print 'start'
     weth = Weather()
     weather_img, date_title = weth.draw_img()
     # create stream
     print 'streem'
     image_io = StringIO()
     # weather_img.save(image_io, format='JPEG', quality=100, subsampling=0, optimize=True, progressive=True)
     weather_img.save(image_io, format='PNG')
     image_io.seek(0)
     # post tweet
     print 'post'
     return self.twitter.update_status_with_media(media=image_io, status=self.weather_string % date_title)
开发者ID:Samael500,项目名称:sev-boats,代码行数:15,代码来源:twitter.py

示例11: __init__

	def __init__(self, testmode = False, scrolling = False):
		self.logger = logging.getLogger(__name__)
		threading.Thread.__init__(self, name='infodisplay')
		self.Event = threading.Event()
		self.logger.info("Starting InfoDisplay class")
		self.chgvol_flag = False
		self.vol_string = ' '
		if keys.board not in ['oled4', 'oled2', 'lcd', 'uoled', 'tft', 'emulator']:
			print 'Error: display type not recognised.'
			sys.exit()			
		print 'Infodisplay board = ',keys.board
		board = importlib.import_module(keys.board)
		self.myScreen = board.Screen()
		if keys.board == 'oled2':
			self.myScreen.set_rowcount(2)
		self.myWeather = Weather(keys.wunder, keys.locn)
		self.myWeather.start()
		self.ending = False
		self.myScreen.start()
		self.rowcount, self.rowlength = self.myScreen.info()
		self.writerow(TITLE_ROW, 'Starting up...'.center(self.rowlength))
#		self.update_info_row()
		self.lasttime = 0
		self.delta = 0.001
		self.scroll_pointer = SCROLL_PAUSE
		self.scroll_string = '       '
		self.prog = 'Info test'
		if testmode:
			self.timer = 2
		else:
			self.timer = INFOROWUPDATEPERIOD
		self.scrolling = scrolling
		self.told = time.clock()
开发者ID:andytopham,项目名称:podplayer,代码行数:33,代码来源:infodisplay.py

示例12: weather

 def weather(self, irc, msg, args, loc):
     """[location]
         location must be zip
         (sorry, you international folks have to go look out a window)
         tells you the current weather for your area
     """
     self._limit_api(irc, lambda:Weather.current(loc))
开发者ID:nod,项目名称:boombot,代码行数:7,代码来源:plugin.py

示例13: __init__

 def __init__(self, url):
     self._weather = Weather(url, 10)
     self.time = time.time()
     self._prev_time = time.time()
     self.temperature = 0
     self._prev_temperature = 0
     self.conditions = ''
     self._prev_conditions = ''
开发者ID:DrKylstein,项目名称:Media-Gizmo,代码行数:8,代码来源:weather_clock.py

示例14: severe

 def severe(self, irc, msg, args, loc):
     """[location]
         returns severe warnings for the area
         location must be zip
         (sorry, you international folks have to go look out a window)
         tells you the forecast for your area
     """
     self._limit_api(irc, lambda: Weather.severe(loc), 'no alerts')
开发者ID:nod,项目名称:boombot,代码行数:8,代码来源:plugin.py

示例15: __init__

	def __init__(self,rowcount=4):
		self.logger = logging.getLogger(__name__)
		Oled.__init__(self, rowcount)		# We are a subclass, so need to be explicit about which init
		if rowcount == 2:
			self.rowlength = 16
		else:
			self.rowlength = 20
		self.update_row1('Starting up...   ')
		self.myWeather = Weather()
		self.update_row2(1)
		self.lasttime = 0
		self.delta = 0.001
开发者ID:andytopham,项目名称:podplayer,代码行数:12,代码来源:uoledinfo.py


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