fix(pypo): refactor liquidsoap entrypoint
This commit is contained in:
parent
7aa95bf204
commit
7788397304
|
@ -7,10 +7,11 @@ import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
from pypo import pure
|
from pypo import pure
|
||||||
|
|
||||||
PYPO_HOME = '/var/tmp/airtime/pypo/'
|
PYPO_HOME = "/var/tmp/airtime/pypo/"
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
'''Entry-point for this application'''
|
"""Entry-point for this application"""
|
||||||
print("Airtime Liquidsoap")
|
print("Airtime Liquidsoap")
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("-d", "--debug", help="run in debug mode", action="store_true")
|
parser.add_argument("-d", "--debug", help="run in debug mode", action="store_true")
|
||||||
|
@ -19,15 +20,29 @@ def run():
|
||||||
os.environ["HOME"] = PYPO_HOME
|
os.environ["HOME"] = PYPO_HOME
|
||||||
|
|
||||||
if args.debug:
|
if args.debug:
|
||||||
logging.basicConfig(level=getattr(logging, 'DEBUG', None))
|
logging.basicConfig(level=getattr(logging, "DEBUG", None))
|
||||||
|
|
||||||
generate_liquidsoap_cfg.run()
|
generate_liquidsoap_cfg.run()
|
||||||
''' check liquidsoap version so we can run a scripts matching the liquidsoap minor version '''
|
""" check liquidsoap version so we can run a scripts matching the liquidsoap minor version """
|
||||||
liquidsoap_version = subprocess.check_output("liquidsoap --version", shell=True, universal_newlines=True)[0:3]
|
liquidsoap_version = subprocess.check_output(
|
||||||
script_path = os.path.join(os.path.dirname(__file__), liquidsoap_version, 'ls_script.py')
|
"liquidsoap --force-start 'print(liquidsoap.version) shutdown()'",
|
||||||
|
shell=True,
|
||||||
|
universal_newlines=True,
|
||||||
|
)[0:3]
|
||||||
|
script_path = os.path.join(
|
||||||
|
os.path.dirname(__file__), liquidsoap_version, "ls_script.liq"
|
||||||
|
)
|
||||||
|
exec_args = [
|
||||||
|
"/usr/bin/liquidsoap",
|
||||||
|
"airtime-liquidsoap",
|
||||||
|
script_path,
|
||||||
|
"--verbose",
|
||||||
|
"-f",
|
||||||
|
]
|
||||||
if args.debug:
|
if args.debug:
|
||||||
os.execl('/usr/bin/liquidsoap', 'airtime-liquidsoap', script_path, '--verbose', '-f', '--debug')
|
print(f"Liquidsoap {liquidsoap_version} using script: {script_path}")
|
||||||
else:
|
exec_args.append("--debug")
|
||||||
os.execl('/usr/bin/liquidsoap', 'airtime-liquidsoap', script_path, '--verbose', '-f')
|
os.execl(*exec_args)
|
||||||
|
|
||||||
|
|
||||||
run()
|
run()
|
||||||
|
|
Loading…
Reference in New Issue