Mercurial > sat_docs
view flatpak/libervia_wrapper.py @ 173:0d2eb834fc59
screenshots: more 0.8 screenshots + apng screencast
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 30 Nov 2021 22:14:01 +0100 |
parents | a213053a03be |
children |
line wrap: on
line source
#!/usr/bin/env python3 """This script launch Libervia backend if it's not before running command""" import os import sys import subprocess from sat.tools import config from pathlib import Path command = "##COMMAND##" local_path = Path(config.getConfig( config.parseMainConf(), "", "local_dir" )) socket_path = local_path / "bridge_pb" # we remove any path with "/home" from PYTHONPATH because we have # "--filesystem=home" permission and packages in .local/lib/pythonX/site-packages may # conflict with the ones from flatpak clean_pythonpath = ':'.join(p for p in sys.path if p and not p.startswith('/home')) os.environ['PYTHONPATH'] = clean_pythonpath os.environ['PYTHONNOUSERSITE'] = '1' if not socket_path.is_socket(): # backend is not launched we need to launch it print("Launching Libervia backend") subprocess.check_call("libervia-backend") backend_launched = True else: backend_launched = False subprocess.run([command, *sys.argv[1:]]) if backend_launched: print("Stopping Libervia backend") subprocess.check_call(["libervia-backend", "stop"])