Skip to content

Commit

Permalink
Merge pull request #79 from emfcamp/appstore-uninstall
Browse files Browse the repository at this point in the history
Appstore uninstall
  • Loading branch information
hughrawlinson committed May 31, 2024
2 parents f3b692f + dec0444 commit c684ccd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
28 changes: 25 additions & 3 deletions modules/firmware_apps/app_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import app
import wifi
import shutil
import machine
from app_components import Menu, clear_background, fourteen_pt, sixteen_pt, ten_pt
from events.input import BUTTON_TYPES, ButtonDownEvent
from requests import get
Expand Down Expand Up @@ -145,6 +147,7 @@ def exit_available_menu():
item_font_size=ten_pt,
)


def prepare_main_menu(self):
def on_cancel():
self.minimise()
Expand Down Expand Up @@ -182,9 +185,10 @@ def on_cancel():
self.cleanup_ui_widgets()
self.update_state("main_menu")

def on_select(_, __):
# TODO maybe implement uninstalling apps
pass
def on_select(value, idx):
self.uninstall_app(value)
self.cleanup_ui_widgets()
self.update_state("main_menu")

installed_apps = list_user_apps()

Expand All @@ -197,6 +201,24 @@ def on_select(_, __):
item_font_size=ten_pt,
)

def uninstall_app(self, app):
user_apps = list_user_apps()
selected_app = list(filter(lambda x: x['name'] == app, user_apps))
if len(selected_app) == 0:
raise RuntimeError(f"app not found: {app}")
if len(selected_app) > 1:
raise RuntimeError(f"duplicate app found: {app}")
else:
selected_app = selected_app[0]
selected_app_module = selected_app['path']
selected_app_fs_path = "/" + "/".join(selected_app_module.split(".")[0:-1])
print(f"Selected app fs path: {selected_app_fs_path}")
shutil.rmtree(selected_app_fs_path)
eventbus.emit(InstallNotificationEvent())
machine.reset()



def error_screen(self, ctx, message):
ctx.save()
ctx.text_align = ctx.CENTER
Expand Down
3 changes: 2 additions & 1 deletion modules/system/launcher/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ def launch(self, item):
try:
module = __import__(module_name, None, None, (fn,))
app = getattr(module, fn)()
except Exception:
except Exception as e:
print(f"Error creating app: {e}")
eventbus.emit(
ShowNotificationEvent(message=f"{item["name"]} has crashed")
)
Expand Down
1 change: 1 addition & 0 deletions tildagon/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def freeze_images(path, generated_dir):
module("eeprom_i2c.py", base_path="$(MPY_DIR)/../modules/lib")
freeze("$(MPY_DIR)/../modules/lib", "typing.py")
freeze("$(MPY_DIR)/../modules/lib", "typing_extensions.py")
freeze("$(MPY_DIR)/../modules/lib", "shutil.py")
#freeze("$(MPY_DIR)/../micropython-lib/python-ecosys/urequests", "urequests.py")
#freeze("$(MPY_DIR)/../micropython-lib/micropython/upysh", "upysh.py")
#freeze("$(MPY_DIR)/../micropython-lib/python-stdlib/functools", "functools.py")
Expand Down

0 comments on commit c684ccd

Please sign in to comment.