def run(self): self.pipeline.configure() self.pipeline.start() self.netclock.start() self.do_run = True self.log.info('running GObject-MainLoop') MainLoop.run()
def main(): global conf, macMapping, hostAddress, t, ready, ncdict, pipeline # configure logging docolor = (Args.color == 'always') or (Args.color == 'auto' and sys.stderr.isatty()) handler = LogHandler(docolor) logging.root.addHandler(handler) if Args.verbose >= 2: level = logging.DEBUG elif Args.verbose == 1: level = logging.INFO else: level = logging.WARNING level = logging.DEBUG logging.root.setLevel(level) #load config conf = loadconfig("config.json") macMapping = conf["macMapping"] hostAddress = conf["hostAddress"] #start server t = threading.Thread(target=run_server) t.start() if clearOnStart: try: shutil.rmtree("./config") except FileNotFoundError: pass while not ready: try: time.sleep(2) print("\x1b[2J\x1b[H") monitorManager.load() print('syncstream ready') print('- registered clients -') for mon in monitorManager.monitors: print('{}: {} ({})'.format(mon.index, mon.ip, mon.mac)) print('press ctrl+c to start') except KeyboardInterrupt: print('Starting!') # make killable by ctrl-c logging.debug('setting SIGINT handler') signal.signal(signal.SIGINT, signal.SIG_DFL) # init main-class and main-loop logging.debug('Creating Pipeline') pipeline = Pipeline() source = TCPSource(9999) netclock = NetClock(pipeline, None, 10000) pipeline.configure() pipeline.start() netclock.start() ncdict = netclock.netprov ready = True logging.info('running GObject MainLoop') MainLoop.run()
def run(self): self.pipeline.configure() self.pipeline.start() try: self.log.info('running GObject-MainLoop') MainLoop.run() except KeyboardInterrupt: self.log.info('Terminated via Ctrl-C')
class RemoteApp: usb_active = False remote = False def __init__(self): self.logger = Logger() self.main_loop = MainLoop() self.usb = Usb() self.action = Action() Logger.log('Init RemoteApp', True) def run(self): self.main_loop.set_interval(self.main, .1) def find_usb_device(self): tty_usb = self.usb.find() if tty_usb: try: success = self.usb.setup(tty_usb) if success: self.usb_active = True except Exception as error: Logger.error(error) def remote_action(self): error = self.usb.get_errors() if len(error): Logger.error(error) self.usb_active = False else: action_codes = self.usb.get_codes() for code in action_codes: self.action.run(code) def main(self): if not self.usb_active: self.find_usb_device() else: self.remote_action()
def on_eos(self, bus, message): self.log.debug( 'Received End-of-Stream-Signal on Source-Pipeline, shutting down') MainLoop.quit()
def quit(self): self.do_run = False self.log.info('stopping Pipeline') self.pipeline.stop() self.log.info('quitting GObject-MainLoop') MainLoop.quit()
def __init__(self): self.logger = Logger() self.main_loop = MainLoop() self.usb = Usb() self.action = Action() Logger.log('Init RemoteApp', True)
def quit(self): self.log.info('quitting GObject-MainLoop') MainLoop.quit()
def run(self): try: self.log.info('running GObject-MainLoop') MainLoop.run() except KeyboardInterrupt: self.log.info('Terminated via Ctrl-C')
def on_eos(self, bus, message): self.log.debug('Received End-of-Stream-Signal on Source-Pipeline, shutting down') MainLoop.quit()