diff --git a/pwnagotchi/plugins/default/auto-update.py b/pwnagotchi/plugins/default/auto-update.py index 314acd8..0d8f17c 100644 --- a/pwnagotchi/plugins/default/auto-update.py +++ b/pwnagotchi/plugins/default/auto-update.py @@ -62,8 +62,7 @@ def check(version, repo, native=True): def install(display, update): name = update['repo'].split('/')[1] - display.set('status', 'Downloading %s ...' % name) - display.update(force=True) + display.update(force=True, new_data={'status': 'Downloading %s ...' % name}) path = os.path.join("/tmp/updates/", name) if os.path.exists(path): @@ -81,8 +80,7 @@ def install(display, update): logging.info("[update] extracting %s to %s ..." % (target_path, path)) - display.set('status', 'Extracting %s ...' % name) - display.update(force=True) + display.update(force=True, new_data={'status': 'Extracting %s ...' % name}) os.system('unzip "%s" -d "%s"' % (target_path, path)) @@ -92,6 +90,8 @@ def install(display, update): logging.warning("native update without SHA256 checksum file") else: + display.update(force=True, new_data={'status': 'Verifying %s ...' % name}) + binary_path = os.path.join(path, name) checksum = checksums[0] @@ -106,6 +106,8 @@ def install(display, update): logging.warning("[update] checksum mismatch for %s: expected=%s got=%s" % (binary_path, expected, real)) return + display.update(force=True, new_data={'status': 'Installing %s ...' % name}) + if update['native']: dest_path = subprocess.getoutput("which %s" % name) logging.info("[update] installing %s to %s ... TODO" % (binary_path, dest_path)) @@ -130,8 +132,7 @@ def on_internet_available(agent): prev_status = display.get('status') try: - display.set('status', 'Checking for updates ...') - display.update(force=True) + display.update(force=True, new_data={'status': 'Checking for updates ...'}) to_install = [] to_check = [ @@ -164,5 +165,4 @@ def on_internet_available(agent): logging.error("[update] %s" % e) logging.debug("[update] setting status '%s'" % prev_status) - display.set('status', prev_status if prev_status is not None else '') - display.update(force=True) + display.update(force=True, new_data={'status': prev_status if prev_status is not None else ''}) diff --git a/pwnagotchi/ui/view.py b/pwnagotchi/ui/view.py index 977dbe8..a2f2d2c 100644 --- a/pwnagotchi/ui/view.py +++ b/pwnagotchi/ui/view.py @@ -310,7 +310,10 @@ class View(object): self.set('status', self._voice.custom(text)) self.update() - def update(self, force=False): + def update(self, force=False, new_data={}): + for key, val in new_data.items(): + self.set(key, val) + with self._lock: if self._frozen: return