From 01234592fd6fc91efc52eae4a5dad36ced16c150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Thu, 24 Oct 2024 14:00:53 +0200 Subject: [PATCH] add get sub port --- bin/getUSBport.py | 15 +++++++++++++++ labhw/__init__.py | 2 +- setup.py | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 bin/getUSBport.py diff --git a/bin/getUSBport.py b/bin/getUSBport.py new file mode 100644 index 0000000..d7ae0fc --- /dev/null +++ b/bin/getUSBport.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +import sys +import labhw + + +name = 'Arduino__www_arduino_cc__75833353035351903182' +name = sys.argv[1] + +devices = labhw.list_USB_devices() + +try: + print(devices[name]) +except KeyError as e: + raise RuntimeError(f"unknown device {name}") diff --git a/labhw/__init__.py b/labhw/__init__.py index fe815bc..517ecd8 100644 --- a/labhw/__init__.py +++ b/labhw/__init__.py @@ -1,4 +1,4 @@ -__version__ = '0.1.3' +__version__ = '0.1.4' from .LTS import * from .USBdev import * diff --git a/setup.py b/setup.py index 1bb02bb..fab7632 100644 --- a/setup.py +++ b/setup.py @@ -32,6 +32,7 @@ setup( long_description=long_description, long_description_content_type='text/markdown', scripts = ['bin/listUSBdevice.py', + 'bin/getUSBport.py', ], # Automatically find packages in the current directory