Browse Source

Boolean return values for write() on interfaces

Matt Sparks 15 years ago
parent
commit
d765de72d9
2 changed files with 8 additions and 2 deletions
  1. 1 1
      alphasign/interfaces/base.py
  2. 7 1
      alphasign/interfaces/local.py

+ 1 - 1
alphasign/interfaces/base.py

@@ -9,7 +9,7 @@ import alphasign.text
 
 class BaseInterface(object):
   def write(self, data):
-    pass
+    return False
 
   def clear_memory(self):
     """Clear the sign's memory.

+ 7 - 1
alphasign/interfaces/local.py

@@ -46,7 +46,12 @@ class Serial(base.BaseInterface):
       return
     if self.debug:
       print "Writing packet: %s" % repr(packet)
-    self._conn.write(str(packet))
+    try:
+      self._conn.write(str(packet))
+    except OSError:
+      return False
+    else:
+      return True
 
 
 class DebugInterface(base.BaseInterface):
@@ -66,4 +71,5 @@ class DebugInterface(base.BaseInterface):
   def write(self, packet):
     if self.debug:
       print "Writing packet: %s" % repr(packet)
+    return True