def start_timecode(self, cue): """Start the timecode, using the given cue.""" # Test and create client, if needed, return on fail if not self.__client: try: self.__client = OlaClient() except OLADNotRunningException: logging.debug('TIMECODE: Cannot track cue, OLA not running.') return # Load cue settings, if enabled, otherwise return if not cue.timecode['enabled']: return # Stop the currently "running" timecode self.stop_timecode() # Reload format settings self.__hres = config['Timecode'].getboolean('hres') self.__format = TcFormat[config['Timecode']['format']].format self.__millis = TcFormat[config['Timecode']['format']].millis # Setup new cue and options self.__cue = cue self.__cue_time = HRCueTime(cue) if self.__hres else CueTime(cue) self.__replace_hours = cue.timecode['replace_hours'] self.__track = cue.timecode['track'] # Start watching the new cue self.__cue_time.notify.connect(self.__send_timecode, Connection.QtQueued)
def __init__(self): try: self.__client = OlaClient() except OLADNotRunningException: self.__client = None self.__cue = None self.__cue_time = None self.__track = 0 self.__hres = config['Timecode'].getboolean('hres') self.__format = TcFormat[config['Timecode']['format']].format self.__millis = TcFormat[config['Timecode']['format']].millis self.__replace_hours = False self.__last_frame = -1
class ClientWrapper(object): def __init__(self, socket=None): self._ss = SelectServer() self._client = OlaClient(socket) self._ss.AddReadDescriptor(self._client.GetSocket(), self._client.SocketReady) def Stop(self): self._ss.Terminate() def StopIfNoEvents(self): self._ss.StopIfNoEvents() def Reset(self): self._ss.Reset() def Client(self): return self._client def Run(self): self._ss.Run() def AddEvent(self, time_in_ms, callback): """Schedule an event to run in the future. Args: time_in_ms: An interval in milliseconds when this should run. callback: The function to run. """ self._ss.AddEvent(time_in_ms, callback)
def main(): options = parse_options() settings.update(options.__dict__) pid_store = PidStore.GetStore(options.pid_store, ('pids.proto')) logging.basicConfig(level=logging.INFO, format='%(message)s') SetupLogDirectory(options) #Check olad status logging.info('Checking olad status') try: ola_client = OlaClient() except OLADNotRunningException: logging.error('Error creating connection with olad. Is it running?') sys.exit(127) ola_thread = OLAThread(ola_client) ola_thread.start() test_thread = RDMTestThread(pid_store, settings['log_directory']) test_thread.start() app = BuildApplication(ola_thread, test_thread) httpd = make_server('', settings['PORT'], app.HandleRequest) logging.info('Running RDM Tests Server on %s:%s' % ('127.0.0.1', httpd.server_port)) try: httpd.serve_forever() except KeyboardInterrupt: pass ola_thread.Stop() test_thread.Stop() ola_thread.join() test_thread.join()
def testOla(self): if self.activateBox.isChecked(): try: client = OlaClient() del client except OLADNotRunningException: QMessageBox.warning( MainWindow(), translate('TimecodeSettings', 'OLA status'), translate('TimecodeSettings', 'OLA is not running - start the OLA daemon.'))
class ClientWrapper(object): def __init__(self): self._quit = False self._sock = socket.socket() self._sock.connect(('localhost', 9010)) self._client = OlaClient(self._sock) def Stop(self): self._quit = True def Client(self): return self._client def Run(self): while not self._quit: i, o, e = select.select([self._sock], [], []) if self._sock in i: self._client.SocketReady()
def __init__(self, socket=None): self._ss = SelectServer() self._client = OlaClient(socket) self._ss.AddReadDescriptor(self._client.GetSocket(), self._client.SocketReady)
def __init__(self): self._quit = False self._sock = socket.socket() self._sock.connect(('localhost', 9010)) self._client = OlaClient(self._sock)
class OlaTimecode: def __init__(self): try: self.__client = OlaClient() except OLADNotRunningException: self.__client = None self.__cue = None self.__cue_time = None self.__track = 0 self.__hres = config['Timecode'].getboolean('hres') self.__format = TcFormat[config['Timecode']['format']].format self.__millis = TcFormat[config['Timecode']['format']].millis self.__replace_hours = False self.__last_frame = -1 @property def cue(self): return self.__cue def status(self): return bool(self.__client) def start_timecode(self, cue): """Start the timecode, using the given cue.""" # Test and create client, if needed, return on fail if not self.__client: try: self.__client = OlaClient() except OLADNotRunningException: logging.debug('TIMECODE: Cannot track cue, OLA not running.') return # Load cue settings, if enabled, otherwise return if not cue.timecode['enabled']: return # Stop the currently "running" timecode self.stop_timecode() # Reload format settings self.__hres = config['Timecode'].getboolean('hres') self.__format = TcFormat[config['Timecode']['format']].format self.__millis = TcFormat[config['Timecode']['format']].millis # Setup new cue and options self.__cue = cue self.__cue_time = HRCueTime(cue) if self.__hres else CueTime(cue) self.__replace_hours = cue.timecode['replace_hours'] self.__track = cue.timecode['track'] # Start watching the new cue self.__cue_time.notify.connect(self.__send_timecode, Connection.QtQueued) def stop_timecode(self, rclient=False, rcue=False): """Stop the timecode :param rclient: Reset the client :param rcue: Reset the cues """ if self.__cue_time is not None: self.__cue_time.notify.disconnect(self.__send_timecode) self.__last_frame = -1 if rclient: self.__client = None if rcue: self.__cue = None self.__cue_time = None def __send_timecode(self, time): tt = time_tuple(time) frame = int(tt[3] / self.__millis) if self.__hres: if self.__last_frame == frame: return self.__last_frame = frame try: if not self.__replace_hours: track = tt[0] else: track = self.__track self.__client.SendTimeCode(self.__format, track, tt[1], tt[2], frame) except OLADNotRunningException: self.stop_timecode(rclient=True, rcue=True) elogging.error(translate('Timecode', 'Cannot send timecode.'), details=translate('Timecode', 'OLA has stopped.')) except Exception as e: self.stop_timecode(rclient=True, rcue=True) elogging.exception('Cannot send timecode.', e, dialog=False)