misc: small fix or general refactoring i did not bother commenting

This commit is contained in:
Simone Margaritelli 2019-10-20 20:52:22 +02:00
parent 649091766f
commit 399e78e675
No known key found for this signature in database
GPG Key ID: 82E42E7F3B34C97E

View File

@ -115,15 +115,17 @@ def install(display, update):
logging.warning("[update] can't find path for %s" % name) logging.warning("[update] can't find path for %s" % name)
return False return False
logging.info("[update] service %s stop" % update['service']) os.system("service %s stop" % update['service'])
logging.info("[update] mv %s %s" % (source_path, dest_path)) os.system("mv %s %s" % (source_path, dest_path))
logging.info("[update] service %s start" % update['service'])
else: else:
if not os.path.exists(source_path): if not os.path.exists(source_path):
source_path = "%s-%s" % (source_path, update['available']) source_path = "%s-%s" % (source_path, update['available'])
logging.info("[update] cd %s && pip3 install ." % source_path) os.system("service %s stop" % update['service'])
os.system("cd %s && pip3 install ." % source_path)
os.system("service %s start" % update['service'])
return True return True
@ -178,7 +180,8 @@ def on_internet_available(agent):
STATUS.update() STATUS.update()
if num_installed > 0: if num_installed > 0:
logging.info("[update] pwnagotchi.reboot()") display.update(force=True, new_data={'status': 'Rebooting ...'})
pwnagotchi.reboot()
except Exception as e: except Exception as e:
logging.error("[update] %s" % e) logging.error("[update] %s" % e)