plotjuggler: route name in window title (#25370)

* Route titles

* minimum version check

* use tuples

* minor clean up

* use check_output

* space

* belongs here

* add prompt

* no f string

* Update juggle.py

Co-authored-by: Shane Smiskol <shane@smiskol.com>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
This commit is contained in:
grekiki 2022-08-09 00:10:31 +02:00 committed by GitHub
parent ac305dacef
commit cac960cb54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 2 deletions

View File

@ -23,6 +23,7 @@ DEMO_ROUTE = "4cf7a6ad03080c90|2021-09-29--13-46-36"
RELEASES_URL="https://github.com/commaai/PlotJuggler/releases/download/latest" RELEASES_URL="https://github.com/commaai/PlotJuggler/releases/download/latest"
INSTALL_DIR = os.path.join(juggle_dir, "bin") INSTALL_DIR = os.path.join(juggle_dir, "bin")
PLOTJUGGLER_BIN = os.path.join(juggle_dir, "bin/plotjuggler") PLOTJUGGLER_BIN = os.path.join(juggle_dir, "bin/plotjuggler")
MINIMUM_PLOTJUGGLER_VERSION = (3, 5, 2)
def install(): def install():
@ -46,6 +47,12 @@ def install():
tar.extractall(path=INSTALL_DIR) tar.extractall(path=INSTALL_DIR)
def get_plotjuggler_version():
out = subprocess.check_output([PLOTJUGGLER_BIN, "-v"], encoding="utf-8").strip()
version = out.split(" ")[1]
return tuple(map(int, version.split(".")))
def load_segment(segment_name): def load_segment(segment_name):
if segment_name is None: if segment_name is None:
return [] return []
@ -57,7 +64,7 @@ def load_segment(segment_name):
return [] return []
def start_juggler(fn=None, dbc=None, layout=None): def start_juggler(fn=None, dbc=None, layout=None, route_or_segment_name=None):
env = os.environ.copy() env = os.environ.copy()
env["BASEDIR"] = BASEDIR env["BASEDIR"] = BASEDIR
env["PATH"] = f"{INSTALL_DIR}:{os.getenv('PATH', '')}" env["PATH"] = f"{INSTALL_DIR}:{os.getenv('PATH', '')}"
@ -69,6 +76,8 @@ def start_juggler(fn=None, dbc=None, layout=None):
extra_args += f" -d {fn}" extra_args += f" -d {fn}"
if layout is not None: if layout is not None:
extra_args += f" -l {layout}" extra_args += f" -l {layout}"
if route_or_segment_name is not None:
extra_args += f" --window_title \"{route_or_segment_name}\""
cmd = f'{PLOTJUGGLER_BIN} --plugin_folders {INSTALL_DIR}{extra_args}' cmd = f'{PLOTJUGGLER_BIN} --plugin_folders {INSTALL_DIR}{extra_args}'
subprocess.call(cmd, shell=True, env=env, cwd=juggle_dir) subprocess.call(cmd, shell=True, env=env, cwd=juggle_dir)
@ -129,7 +138,7 @@ def juggle_route(route_or_segment_name, segment_count, qlog, can, layout, dbc=No
with tempfile.NamedTemporaryFile(suffix='.rlog', dir=juggle_dir) as tmp: with tempfile.NamedTemporaryFile(suffix='.rlog', dir=juggle_dir) as tmp:
save_log(tmp.name, all_data, compress=False) save_log(tmp.name, all_data, compress=False)
del all_data del all_data
start_juggler(tmp.name, dbc, layout) start_juggler(tmp.name, dbc, layout, route_or_segment_name)
if __name__ == "__main__": if __name__ == "__main__":
@ -159,6 +168,10 @@ if __name__ == "__main__":
if not os.path.exists(PLOTJUGGLER_BIN): if not os.path.exists(PLOTJUGGLER_BIN):
print("PlotJuggler is missing. Downloading...") print("PlotJuggler is missing. Downloading...")
install() install()
if get_plotjuggler_version() < MINIMUM_PLOTJUGGLER_VERSION:
ans = input("PlotJuggler is out of date. Installing update...")
install()
if args.stream: if args.stream:
start_juggler(layout=args.layout) start_juggler(layout=args.layout)