From 0f19ffc7df96df38f8af0f2128d7562faadf8573 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Wed, 20 Feb 2013 15:02:37 -0500 Subject: [PATCH 1/4] CC-4965: Fix airtime-silan import tool -move to correct directory --- utils/{airtime-silan => }/airtime-silan | 0 utils/{airtime-silan => }/airtime-silan.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename utils/{airtime-silan => }/airtime-silan (100%) rename utils/{airtime-silan => }/airtime-silan.py (100%) diff --git a/utils/airtime-silan/airtime-silan b/utils/airtime-silan similarity index 100% rename from utils/airtime-silan/airtime-silan rename to utils/airtime-silan diff --git a/utils/airtime-silan/airtime-silan.py b/utils/airtime-silan.py similarity index 100% rename from utils/airtime-silan/airtime-silan.py rename to utils/airtime-silan.py From b8f9acc0e50f3b97bc110ae8694845334f719746 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Wed, 20 Feb 2013 15:11:27 -0500 Subject: [PATCH 2/4] CC-4965: Fix airtime-silan import tool -various fixes --- utils/airtime-silan | 48 ++++++++++++++++++++++++++++++------------ utils/airtime-silan.py | 15 ++++++------- 2 files changed, 41 insertions(+), 22 deletions(-) diff --git a/utils/airtime-silan b/utils/airtime-silan index be88f8954..efb96ef30 100755 --- a/utils/airtime-silan +++ b/utils/airtime-silan @@ -1,22 +1,42 @@ #!/bin/bash +#------------------------------------------------------------------------------- +# Copyright (c) 2011 Sourcefabric O.P.S. +# +# This file is part of the Airtime project. +# http://airtime.sourcefabric.org/ +# +# Airtime is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# Airtime is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Airtime; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +#------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- +# This script handles update cue-in/cue-out points for files that already exist +# in Airtime's library. +# +exec 2>&1 +airtime_silan_script="airtime-silan.py" +api_client_path="/usr/lib/airtime/" virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/" . ${virtualenv_bin}activate -invokePwd=$PWD - -#airtime_silan_path="/usr/lib/airtime/utils/airtime-silan/" -airtime_silan_path="/home/james/src/airtime/utils/airtime-silan/" -airtime_silan_script="airtime-silan.py" - -api_client_path="/usr/lib/airtime/" -cd ${airtime_silan_path} - -exec 2>&1 - export PYTHONPATH=${api_client_path} -# Note the -u when calling python! we need it to get unbuffered binary stdout and stderr -exec python -u ${airtime_silan_path}${airtime_silan_script} --dir "$invokePwd" "$@" +# Absolute path to this script +SCRIPT=`readlink -f $0` +# Absolute directory this script is in +SCRIPTPATH=`dirname $SCRIPT` -# EOF +cd $SCRIPTPATH +python ${airtime_silan_script} diff --git a/utils/airtime-silan.py b/utils/airtime-silan.py index bd8a0af4d..465edae6f 100644 --- a/utils/airtime-silan.py +++ b/utils/airtime-silan.py @@ -1,11 +1,12 @@ -import logging +from configobj import ConfigObj from api_clients import api_client as apc + +import logging import json import shutil import commands import os import sys -from configobj import ConfigObj import subprocess import traceback @@ -19,16 +20,16 @@ logging.disable(50) # add ch to logger logger.addHandler(ch) -if (os.geteuid() != 0): +if os.geteuid() != 0: print 'Must be a root user.' - sys.exit() + sys.exit(1) # loading config file try: config = ConfigObj('/etc/airtime/media-monitor.cfg') except Exception, e: print('Error loading config file: %s', e) - sys.exit() + sys.exit(1) api_client = apc.AirtimeApiClient(config) @@ -58,7 +59,7 @@ try: data['cueout'] = str('{0:f}'.format(info['sound'][-1][1])) processed_data.append((f['id'], data)) total += 1 - if (total % 5 == 0): + if total % 5 == 0: print "Total %s / %s files has been processed.." % (total, total_files) except Exception, e: print e @@ -77,5 +78,3 @@ try: except Exception, e: print e print traceback.format_exc() - -#update_cue_values_by_silan From b001053d915d403fbaf9d2bd0575ee661132e6ad Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Wed, 20 Feb 2013 15:19:09 -0500 Subject: [PATCH 3/4] add airtime-silan to symlink to /usr/bin --- install_minimal/include/airtime-copy-files.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install_minimal/include/airtime-copy-files.sh b/install_minimal/include/airtime-copy-files.sh index 92d9e0c6c..20b128a68 100755 --- a/install_minimal/include/airtime-copy-files.sh +++ b/install_minimal/include/airtime-copy-files.sh @@ -84,6 +84,7 @@ ln -sf /usr/lib/airtime/utils/airtime-check-system /usr/bin/airtime-check-system ln -sf /usr/lib/airtime/utils/airtime-log /usr/bin/airtime-log ln -sf /usr/lib/airtime/utils/airtime-test-soundcard /usr/bin/airtime-test-soundcard ln -sf /usr/lib/airtime/utils/airtime-test-stream /usr/bin/airtime-test-stream +ln -sf /usr/lib/airtime/utils/airtime-silan /usr/bin/airtime-silan echo "* Creating /var/log/airtime" mkdir -p /var/log/airtime From 671c6276078b76df5ffeedb8e4e8591bfc1d7433 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Wed, 20 Feb 2013 15:22:58 -0500 Subject: [PATCH 4/4] CC-4965: Fix airtime-silan import tool -prevent zombie processes --- utils/airtime-silan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/airtime-silan.py b/utils/airtime-silan.py index 465edae6f..04ec86745 100644 --- a/utils/airtime-silan.py +++ b/utils/airtime-silan.py @@ -52,7 +52,7 @@ try: try: command = ['silan', '-f', 'JSON', full_path] proc = subprocess.Popen(command, stdout=subprocess.PIPE) - out = proc.stdout.read() + out = proc.communicate()[0].strip('\r\n') info = json.loads(out) data = {} data['cuein'] = str('{0:f}'.format(info['sound'][0][0]))