aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTC Wan2011-04-27 15:21:17 +0800
committerTC Wan2011-04-27 15:21:17 +0800
commit0bf5f4efbea18e4402814f8cacd79967a4257e50 (patch)
treeac9f491ae38adb9cbcb02e212f32fd16b020092f
parenta5cf3be2fd6c279c2a59e229915c4461bbd060cb (diff)
wip pyfantom support
Some minor cleanups for pyfantom support
-rw-r--r--nxt-python-fantom/nxt/fantomglue.py4
-rw-r--r--nxt-python-fantom/nxt/pyusbglue.py4
-rw-r--r--nxt-python-fantom/nxt/usbsock.py3
3 files changed, 7 insertions, 4 deletions
diff --git a/nxt-python-fantom/nxt/fantomglue.py b/nxt-python-fantom/nxt/fantomglue.py
index 89c08b2..5e85e03 100644
--- a/nxt-python-fantom/nxt/fantomglue.py
+++ b/nxt-python-fantom/nxt/fantomglue.py
@@ -91,6 +91,10 @@ class USBSocket:
self._sock = device
self.debug = False
+ def device_name(self):
+ devinfo = self._sock.deviceinfo()
+ return devinfo.name
+
def connect(self):
addr, port = addrport
if self._sock is None:
diff --git a/nxt-python-fantom/nxt/pyusbglue.py b/nxt-python-fantom/nxt/pyusbglue.py
index 2d64d24..40f708b 100644
--- a/nxt-python-fantom/nxt/pyusbglue.py
+++ b/nxt-python-fantom/nxt/pyusbglue.py
@@ -28,8 +28,8 @@ class USBSocket:
self.handle = None
self.debug = False
- def __str__(self):
- return 'USB (%s)' % (self.device.filename)
+ def device_name(self):
+ return self.device.filename
def connect(self):
'Use to connect to NXT.'
diff --git a/nxt-python-fantom/nxt/usbsock.py b/nxt-python-fantom/nxt/usbsock.py
index 3e2ed58..78c21ab 100644
--- a/nxt-python-fantom/nxt/usbsock.py
+++ b/nxt-python-fantom/nxt/usbsock.py
@@ -29,8 +29,7 @@ class USBSock(object):
self.debug = False
def __str__(self):
- # FIXME: This breaks encapsulation
- return 'USB (%s)' % (self.sock.filename)
+ return 'USB (%s)' % (self.sock.device_name())
def connect(self):
'Use to connect to NXT.'