本文整理汇总了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
示例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])
示例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()))
示例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)]
示例5: checkWeather
def checkWeather(self):
wi = WeatherInfo()
wi.parse(self._location)
newWeather = Weather()
newWeather.extractData(wi,self._unit)
self._weather = newWeather
self.update()
示例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()
示例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
示例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())
示例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!"
示例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)
示例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()
示例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))
示例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 = ''
示例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')
示例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