Skip to content

Commit c6cdb94

Browse files
Merge pull request #1597 from PaintYourDragon/main
Macropad Hotkeys: trap import errors, add comments to config files
2 parents 27829ab + 09b1eaf commit c6cdb94

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

Macropad_Hotkeys/code.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,12 @@ def switch(self):
8888
FILES.sort()
8989
for FILENAME in FILES:
9090
if FILENAME.endswith('.py'):
91-
module = __import__(MACRO_FOLDER + '/' + FILENAME[:-3])
92-
APPS.append(App(module.app))
91+
try:
92+
module = __import__(MACRO_FOLDER + '/' + FILENAME[:-3])
93+
APPS.append(App(module.app))
94+
except (SyntaxError, ImportError, AttributeError, KeyError, NameError,
95+
IndexError, TypeError) as err:
96+
pass
9397

9498
if not APPS:
9599
GROUP[13].text = 'NO MACRO FILES FOUND'

Macropad_Hotkeys/macros/mac-adobe-illustrator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# MACROPAD Hotkeys example: Adobe Illustrator for Mac
2+
13
from adafruit_hid.keycode import Keycode # REQUIRED if using Keycode.* values
24

35
app = { # REQUIRED dict, must be named 'app'

Macropad_Hotkeys/macros/mac-adobe-photoshop.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# MACROPAD Hotkeys example: Adobe Photoshop for Mac
2+
13
from adafruit_hid.keycode import Keycode # REQUIRED if using Keycode.* values
24

35
app = { # REQUIRED dict, must be named 'app'

Macropad_Hotkeys/macros/mac-safari.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# MACROPAD Hotkeys example: Safari web browser for Mac
2+
13
from adafruit_hid.keycode import Keycode # REQUIRED if using Keycode.* values
24

35
app = { # REQUIRED dict, must be named 'app'

0 commit comments

Comments
 (0)