|
12 | 12 | RequestStartAppEvent, |
13 | 13 | RequestStopAppEvent, |
14 | 14 | ) |
| 15 | +from system.notification.events import ShowNotificationEvent |
15 | 16 |
|
16 | 17 | APP_DIR = "/apps" |
17 | 18 |
|
| 19 | + |
18 | 20 | class InstallNotificationEvent(Event): |
19 | 21 | pass |
20 | 22 |
|
| 23 | + |
21 | 24 | def path_isfile(path): |
22 | 25 | # Wow totally an elegant way to do os.path.isfile... |
23 | 26 | try: |
@@ -86,8 +89,10 @@ def __init__(self): |
86 | 89 | self.update_menu() |
87 | 90 | self._apps = {} |
88 | 91 | eventbus.on_async(RequestStopAppEvent, self._handle_stop_app, self) |
89 | | - eventbus.on_async(InstallNotificationEvent, self._handle_refresh_notifications, self) |
90 | | - |
| 92 | + eventbus.on_async( |
| 93 | + InstallNotificationEvent, self._handle_refresh_notifications, self |
| 94 | + ) |
| 95 | + |
91 | 96 | async def _handle_refresh_notifications(self, _): |
92 | 97 | self.update_menu() |
93 | 98 |
|
@@ -146,8 +151,14 @@ def launch(self, item): |
146 | 151 | print(self._apps) |
147 | 152 | if app is None: |
148 | 153 | print(f"Creating app {app_id}...") |
149 | | - module = __import__(module_name, None, None, (fn,)) |
150 | | - app = getattr(module, fn)() |
| 154 | + try: |
| 155 | + module = __import__(module_name, None, None, (fn,)) |
| 156 | + app = getattr(module, fn)() |
| 157 | + except Exception: |
| 158 | + eventbus.emit( |
| 159 | + ShowNotificationEvent(message=f"{item["name"]} has crashed") |
| 160 | + ) |
| 161 | + return |
151 | 162 | self._apps[app_id] = app |
152 | 163 | eventbus.emit(RequestStartAppEvent(app, foreground=True)) |
153 | 164 | else: |
|
0 commit comments