Example #1
0
class Backuptool(object):
    def __init__(self, config):
        """
        :type config lib.config.VocConfigParser
        """
        self.config = config

        # initialize mainloop
        self.log = logging.getLogger('Main')
        self.log.debug('creating GObject-MainLoop')
        self.mainloop = GObject.MainLoop()

        # initialize subsystem
        self.log.debug('creating Audio-Pipeline')
        self.statusServer = StatusServer(config)
        self.pipeline = Pipeline(config, self.statusServer)

    def run(self):
        self.log.info('starting Pipeline')
        self.pipeline.start()

        try:
            self.log.info('running GObject-MainLoop')
            self.mainloop.run()
        except KeyboardInterrupt:
            self.log.info('Terminated via Ctrl-C')

    def quit(self):
        self.log.info('quitting GObject-MainLoop')
        self.mainloop.quit()
Example #2
0
class SyncStream(object):
    def __init__(self):
        self.log = logging.getLogger('SyncStream')

        # initialize subsystem
        self.log.debug('creating A/V-Pipeline')
        self.pipeline = Pipeline()
        self.source = TCPSource(9999)
        self.netclock = NetClock(self.pipeline, None, 10000)
        self.do_run = True

    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 quit(self):
        self.do_run = False
        self.log.info('stopping Pipeline')
        self.pipeline.stop()
        self.log.info('quitting GObject-MainLoop')
        MainLoop.quit()

    def reload(self):
        self.log.info('reloading pipeline')
        self.pipeline.stop()
        self.pipeline.configure()
        self.pipeline.start()
Example #3
0
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()
Example #4
0
class LoudnessMonitor(object):
    def __init__(self):
        self.log = logging.getLogger('LoudnessMonitor')

        # initialize subsystem
        self.log.debug('creating A/V-Pipeline')
        self.pipeline = Pipeline()

    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')

    def quit(self):
        self.log.info('quitting GObject-MainLoop')
        MainLoop.quit()