More work on switching pypo to use setuptools

This commit is contained in:
Duncan Sommerville 2014-12-17 16:42:29 -05:00
parent 97805ad271
commit 29917ebf63
6 changed files with 158 additions and 0 deletions

View File

@ -374,6 +374,9 @@ verbose "...Done"
chmod 755 /etc/init.d/airtime-*
initctl reload-configuration
verbose "\n * Copying pypo files..."
python ${AIRTIMEROOT}/python_apps/pypo/setup.py install
if [ ! -d /var/log/airtime ]; then
loud "\n-----------------------------------------------------"
loud " * Installing Log Files * "

View File

@ -0,0 +1,48 @@
#!/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
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
. ${virtualenv_bin}activate
export HOME="/var/tmp/airtime/pypo/"
api_client_path="/usr/lib/airtime/"
if [ $debug = "t" ]; then
ls_path="/usr/bin/airtime-liquidsoap --verbose -f"
else
ls_path="/usr/bin/airtime-liquidsoap --verbose -f -d"
fi
ls_param="/usr/lib/airtime/pypo/bin/liquidsoap_scripts/ls_script.liq"
export PYTHONPATH=${api_client_path}
SCRIPT=`readlink -f $0`
# Absolute directory this script is in
SCRIPTPATH=`dirname $SCRIPT`
cd $SCRIPTPATH/liquidsoap_scripts
python generate_liquidsoap_cfg.py
exec ${ls_path} ${ls_param} 2>&1
# EOF

View File

@ -0,0 +1,31 @@
#!/bin/bash
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
. ${virtualenv_bin}activate
# Absolute path to this script
SCRIPT=`readlink -f $0`
# Absolute directory this script is in
pypo_path=`dirname $SCRIPT`
api_client_path="/usr/lib/airtime/"
pypo_script="pypocli.py"
cd ${pypo_path}
set +e
cat /etc/default/locale | grep -i "LANG=.*UTF-\?8" > /dev/null
set -e
if [ "$?" != "0" ]; then
echo "non UTF-8 default locale found in /etc/default/locale." > /var/log/airtime/pypo/error.log
exit 1
fi
export HOME="/var/tmp/airtime/pypo/"
export PYTHONPATH=${api_client_path}:$PYTHONPATH
export LC_ALL=`cat /etc/default/locale | grep "LANG=" | cut -d= -f2 | tr -d "\n\""`
export TERM=xterm
exec python ${pypo_path}/${pypo_script} > /var/log/airtime/pypo/py-interpreter.log 2>&1
# EOF

View File

@ -0,0 +1,15 @@
description "Airtime Liquidsoap"
author "help@sourcefabric.org"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
setuid www-data
setgid www-data
env LANG='en_US.UTF-8'
env LC_ALL='en_US.UTF-8'
exec airtime-liquidsoap

View File

@ -0,0 +1,15 @@
description "Pypo"
author "help@sourcefabric.org"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
setuid www-data
setgid www-data
env LANG='en_US.UTF-8'
env LC_ALL='en_US.UTF-8'
exec airtime-playout

46
python_apps/pypo/setup.py Normal file
View File

@ -0,0 +1,46 @@
from setuptools import setup
from subprocess import call
import sys
# Allows us to avoid installing the upstart init script when deploying airtime_analyzer
# on Airtime Pro:
if '--no-init-script' in sys.argv:
data_files = []
sys.argv.remove('--no-init-script') # super hax
else:
data_files = [('/etc/init', ['install/airtime-playout.conf', 'install/airtime-liquidsoap.conf'])]
print data_files
setup(name='airtime-playout',
version='0.1',
description='Airtime Analyzer Worker and File Importer',
url='http://github.com/sourcefabric/Airtime',
author='sourcefabric',
license='AGPLv3',
packages=['pypo'],
scripts=[
'bin/airtime-playout',
'bin/airtime-liquidsoap'
],
install_requires=[
'amqplib',
'anyjson',
'argparse',
'configobj',
'docopt',
'kombu',
'mutagen',
'poster',
'PyDispatcher',
'pyinotify',
'pytz',
'wsgiref'
],
zip_safe=False,
data_files=data_files)
# Reload the initctl config so that "service start airtime_analyzer" works
if data_files:
print "Reloading initctl configuration"
call(['initctl', 'reload-configuration'])
print "Run \"sudo service airtime-playout start\" and \"sudo service airtime-liquidsoap start\""