Minor fixes for Windows.

To be backwards compatible, using Windows with hidapi is not forbidden. But now, you have to select it explicitly.
pull/8/head^2
Ben Sartori 6 months ago
parent aba522f665
commit 312715845b
  1. 12
      lednamebadge.py
  2. 7
      tests/test_lednamebadge_select_method.py

@ -903,11 +903,7 @@ class LedNameBadge:
sys.exit(1)
if method == hidapi.get_name():
if sys.platform.startswith('win'):
print("For Windows, please use method '%s' or 'auto'." % (libusb.get_name(),))
print("Or help us implementing support for Windows.")
sys.exit(1)
elif sys.version_info[0] < 3:
if sys.version_info[0] < 3:
print("Please use method '%s' or 'auto' with python-2.x" % (libusb.get_name(),))
print("because of https://github.com/jnweiger/led-badge-ls32/issues/9")
sys.exit(1)
@ -915,6 +911,12 @@ class LedNameBadge:
LedNameBadge._print_hidapi_install_hints(hidapi.get_name())
sys.exit(1)
if sys.platform.startswith('win') and hidapi.is_ready():
print("Method '%s' is not tested under Windows. If not working, please use '%s' or 'auto'" % (
hidapi.get_name(), libusb.get_name()))
print("Or help us implementing support for Windows.")
# But it is not forbidden
first_method_found = None
for m in auto_order_methods:
if method == 'auto' or method == m.get_name():

@ -127,7 +127,12 @@ class Test(abstract_witre_method_test.AbstractWriteMethodTest):
def test_windows_negative(self):
method, output = self.call_find(True, False, True, 'hidapi', 'auto')
self.assertNotIn('device initialized', output)
self.assertIn('please use method', output)
self.assertIn('is not possible to be used', output)
self.assertIsNone(method)
method, output = self.call_find(True, True, False, 'hidapi', 'auto')
self.assertNotIn('device initialized', output)
self.assertIn('If not working, please use', output)
self.assertIsNone(method)
@patch('sys.platform', new='darwin')

Loading…
Cancel
Save