本文整理汇总了Python中weather.Weather.join方法的典型用法代码示例。如果您正苦于以下问题:Python Weather.join方法的具体用法?Python Weather.join怎么用?Python Weather.join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weather.Weather
的用法示例。
在下文中一共展示了Weather.join方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: InfoDisplay
# 需要导入模块: from weather import Weather [as 别名]
# 或者: from weather.Weather import join [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:
#.........这里部分代码省略.........