feat: Adding support for json apps. Updated Macropad_os.py to automatically load in the python and json apps at launch.
This commit is contained in:
@@ -10,31 +10,14 @@ default_config = Config("default_config.json").load()
|
||||
config = Config("config.json").load(default_config)
|
||||
|
||||
PYTHON_APP_FOLDER = "./macropad_apps/python"
|
||||
JSON_APP_FOLDER = "./macropad_apps/json"
|
||||
|
||||
apps = []
|
||||
|
||||
files = os.listdir(PYTHON_APP_FOLDER)
|
||||
files.sort()
|
||||
|
||||
app_classes = []
|
||||
for filename in files:
|
||||
if filename.endswith('.py') and not filename.startswith('._'):
|
||||
try:
|
||||
print(filename)
|
||||
module = __import__(PYTHON_APP_FOLDER + '/' + filename[:-3])
|
||||
classes = [getattr(module, a) for a in dir(module)
|
||||
if isinstance(getattr(module, a), type)]
|
||||
for cls in classes:
|
||||
if issubclass(cls, App) and cls.__name__ != "App":
|
||||
app_classes.append(cls)
|
||||
print(app_classes)
|
||||
except (SyntaxError, ImportError, AttributeError, KeyError, NameError, IndexError, TypeError) as err:
|
||||
print("ERROR in", filename)
|
||||
import traceback
|
||||
|
||||
traceback.print_exception(err, err, err.__traceback__)
|
||||
|
||||
ar = MacropadOS(macropad, config, apps=app_classes)
|
||||
ar = MacropadOS(
|
||||
macropad,
|
||||
config,
|
||||
python_apps=PYTHON_APP_FOLDER,
|
||||
json_apps=JSON_APP_FOLDER
|
||||
)
|
||||
# sc = SerialComms(config)
|
||||
# _thread.start_new_thread(sc.run, (sc))
|
||||
ar.start()
|
||||
|
||||
Reference in New Issue
Block a user