1
2
3
4
5
6
7
8
9
10
11
12
13
14
17
20
22 """Used by find_one_brick to look for bricks ***ADVANCED USERS ONLY***"""
23
24 try:
25 import usbsock
26 usb_available = True
27 socks = usbsock.find_bricks(host, name)
28 for s in socks:
29 yield s
30 except ImportError:
31 usb_available = False
32 import sys
33 print >>sys.stderr, "USB unavailable, not searching there"
34
35 try:
36 from bluetooth import BluetoothError
37 try:
38 import bluesock
39 socks = bluesock.find_bricks(host, name)
40 for s in socks:
41 yield s
42 except BluetoothError:
43 pass
44 except ImportError:
45 import sys
46 print >>sys.stderr, "Bluetooth unavailable, not searching there"
47 if not usb_available:
48 raise NoBackendError("Neither USB nor Bluetooth could be used!")
49
50
52 """Use to find one brick. After it returns a usbsock object or a bluesock
53 object, use .connect() to connect to the brick, which returns a brick
54 object."""
55 for s in find_bricks(host, name):
56 return s
57 raise BrickNotFoundError
58