def main(argv): (opts, args) = get_option_parser().parse_args(argv) if len(args) != 2: print get_option_parser().get_usage() return 1 path = os.path.abspath(args[1]) instance = pynorm.Instance() instance.setCacheDirectory(path) try: instance.openDebugPipe(opts.pipe) except pynorm.NormError: print 'Could not connect to pipe, disabling...' pynorm.setDebugLevel(opts.debug) manager = Manager(instance) manager.register(pynorm.NORM_RX_OBJECT_INFO, newObject, path) # manager.register(pynorm.NORM_RX_OBJECT_UPDATED, updatedObject) manager.register(pynorm.NORM_RX_OBJECT_COMPLETED, complete) manager.register(pynorm.NORM_RX_OBJECT_ABORTED, abort) manager.start() session = instance.createSession(opts.address, opts.port) if opts.iface: session.setMulticastInterface(opts.iface) session.startReceiver(1024 * 1024) print 'Starting listener on %s:%i' % (opts.address, opts.port) try: while True: manager.join(2) except KeyboardInterrupt: pass print 'Exiting...' instance.stop() manager.join() return 0
def main(argv): (opts, args) = get_option_parser().parse_args(argv) if len(args) != 2: print get_option_parser().get_usage() return 1 path = os.path.abspath(args[1]) instance = pynorm.Instance() instance.setCacheDirectory(path) try: instance.openDebugPipe(opts.pipe) except pynorm.NormError: print 'Could not connect to pipe, disabling...' pynorm.setDebugLevel(opts.debug) manager = Manager(instance) manager.register(pynorm.NORM_RX_OBJECT_INFO, newObject, path) # manager.register(pynorm.NORM_RX_OBJECT_UPDATED, updatedObject) manager.register(pynorm.NORM_RX_OBJECT_COMPLETED, complete) manager.register(pynorm.NORM_RX_OBJECT_ABORTED, abort) manager.start() session = instance.createSession(opts.address, opts.port) if opts.iface: session.setMulticastInterface(opts.iface) session.startReceiver(1024*1024) print 'Starting listener on %s:%i' % (opts.address, opts.port) try: while True: manager.join(2) except KeyboardInterrupt: pass print 'Exiting...' instance.stop() manager.join() return 0
def main(argv): (opts, args) = get_option_parser().parse_args(argv) if len(args) != 2: print get_option_parser().get_usage() return 1 instance = pynorm.Instance() session = instance.createSession(opts.address, opts.port) if opts.iface: session.setMulticastInterface(opts.iface) session.startReceiver(1024 * 1024) session.startSender(randint(0, 1000), 1024**2, 1400, 64, 16) stream = session.streamOpen(1024 * 1024) gui = Gui(stream, args[1]) manager = Manager(instance) manager.register(pynorm.NORM_RX_OBJECT_UPDATED, lambda e: gui.showText(e.object.streamRead(1024)[1])) # manager.register(pynorm.NORM_RX_OBJECT_INFO, # lambda e: gui.showText('%s joined the chat' % e.object.info)) manager.start() try: curses.wrapper(gui) except KeyboardInterrupt: pass print 'Exiting...' stream.streamClose(True) instance.stop() manager.join() return 0
def main(argv): (opts, args) = get_option_parser().parse_args(argv) if len(args) != 2: print get_option_parser().get_usage() return 1 instance = pynorm.Instance() session = instance.createSession(opts.address, opts.port) if opts.iface: session.setMulticastInterface(opts.iface) session.startReceiver(1024*1024) session.startSender(randint(0, 1000), 1024**2, 1400, 64, 16) stream = session.streamOpen(1024*1024) gui = Gui(stream, args[1]) manager = Manager(instance) manager.register(pynorm.NORM_RX_OBJECT_UPDATED, lambda e: gui.showText(e.object.streamRead(1024)[1])) # manager.register(pynorm.NORM_RX_OBJECT_INFO, # lambda e: gui.showText('%s joined the chat' % e.object.info)) manager.start() try: curses.wrapper(gui) except KeyboardInterrupt: pass print 'Exiting...' stream.streamClose(True) instance.stop() manager.join() return 0