本文整理匯總了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()
#.........這裏部分代碼省略.........