Skip to content

Commit b4acb04

Browse files
author
marcusw
committed
Fixed some fudged logic in locator.py, in preparation for mac support.
1 parent 66a4764 commit b4acb04

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

nxt/locator.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# GNU General Public License for more details.
1414

1515
class BrickNotFoundError(Exception):
16-
pass
17-
16+
pass
17+
1818
class NoBackendError(Exception):
1919
pass
2020

@@ -33,13 +33,23 @@ def find_bricks(host=None, name=None):
3333
print >>sys.stderr, "USB unavailable, not searching there"
3434

3535
try:
36-
from bluetooth import BluetoothError
36+
import bluesock
3737
try:
38-
import bluesock
3938
socks = bluesock.find_bricks(host, name)
4039
for s in socks:
4140
yield s
42-
except (BluetoothError, IOError):# BluetoothError or IOError: #for cases such as no adapter, bluetooth throws IOError, not BluetoothError
41+
except:
42+
#"except:" is dangerous and the code in the above try: block should
43+
#be treated with extreme caution. Any errors in it will be dropped
44+
#silently.
45+
#This is necessary to provide a higher level of abstraction above
46+
#the "bluetooth" module on linux/windows and the "lightblue" module
47+
#on mac, since catching bluetooth errors would involve a non-cross-
48+
#platform "import bluetooth", which also happens to break compata-
49+
#bility with lightblueglue even when used externally.
50+
#When testing modifications to the try: block, it may be helpful to
51+
#add "import sys; print sys.exc_info()" right below this message, to
52+
#print out any errors.
4353
pass
4454
except ImportError:
4555
import sys

0 commit comments

Comments
 (0)