本文整理汇总了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