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


Python System.return_hostname方法代码示例

本文整理汇总了Python中system.System.return_hostname方法的典型用法代码示例。如果您正苦于以下问题:Python System.return_hostname方法的具体用法?Python System.return_hostname怎么用?Python System.return_hostname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在system.System的用法示例。


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

示例1: __init__

# 需要导入模块: from system import System [as 别名]
# 或者: from system.System import return_hostname [as 别名]
class Executive:
	'''The main podplayer looping structure. '''
	def __init__(self):
		self.logger = logging.getLogger(__name__)
		self.logger.info("Starting executive class")
		#initialise the variables
		self.die = False
		self.next = False
		self.stop = False
		self.volup = False
		self.voldown = False
		self.chgvol_flag = False
		self.maxelapsed = 0
		self.error_string = ''

	def startup(self, verbosity):
		'''Initialisation for the objects that have variable startup behaviour'''
		self.myInfoDisplay = infodisplay.InfoDisplay()
#		self.myKey = keyboardpoller.KeyboardPoller()
#		self.myKey.start()
		try:
			if keys.board == 'emulator':
				import gpio_emulator
				import mpc_emulator
				self.myGpio = gpio_emulator.Gpio()
				self.myMpc = mpc_emulator.Mpc()
				host = 'dummy host'
				self.programmename = 'dummy prog\nTest\nSecond row'
			if keys.board == 'lcd':
				host = 'rotary host'
				import rotary
				self.myGpio = rotary.Rotary()
				self.myVol = rotary.Rotary(1)
				self.myMpc = mpc2.Mpc()
				print 'mpc has been setup'
#				count = self.myMpc.podcounter()
				self.mySystem = System()
				host = self.mySystem.return_hostname()
				print 'Hostname:', host
				self.programmename = self.myMpc.progname()
				print 'Prog:', self.programmename
#				remaining = self.myMpc.check_time_left()
			else:
				from mpc2 import Mpc
				import gpio
				self.myGpio = gpio.Gpio()
				self.myMpc = Mpc(False, True)		# Test mode, podmode
				count = self.myMpc.podcounter()
				self.mySystem = System()
				host = self.mySystem.return_hostname()
				self.programmename = self.myMpc.progname()
				remaining = self.myMpc.check_time_left()
		except:
			self.cleanup('Failed to start gpio')
#		self.myInfoDisplay.writerow(0,host)
#		self.myInfoDisplay.update_display()
		self.myInfoDisplay.prog = self.programmename
		self.myInfoDisplay.start()
		time.sleep(2)
		self.myInfoDisplay.prog = self.myMpc.progname()
		self.ending = False
		self.t = threading.Timer(AUDIOTIMEOUT, self.audiofunc)
		self.t.start()
		self.t.name = 'audiot'
		print threading.enumerate()		# helps debug
		print 'Thread count: ', threading.active_count()
#		self.check_threads()
		if False:								# set to true for testing
			self.cleanup('Forced cleanup')
		self.dt = threading.Timer(DEBUGTIMEOUT, self.debugfunc)
#		self.dt.start()
		self.dt.name = 'debugt'
		
	def check_threads(self):
		# a routine to check all the threads that should be started actually are.
		if myInfoDisplay.is_alive():
			print 'Infodisplay is alive'
		else:
			print 'Infodisplay is dead'
		for threadname in ('lcd', 'rotary'):
			if not threadname.is_alive():
				print 'Missing thread: ', threadname
		

	def audiofunc(self):
		'''Called by the audio timeout Timer. Implements the actual timeout function.'''
		print 'Timeout'
		self.logger.info('Audio timeout')
		self.myInfoDisplay.writerow(0,'Timeout              ')
		self.myMpc.stop()
		self.myInfoDisplay.prog = 'Timeout               '
		return(0)

	def reset_audio_timer(self):
		'''Resets the audio timeout Timer. Called by each button push.'''
		self.t.cancel()
		time.sleep(1)
		if not self.ending:
			self.t = threading.Timer(AUDIOTIMEOUT, self.audiofunc)
			self.t.start()
#.........这里部分代码省略.........
开发者ID:andytopham,项目名称:podplayer,代码行数:103,代码来源:executive.py


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