CC-5990, CC-5991 - Python cleanup, removed need for /usr/lib/airtime
This commit is contained in:
parent
cd102b984b
commit
875a9dfd8b
115 changed files with 248 additions and 212 deletions
|
@ -1,38 +1,3 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
debug="f"
|
||||
|
||||
showhelp () {
|
||||
echo "Usage: airtime-liquidsoap [options]
|
||||
--help|-h Displays usage information.
|
||||
--debug|-d Print error messages to console"
|
||||
}
|
||||
|
||||
set -- $(getopt -l help,debug "hd" "$@")
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
(-h|--help) showhelp; exit 0;;
|
||||
(-d|--debug) debug="t";;
|
||||
|
||||
(--) shift; break;;
|
||||
(-*) echo "$0: error - unrecognized option $1" 1>&2; exit 1;;
|
||||
(*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
export HOME="/var/tmp/airtime/pypo/"
|
||||
if [ "$debug" = "t" ]; then
|
||||
ls_path="/usr/bin/airtime-liquidsoap --verbose -f --debug"
|
||||
else
|
||||
ls_path="/usr/bin/airtime-liquidsoap --verbose -f"
|
||||
fi
|
||||
|
||||
export PYTHONPATH=/usr/lib/airtime/:/usr/lib/airtime/pypo/bin/:/usr/lib/airtime/std_err_override/:/usr/lib/airtime/api_clients:$PYTHONPATH
|
||||
ls_param="/usr/lib/airtime/pypo/bin/liquidsoap_scripts/ls_script.liq"
|
||||
|
||||
cd /usr/lib/airtime/pypo/bin/liquidsoap_scripts
|
||||
python generate_liquidsoap_cfg.py
|
||||
|
||||
exec ${ls_path} ${ls_param} 2>&1
|
||||
exec python -m liquidsoap 2>&1
|
||||
|
|
|
@ -9,8 +9,7 @@ if [ "$?" != "0" ]; then
|
|||
fi
|
||||
|
||||
export HOME="/var/tmp/airtime/pypo/"
|
||||
export PYTHONPATH=/usr/lib/airtime/:/usr/lib/airtime/pypo/bin/:/usr/lib/airtime/std_err_override/:/usr/lib/airtime/api_clients:$PYTHONPATH
|
||||
export LC_ALL=`cat /etc/default/locale | grep "LANG=" | cut -d= -f2 | tr -d "\n\""`
|
||||
export TERM=xterm
|
||||
|
||||
exec python /usr/lib/airtime/pypo/bin/pypocli.py > /var/log/airtime/pypo/py-interpreter.log 2>&1
|
||||
exec python -m pypo > /var/log/airtime/pypo/py-interpreter.log 2>&1
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
import traceback
|
||||
|
0
python_apps/pypo/liquidsoap/__init__.py
Normal file
0
python_apps/pypo/liquidsoap/__init__.py
Normal file
27
python_apps/pypo/liquidsoap/__main__.py
Normal file
27
python_apps/pypo/liquidsoap/__main__.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
""" Runs Airtime liquidsoap
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import generate_liquidsoap_cfg
|
||||
|
||||
PYPO_HOME = '/var/tmp/airtime/pypo/'
|
||||
|
||||
def run():
|
||||
'''Entry-point for this application'''
|
||||
print "Airtime Liquidsoap"
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-d", "--debug", help="run in debug mode", action="store_true")
|
||||
args = parser.parse_args()
|
||||
|
||||
os.environ["HOME"] = PYPO_HOME
|
||||
|
||||
generate_liquidsoap_cfg.run()
|
||||
script_path = os.path.join(os.path.dirname(__file__), 'ls_script.liq')
|
||||
|
||||
if args.debug:
|
||||
os.execl('/usr/bin/liquidsoap', 'airtime-liquidsoap', script_path, '--verbose', '-f', '--debug')
|
||||
else:
|
||||
os.execl('/usr/bin/liquidsoap', 'airtime-liquidsoap', script_path, '--verbose', '-f')
|
||||
|
||||
run()
|
|
@ -25,24 +25,25 @@ def generate_liquidsoap_config(ss):
|
|||
|
||||
fh.write('log_file = "/var/log/airtime/pypo-liquidsoap/<script>.log"\n')
|
||||
fh.close()
|
||||
|
||||
logging.basicConfig(format='%(message)s')
|
||||
attempts = 0
|
||||
max_attempts = 10
|
||||
successful = False
|
||||
|
||||
while not successful:
|
||||
try:
|
||||
ac = AirtimeApiClient(logging.getLogger())
|
||||
ss = ac.get_stream_setting()
|
||||
generate_liquidsoap_config(ss)
|
||||
successful = True
|
||||
except Exception, e:
|
||||
if attempts == max_attempts:
|
||||
print "Unable to connect to the Airtime server."
|
||||
logging.error(str(e))
|
||||
logging.error("traceback: %s", traceback.format_exc())
|
||||
sys.exit(1)
|
||||
else:
|
||||
time.sleep(3)
|
||||
attempts += 1
|
||||
|
||||
def run():
|
||||
logging.basicConfig(format='%(message)s')
|
||||
attempts = 0
|
||||
max_attempts = 10
|
||||
successful = False
|
||||
|
||||
while not successful:
|
||||
try:
|
||||
ac = AirtimeApiClient(logging.getLogger())
|
||||
ss = ac.get_stream_setting()
|
||||
generate_liquidsoap_config(ss)
|
||||
successful = True
|
||||
except Exception, e:
|
||||
if attempts == max_attempts:
|
||||
print "Unable to connect to the Airtime server."
|
||||
logging.error(str(e))
|
||||
logging.error("traceback: %s", traceback.format_exc())
|
||||
sys.exit(1)
|
||||
else:
|
||||
time.sleep(3)
|
||||
attempts += 1
|
0
python_apps/pypo/liquidsoap/library/__init__.py
Normal file
0
python_apps/pypo/liquidsoap/library/__init__.py
Normal file
|
@ -1,5 +1,5 @@
|
|||
def notify(m)
|
||||
command = "/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --media-id=#{m['schedule_table_id']} &"
|
||||
command = "timeout --signal=KILL 45 python pyponotify --media-id=#{m['schedule_table_id']} &"
|
||||
log(command)
|
||||
system(command)
|
||||
end
|
||||
|
@ -15,7 +15,7 @@ def notify_stream(m)
|
|||
#if a string has a single apostrophe in it, let's comment it out by ending the string before right before it
|
||||
#escaping the apostrophe, and then starting a new string right after it. This is why we use 3 apostrophes.
|
||||
json_str = string.replace(pattern="'",(fun (s) -> "'\''"), json_str)
|
||||
command = "/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --webstream='#{json_str}' --media-id=#{!current_dyn_id} &"
|
||||
command = "timeout --signal=KILL 45 python pyponotify --webstream='#{json_str}' --media-id=#{!current_dyn_id} &"
|
||||
|
||||
if !current_dyn_id != "-1" then
|
||||
log(command)
|
||||
|
@ -93,14 +93,14 @@ def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, de
|
|||
source = ref s
|
||||
def on_error(msg)
|
||||
connected := "false"
|
||||
command = "/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --error='#{msg}' --stream-id=#{stream} --time=#{!time} &"
|
||||
command = "timeout --signal=KILL 45 python pyponotify --error='#{msg}' --stream-id=#{stream} --time=#{!time} &"
|
||||
system(command)
|
||||
log(command)
|
||||
5.
|
||||
end
|
||||
def on_connect()
|
||||
connected := "true"
|
||||
command = "/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --connect --stream-id=#{stream} --time=#{!time} &"
|
||||
command = "timeout --signal=KILL 45 python pyponotify --connect --stream-id=#{stream} --time=#{!time} &"
|
||||
system(command)
|
||||
log(command)
|
||||
end
|
|
@ -188,7 +188,7 @@ def make_scheduled_play_unavailable()
|
|||
end
|
||||
|
||||
def update_source_status(sourcename, status) =
|
||||
command = "/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --source-name=#{sourcename} --source-status=#{status} &"
|
||||
command = "timeout --signal=KILL 45 python pyponotify --source-name=#{sourcename} --source-status=#{status} &"
|
||||
system(command)
|
||||
log(command)
|
||||
end
|
||||
|
@ -399,6 +399,6 @@ if s3_enable == true then
|
|||
s3_connected, s3_description, s3_channels)
|
||||
end
|
||||
|
||||
command = "/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --liquidsoap-started &"
|
||||
command = "timeout --signal=KILL 45 python pyponotify --liquidsoap-started &"
|
||||
log(command)
|
||||
system(command)
|
|
@ -5,7 +5,7 @@ import os
|
|||
import time
|
||||
import logging
|
||||
|
||||
from media.update import replaygain
|
||||
import replaygain
|
||||
|
||||
class ReplayGainUpdater(Thread):
|
||||
"""
|
||||
|
|
|
@ -35,10 +35,13 @@ setup(name='airtime-playout',
|
|||
url='http://github.com/sourcefabric/Airtime',
|
||||
author='sourcefabric',
|
||||
license='AGPLv3',
|
||||
packages=['pypo'],
|
||||
packages=['pypo', 'pypo.media', 'pypo.media.update',
|
||||
'liquidsoap', 'liquidsoap.library'],
|
||||
package_data={'': ['*.liq', '*.cfg']},
|
||||
scripts=[
|
||||
'bin/airtime-playout',
|
||||
'bin/airtime-liquidsoap'
|
||||
'bin/airtime-liquidsoap',
|
||||
'bin/pyponotify'
|
||||
],
|
||||
install_requires=[
|
||||
'amqplib',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue