Skip to content

Commit

Permalink
Merge pull request schodet#129 from GolddolphinSKB-Fexcraftian/master
Browse files Browse the repository at this point in the history
Update locator.py (fantomsock.py needs to be deleted as well)
  • Loading branch information
Eelviny authored Mar 5, 2018
2 parents 95e2516 + 136a11f commit 8beaac2
Showing 1 changed file with 3 additions and 22 deletions.
25 changes: 3 additions & 22 deletions nxt/locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@ class NoBackendError(Exception):
class Method():
"""Used to indicate which comm backends should be tried by find_bricks/
find_one_brick. Any or all can be selected."""
def __init__(self, usb=True, bluetooth=True, fantomusb=False, fantombt=False, device=False):
def __init__(self, usb=True, bluetooth=True, device=False):
#new method options MUST default to False!
self.usb = usb
self.bluetooth = bluetooth
self.fantom = fantomusb or fantombt
self.fantomusb = fantomusb
self.fantombt = fantombt
self.device = device

def find_bricks(host=None, name=None, silent=False, method=Method()):
Expand Down Expand Up @@ -72,22 +69,6 @@ def find_bricks(host=None, name=None, silent=False, method=Method()):
except IOError:
pass

if method.fantom:
try:
from . 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("Fantom module unavailable, not searching there", file=sys.stderr)

if methods_available == 0:
raise NoBackendError("No selected backends are available! Did you install the comm modules?")

Expand Down Expand Up @@ -119,7 +100,7 @@ def find_one_brick(host=None, name=None, silent=False, strict=None, debug=False,
if not method: method = Method()
if debug:
print("Host: %s Name: %s Strict: %s" % (host, name, str(strict)))
print("USB: %s BT: %s Fantom: %s FUSB: %s FBT: %s" % (method.usb, method.bluetooth, method.fantom, method.fantomusb, method.fantombt))
print("USB: {} BT: {}".format(method.usb, method.bluetooth))

for s in find_bricks(host, name, silent, method):
try:
Expand Down Expand Up @@ -194,7 +175,7 @@ def make_config(confpath=None):
conf.set('Brick', 'name', 'MyNXT')
conf.set('Brick', 'host', '54:32:59:92:F9:39')
conf.set('Brick', 'strict', 0)
conf.set('Brick', 'method', 'usb=True, bluetooth=False, fantomusb=True')
conf.set('Brick', 'method', 'usb=True, bluetooth=False')
conf.write(open(confpath, 'w'))
print("The file has been written at %s" % confpath)
print("The file contains less-than-sane default values to get you started.")
Expand Down

0 comments on commit 8beaac2

Please sign in to comment.