def scanmdns(): if not libdaap.mdns_init(): print 'error: no Bonjour support detected on system' sys.exit(1) callback = libdaap.mdns_browse(mdns_browse_callback) while True: refs = callback.get_refs() try: r, w, x = select.select(refs, [], []) for i in r: callback(i) except select.error, (err, errstring): if err == errno.EINTR: continue else: raise
def main(argc, argv): # Set some defaults. prognam = argv[0] use_mdns = True debug = False kwargs = dict() try: try: opts, args = getopt.getopt(argv[1:], 'p:c:vhdM') except getopt.GetoptError, e: print str(e) usage(prognam) # NOTREACHED for o, a in opts: if o == '-d': debug = True if o == '-p': kwargs['port'] = int(a) if o == '-v': version(prognam) # NOTREACHED if o == '-c': kwargs['max_conn'] = int(a) if o == '-M': use_mdns = False if o == '-h': usage(prognam) # NOTREACHED if len(args) <= 1: token = None else: token = args[0] # XXX hardcoded module for ready-to-eat server. backend = googlebackend.Backend(token) if debug: print 'info: debug on' server = libdaap.make_daap_server(backend, debug=debug, **kwargs) if not server: raise RuntimeError('Cannot instiantiate server instance') # In robust mode, the server can return a port that's different # from the one we requested. address, port = server.server_address kwargs['port'] = port refs = [] server_fileno = server.fileno() if use_mdns: if not libdaap.mdns_init(): print 'warning: no mdns support found on system, disabled' else: callback = libdaap.mdns_register_service('pydaap', mdns_register_callback, **kwargs) refs = callback.get_refs() while True: try: rset = [server_fileno] + refs r, w, x = select.select(rset, [], []) for ref in refs: if ref in r: callback(ref) if server_fileno in r: server.handle_request() except select.error, (err, errstring): if err == errno.EINTR: continue else: raise
def main(argc, argv): # Set some defaults. prognam = argv[0] use_mdns = True debug = False kwargs = dict() try: try: opts, args = getopt.getopt(argv[1:], 'p:c:vhdM') except getopt.GetoptError, e: print str(e) usage(prognam) # NOTREACHED for o, a in opts: if o == '-d': debug = True if o == '-p': kwargs['port'] = int(a) if o == '-v': version(prognam) # NOTREACHED if o == '-c': kwargs['max_conn'] = int(a) if o == '-M': use_mdns = False if o == '-h': usage(prognam) # NOTREACHED if len(args) <= 1: token = None else: token = args[0] # XXX hardcoded module for ready-to-eat server. backend = googlebackend.Backend(token) if debug: print 'info: debug on' server = libdaap.make_daap_server(backend, debug=debug, **kwargs) if not server: raise RuntimeError('Cannot instiantiate server instance') # In robust mode, the server can return a port that's different # from the one we requested. address, port = server.server_address kwargs['port'] = port refs = [] server_fileno = server.fileno() if use_mdns: if not libdaap.mdns_init(): print 'warning: no mdns support found on system, disabled' else: callback = libdaap.mdns_register_service( 'pydaap', mdns_register_callback, **kwargs) refs = callback.get_refs() while True: try: rset = [server_fileno] + refs r, w, x = select.select(rset, [], []) for ref in refs: if ref in r: callback(ref) if server_fileno in r: server.handle_request() except select.error, (err, errstring): if err == errno.EINTR: continue else: raise