Skip to content

Commit 5c2abfc

Browse files
committed
feat: handle UnsupportedOperation in print_info for BlinkStick mode retrieval
1 parent c36a331 commit 5c2abfc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/scripts/main.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
get_blinkstick_package_version,
1212
BlinkStickVariant,
1313
)
14+
from blinkstick.exceptions import UnsupportedOperation
1415

1516
logging.basicConfig()
1617

@@ -87,14 +88,18 @@ def format_usage(self, usage):
8788

8889

8990
def print_info(stick):
91+
variant = stick.get_variant()
9092
print("Found backend:")
9193
print(" Manufacturer: {0}".format(stick.get_manufacturer()))
9294
print(" Description: {0}".format(stick.get_description()))
9395
print(" Variant: {0}".format(stick.get_variant_string()))
9496
print(" Serial: {0}".format(stick.get_serial()))
9597
print(" Current Color: {0}".format(stick.get_color(color_format="hex")))
96-
print(" Mode: {0}".format(stick.get_mode()))
97-
if stick.get_variant() == BlinkStickVariant.BLINKSTICK_FLEX:
98+
try:
99+
print(" Mode: {0}".format(stick.get_mode()))
100+
except UnsupportedOperation:
101+
print(" Mode: Not supported")
102+
if variant == BlinkStickVariant.BLINKSTICK_FLEX:
98103
try:
99104
count = stick.get_led_count()
100105
except:

0 commit comments

Comments
 (0)