本文整理汇总了Python中weather.Weather.start方法的典型用法代码示例。如果您正苦于以下问题:Python Weather.start方法的具体用法?Python Weather.start怎么用?Python Weather.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weather.Weather
的用法示例。
在下文中一共展示了Weather.start方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from weather import Weather [as 别名]
# 或者: from weather.Weather import start [as 别名]
#.........这里部分代码省略.........
return self.happy_colour.emotion
else:
return None
# update background image from a feature
def update_background_image(self, image):
if self.slideshow and self.slideshow.background_image.size > 0:
return self.slideshow.background_image
elif self.television and self.television.background_image.size > 0:
return self.television.background_image
else:
return image
# handle features
def handle(self, rocky_robot, sporty_robot, image):
self._handle_acting(rocky_robot, sporty_robot)
self._handle_browser(rocky_robot, sporty_robot)
self._handle_calculator(rocky_robot, sporty_robot)
self._handle_hand_gesture(rocky_robot, sporty_robot, image)
self._handle_happy_colour(rocky_robot, image)
self._handle_mixing_desk(rocky_robot)
self._handle_optical_character_recognition(rocky_robot, sporty_robot, image)
self._handle_phrase_translation(sporty_robot)
self._handle_play_your_cards_right(sporty_robot)
self._handle_slideshow(rocky_robot, sporty_robot, image)
self._handle_television(rocky_robot, sporty_robot, image)
self._handle_weather(rocky_robot, sporty_robot)
# handle acting
def _handle_acting(self, rocky_robot, sporty_robot):
if not self.acting: return
if rocky_robot.is_facing or sporty_robot.is_facing:
self.acting.start()
else:
self.acting.stop()
# handle browser
def _handle_browser(self, rocky_robot, sporty_robot):
if not self.browser: return
if rocky_robot.is_facing:
self.browser.start(ROCK)
elif sporty_robot.is_facing:
self.browser.start(SPORT)
else:
self.browser.stop()
# handle calculator
def _handle_calculator(self, rocky_robot, sporty_robot):
if not self.calculator: return
if rocky_robot.is_facing or sporty_robot.is_facing:
self.calculator.start()
else:
self.calculator.stop()
# handle hand gesture
def _handle_hand_gesture(self, rocky_robot, sporty_robot, image):
if not self.hand_gesture: return
if rocky_robot.is_facing or sporty_robot.is_facing:
self.hand_gesture.start(image)
else:
self.hand_gesture.stop()
示例2: InfoDisplay
# 需要导入模块: from weather import Weather [as 别名]
# 或者: from weather.Weather import start [as 别名]
class InfoDisplay(threading.Thread):
''' Richer info on the oled. '''
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()
def cleanup(self):
self.ending = True # must be first line.
time.sleep(1) # these delays needed to get cleanup to work
self.Event.set() # stop the display updates
try:
if self.rowcount == 2:
if self.scrolling:
self.scrollt.cancel()
time.sleep(1)
self.scrollt.cancel()
else:
self.t.cancel() # cancel timer for update display
except:
print 'Scroll timer not started'
self.myWeather.Event.set() # send the stop signal
self.myWeather.join(CLEANUPTIMEOUT) # wait for thread to finish
if self.myWeather.is_alive(): # so we timed out
print 'Weather thread did not die'
self.myScreen.Event.set()
self.myScreen.join(CLEANUPTIMEOUT) # wait for thread to finish
if self.myScreen.is_alive(): # so we timed out
print 'Screen thread did not die'
self.logger.info('Finished infodisplay cleanup.')
def clear(self):
'''Clear screen.'''
self.myScreen.clear()
def writerow(self, row, string):
if row < self.rowcount:
self.myScreen.q.put([row, string]) # add to the queue
else:
print 'Trying to write to non-existent row:', row
def run(self):
print 'Starting infodisplay thread'
myevent = False
while not myevent:
self.update_display()
myevent = self.Event.wait(self.timer) # wait for this timeout or the flag being set.
print 'Infodisplay exiting.'
def update_display(self):
'''Update the whole display, including the prog info and the status line.'''
self._update_info_row()
if self.rowcount == 2:
if self.scrolling:
self._scroll(self.prog)
else:
self.myScreen.q.put([TITLE_ROW,self.prog[:self.rowlength]]) # just show one row
else:
self._show_prog_info(self.prog)
# if not self.ending:
# print 'refreshing display update with timer = ',self.timer
# self.t = threading.Timer(self.timer, self.update_display)
# self.t.start()
# self.t.name = 'update_display'
return(0)
def _update_info_row(self):
'''Time and temperature display on the info line = bottom row.
This now repeats itself courtesy of the Timer.'''
clock = time.strftime("%H:%M")
if self.chgvol_flag:
#.........这里部分代码省略.........