mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-07-26 20:32:04 +08:00
Spinner: wait for UI to start (#20279)
* Impose a max rate for updating spinner progress
* fix import
* Show spinner until offroad is started
* no need for time
* Fix ROOT_DIR
* Fix fb include
* fix relative path
* don't touch these files
* Close spinner after all procs have started
* don't touch file
* Move up
* Revert changes to spinner, and only sleep on final progress update
* add this back
* revert time
* test sending 100
* test sending 100
* revert makefile changes
* rm 2nd 100% update
* pass spinner to thread function
* pass ignore list
* Default to None
Co-authored-by: Willem Melching <willem.melching@gmail.com>
Co-authored-by: Willem Melching <willem.melching@gmail.com>
old-commit-hash: a3556410de
This commit is contained in:
+1
-1
@@ -25,7 +25,7 @@ class Spinner():
|
||||
pass
|
||||
|
||||
def update_progress(self, cur: int, total: int):
|
||||
self.update(str(int(100 * cur / total)))
|
||||
self.update(str(round(100 * cur / total)))
|
||||
|
||||
def close(self):
|
||||
if self.spinner_proc is not None:
|
||||
|
||||
@@ -99,13 +99,11 @@ def manager_prepare(spinner=None):
|
||||
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
total = 100.0 - (0 if PREBUILT else MAX_BUILD_PROGRESS)
|
||||
|
||||
for i, p in enumerate(managed_processes.values()):
|
||||
perc = (100.0 - total) + total * (i + 1) / len(managed_processes)
|
||||
|
||||
if spinner:
|
||||
spinner.update_progress(perc, 100.)
|
||||
p.prepare()
|
||||
if spinner:
|
||||
perc = (100.0 - total) + total * (i + 1) / len(managed_processes)
|
||||
spinner.update_progress(perc, 100.)
|
||||
|
||||
|
||||
def manager_cleanup():
|
||||
@@ -118,7 +116,7 @@ def manager_cleanup():
|
||||
cloudlog.info("everything is dead")
|
||||
|
||||
|
||||
def manager_thread():
|
||||
def manager_thread(spinner=None):
|
||||
cloudlog.info("manager start")
|
||||
cloudlog.info({"environ": os.environ})
|
||||
|
||||
@@ -136,6 +134,10 @@ def manager_thread():
|
||||
pm_apply_packages('enable')
|
||||
start_offroad()
|
||||
|
||||
ensure_running(managed_processes.values(), started=False, not_run=ignore)
|
||||
if spinner: # close spinner when ui has started
|
||||
spinner.close()
|
||||
|
||||
started_prev = False
|
||||
params = Params()
|
||||
sm = messaging.SubMaster(['deviceState'])
|
||||
@@ -177,9 +179,6 @@ def main(spinner=None):
|
||||
manager_init(spinner)
|
||||
manager_prepare(spinner)
|
||||
|
||||
if spinner:
|
||||
spinner.close()
|
||||
|
||||
if os.getenv("PREPAREONLY") is not None:
|
||||
return
|
||||
|
||||
@@ -187,7 +186,7 @@ def main(spinner=None):
|
||||
signal.signal(signal.SIGTERM, lambda signum, frame: sys.exit(1))
|
||||
|
||||
try:
|
||||
manager_thread()
|
||||
manager_thread(spinner)
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
crash.capture_exception()
|
||||
|
||||
Reference in New Issue
Block a user