本文整理匯總了Python中tracker.Tracker.start方法的典型用法代碼示例。如果您正苦於以下問題:Python Tracker.start方法的具體用法?Python Tracker.start怎麽用?Python Tracker.start使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tracker.Tracker
的用法示例。
在下文中一共展示了Tracker.start方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from tracker import Tracker [as 別名]
# 或者: from tracker.Tracker import start [as 別名]
class Client:
def __init__(self, config: ConfigurationFile):
self.config = config
self.database = Database(self.config.db_file)
self.organizer = Organizer(self.config, self.config.db_file)
self.downloader = Downloader(self.config.db_file, self.organizer,
self.config)
self.tracker = Tracker(self.config.db_file, self.downloader,
self.config.update_period)
self.tracker.start()
self.downloader.start()
self.organizer.start()
def add_tvshow(self, tvshow_id: int):
tvshow_name = showrss.get_name(tvshow_id)
self.database.put_tvshow(TVShow(tvshow_id, tvshow_name))
def remove_tvshow(self, tvshow_id: int):
self.database.remove_tvshow(tvshow_id)
def list_tvshows(self):
return self.database.tvshows()
def list_episodes(self, state: EpisodeState = None):
return self.database.episodes(state)
def download_progress(self):
return self.downloader.downloads()
def exit(self):
self.tracker.stop()
self.downloader.stop()
示例2: App
# 需要導入模塊: from tracker import Tracker [as 別名]
# 或者: from tracker.Tracker import start [as 別名]
class App(object):
"""Manage application controllers, respond to user input, run master loop.
This class wraps together the various components of the application. It is
the application entry point. On startup, it creates an instance of each
controller. The run() method starts each controller and runs the master loop
until the user quits.
Settings:
experimentName: used to label the output directory and in output metadata
keyBindings: a dictionary where the keys are 'quit', 'toggleStimulator',
and 'triggerStimulator', and the values are one-character strings
representing the button that triggers the action specified by the key
outputRootDir: directory where the folder containing trial data will be
created
"""
def __init__(self, **kwargs):
"""Initialize the keycode bindings and all controllers, create output dir."""
settings = {
'experimentName' : 'someNameHere',
'outputRootDir' : os.path.normpath(os.path.expanduser("~/kauferdata")),
'keyBindings' : {
'quit' : 'q',
'toggleStimulator' : 't',
'triggerStimulator' : 's'
},
'audio' : {},
'gui' : {},
'stimulator' : { 'activeProtocolName' : 'nucleusAccumbensExample' },
'tracker' : {},
'videoIn' : {},
'videoOut' : {},
'writer' : {},
}
settings.update(kwargs)
trialDir = "{0}_{1}_{2}".format(time.strftime("%y%m%d%H%M%S"),
settings['experimentName'], settings['stimulator']['activeProtocolName'])
settings['outputDataDir'] = os.path.join(settings['outputRootDir'], trialDir)
self.keyBindings = settings['keyBindings']
self.keycodeBindings = {k: getattr(opencvgui.keycodes, v)
for k,v in self.keyBindings.items() }
os.makedirs(os.path.join(settings['outputDataDir'], 'audio'))
self.writeExperimentData(settings)
for x in ['audio', 'videoOut', 'writer']:
kwargs[x] = {} if not kwargs.has_key(x) else kwargs[x]
kwargs[x]['outputDataDir'] = settings['outputDataDir']
# gui and writer both need a reference to the app instance because they
# draw on the state of so many other controllers
self.audio = Audio(**settings['audio'])
self.gui = Gui(self, **settings['gui'])
self.stimulator = Stimulator(**settings['stimulator'])
self.tracker = Tracker(**settings['tracker'])
self.videoIn = VideoIn(**settings['videoIn'])
self.videoOut = VideoOut(**settings['videoOut'])
self.writer = Writer(self, **settings['writer'])
def run(self):
"""Respond to user input and run the master application loop.
This method has three basic sections. Before the loop starts, the start()
method is called on all controllers. The central loop calls update() on
each controller until it is terminated by a user-issued quit keystroke.
Keystrokes are listened for at the start of each loop iteration.
"""
self.printKeybindings()
self.startTime = self.lastTime = time.clock()
self.audio.start()
self.gui.start()
self.stimulator.start()
self.tracker.start()
self.videoIn.start()
self.videoOut.start()
self.writer.start()
while True:
# respond to user input
lastKeyStroke = cv2.waitKey(20) # 20 is the number of ms to wait for key
if lastKeyStroke != -1: # -1 means there was no keystroke
if lastKeyStroke == self.keycodeBindings['quit']:
break
if lastKeyStroke == self.keycodeBindings['triggerStimulator']:
self.stimulator.trigger()
if lastKeyStroke == self.keycodeBindings['toggleStimulator']:
self.stimulator.toggle()
# update state
self.currTime = time.clock()
self.totalTimeElapsed = self.currTime - self.startTime
self.audio.update()
self.videoIn.update()
self.tracker.update(self.videoIn, self.currTime)
self.stimulator.update(self.currTime, self.tracker)
self.videoOut.update(self.videoIn, self.tracker, self.stimulator)
self.gui.update()
self.lastTime = self.currTime
self.writer.update()
#.........這裏部分代碼省略.........
示例3: print
# 需要導入模塊: from tracker import Tracker [as 別名]
# 或者: from tracker.Tracker import start [as 別名]
from operator import itemgetter, attrgetter
from tracker import Tracker
import signal
import os
if __name__ == "__main__":
import sys
print ("argv =" + str(len(sys.argv)) )
for x in sys.argv :
print ( ("argv[n] ="+ x) )
# ..create timer thread
t = Tracker()
t.start()
# Get File name
pathname, scriptname = os.path.split( __file__ )
filesplit = scriptname.split('.')
fname = "{0}.pid".format(filesplit[0])
# Create PID file
pidfile = "/var/run/{0}".format(fname)
f = open(pidfile, 'w')
f.write(str(os.getpid()))
f.close()
"""
Define termination handler for busapi Application.
Define a Signal handler for SIGTERM