Commits

Benoît Allard committed d112bf2

Handle case where the USB backend does not implement all the used methods

Comments (0)

Files changed (3)

 - Fix issue when ConnectionError happens during sync (issue#54)
 - Try again a write operation in case of IOError (issue#61)
 - Be more strict during discovery (issue#66)
+- Handle issue when USB backend does not implement non-mandatory methods
+  (issue#75)
 
 
 galileo 0.4 (2014-03-31)

galileo/dongle.py

                              ' dongle')
                 raise PermissionDeniedException
             raise
+        except NotImplementedError, nie:
+            logger.error("Hit some 'Not Implemented Error': '%s', moving on ...", nie)
 
         cfg = self.dev.get_active_configuration()
         self.DataIF = cfg[(0, 0)]

tests/testDongle.py

 import unittest
 
-from galileo.dongle import isStatus
+import galileo.dongle
+from galileo.dongle import isStatus, FitBitDongle
 
 class MyCM(object):
     def __init__(self, ins, payload):
 
     def testStartsWith(self):
         self.assertTrue(isStatus(MyCM(1, [0x61, 0x62, 0x63, 0x64 , 0]), 'ab'))
+
+class MyDev(object):
+    """ Minimal object to reproduce issue#75 """
+    def is_kernel_driver_active(self, a): raise NotImplementedError()
+    def get_active_configuration(self): return {(0,0): None, (1,0): None}
+    def set_configuration(self): pass
+
+class testDongle(unittest.TestCase):
+
+    def testNIE(self):
+        def myFind(*args, **kwargs):
+            return MyDev()
+        galileo.dongle.usb.core.find = myFind
+        d = FitBitDongle()
+        d.setup()