Exemplo n.º 1
0
def find_bricks(host=None, name=None):
    """Used by find_one_brick to look for bricks ***ADVANCED USERS ONLY***"""

    try:
        import usbsock
        usb_available = True
        socks = usbsock.find_bricks(host, name)
        for s in socks:
            yield s
    except ImportError:
        usb_available = False
        import sys
        print >>sys.stderr, "USB module unavailable, not searching there"
    
    try:
        import bluesock
        try:
            socks = bluesock.find_bricks(host, name)
            for s in socks:
                yield s
        except (bluesock.bluetooth.BluetoothError, IOError): #for cases such as no adapter, bluetooth throws IOError, not BluetoothError
            pass
    except ImportError:
        import sys
        print >>sys.stderr, "Bluetooth module unavailable, not searching there"
        if not usb_available:
            raise NoBackendError("Neither USB nor Bluetooth could be used! Did you install PyUSB or PyBluez?")
Exemplo n.º 2
0
def find_bricks(host=None, name=None):
    """Used by find_one_brick to look for bricks ***ADVANCED USERS ONLY***"""
    
    try:
        import usbsock
        usb_available = True
        socks = usbsock.find_bricks(host, name)
        for s in socks:
            yield s
    except ImportError:
        usb_available = False
        import sys
        print >>sys.stderr, "USB unavailable, not searching there"
    
    try:
        import bluesock
        try:
            socks = bluesock.find_bricks(host, name)
            for s in socks:
                yield s
        except (bluesock.bluetooth.BluetoothError, IOError):
            pass
    except ImportError:
        import sys
        print >>sys.stderr, "Bluetooth unavailable, not searching there"
        if not usb_available:
            raise NoBackendError("Neither USB nor Bluetooth could be used!")
Exemplo n.º 3
0
def find_bricks(host=None, name=None):
    """Used by find_one_brick to look for bricks ***ADVANCED USERS ONLY***"""

    try:
        import usbsock
        usb_available = True
        socks = usbsock.find_bricks(host, name)
        for s in socks:
            yield s
    except ImportError:
        usb_available = False
        import sys
        print >> sys.stderr, "USB module unavailable, not searching there"

    try:
        import bluesock
        try:
            socks = bluesock.find_bricks(host, name)
            for s in socks:
                yield s
        except (
                bluesock.bluetooth.BluetoothError, IOError
        ):  #for cases such as no adapter, bluetooth throws IOError, not BluetoothError
            pass
    except ImportError:
        import sys
        print >> sys.stderr, "Bluetooth module unavailable, not searching there"
        if not usb_available:
            raise NoBackendError(
                "Neither USB nor Bluetooth could be used! Did you install PyUSB or PyBluez?"
            )
Exemplo n.º 4
0
def find_bricks(host=None, name=None, silent=False, method=Method()):
    """Used by find_one_brick to look for bricks ***ADVANCED USERS ONLY***"""
    methods_available = 0

    if method.usb:
        try:
            import usbsock
            methods_available += 1
            socks = usbsock.find_bricks(host, name)
            for s in socks:
                yield s
        except ImportError:
            import sys
            if not silent: print >>sys.stderr, "USB module unavailable, not searching there"
    
    if method.bluetooth:
        try:
            import bluesock
            methods_available += 1
            try:
                socks = bluesock.find_bricks(host, name)
                for s in socks:
                    yield s
            except (bluesock.bluetooth.BluetoothError, IOError): #for cases such as no adapter, bluetooth throws IOError, not BluetoothError
                pass
        except ImportError:
            import sys
            if not silent: print >>sys.stderr, "Bluetooth module unavailable, not searching there"
    
    if method.device:
        try:
            import devsock
            methods_available += 1
            socks = devsock.find_bricks(name=name)
            for s in socks:
                yield s
        except IOError:
            pass

    if method.fantom:
        try:
            import fantomsock
            methods_available += 1
            if method.fantomusb:
                usbsocks = fantomsock.find_bricks(host, name, False)
                for s in usbsocks:
                    yield s
            if method.fantombt:
                btsocks = fantomsock.find_bricks(host, name, True)
                for s in btsocks:
                    yield s
        except ImportError:
            import sys
            if not silent: print >>sys.stderr, "Fantom module unavailable, not searching there"
    
    if methods_available == 0:
        raise NoBackendError("No selected backends are available! Did you install the comm modules?")
Exemplo n.º 5
0
def find_bricks(host=None, name=None):
    #try:
    #	import usbsock
    #	socks						= usbsock.find_bricks(host, name)
    #	for s in socks:
    #		yield s
    #except ImportError:
    #	pass
    try:
        import bluesock
        from bluetooth import BluetoothError
        try:
            socks = bluesock.find_bricks(host, name)
            for s in socks:
                yield s
        except BluetoothError:
            pass
    except ImportError:
        pass