From aab1ad16e176e3e3b016c422a4d3504eea2b2af5 Mon Sep 17 00:00:00 2001 From: Paul Baranowski Date: Fri, 15 Apr 2011 14:45:10 -0400 Subject: [PATCH] CC-2166 : Packaging improvements Fixed paths for pypo and the show recorder. Pypo and the show recorder now read their paths from the INI files. Note that liquidsoap and shell scripts do not yet read from the INI files, and so that paths are hard-coded in those places. On uninstall, no longer deleting INI files and the STOR directory. Included a note to remove those by hand if they want them gone. Fixed some bugs where not all directories were removed on uninstall. Fixed bugs in the Show Recorder install where it was adding directories that it didnt need. --- dev_tools/pl.sh | 2 +- dev_tools/pr.sh | 2 +- install/airtime-uninstall.php | 25 ++-- install/include/AirtimeInstall.php | 9 +- .../install/pypo-daemontools-liquidsoap.sh | 10 +- python_apps/pypo/install/pypo-daemontools.sh | 6 +- python_apps/pypo/install/pypo-install.py | 50 ++++--- python_apps/pypo/install/pypo-uninstall.py | 18 ++- python_apps/pypo/pypo.cfg | 20 ++- python_apps/pypo/scripts/ls_lib.liq | 4 +- python_apps/pypo/scripts/old_files/README | 23 --- .../pypo/scripts/old_files/cue_file.py | 141 ------------------ .../scripts/old_files/include_daypart.liq | 70 --------- .../old_files/include_dynamic_vars.liq | 17 --- .../scripts/old_files/include_live_in.liq | 20 --- .../pypo/scripts/old_files/include_notify.liq | 22 --- .../scripts/old_files/include_scheduler.liq | 78 ---------- .../pypo/scripts/old_files/library.liq | 37 ----- python_apps/pypo/scripts/old_files/log_run.sh | 18 --- .../pypo/scripts/old_files/ls_config.liq.dist | 44 ------ python_apps/pypo/scripts/old_files/ls_cue.liq | 36 ----- python_apps/pypo/scripts/old_files/ls_run.sh | 7 - .../pypo/scripts/old_files/ls_script.liq | 106 ------------- .../scripts/old_files/silence-playlist.lsp | 48 ------ .../install/recorder-daemontools.sh | 6 +- .../show-recorder/install/recorder-install.py | 46 +++--- .../install/recorder-uninstall.py | 19 ++- python_apps/show-recorder/recorder.cfg | 8 +- 28 files changed, 139 insertions(+), 753 deletions(-) delete mode 100644 python_apps/pypo/scripts/old_files/README delete mode 100755 python_apps/pypo/scripts/old_files/cue_file.py delete mode 100644 python_apps/pypo/scripts/old_files/include_daypart.liq delete mode 100644 python_apps/pypo/scripts/old_files/include_dynamic_vars.liq delete mode 100644 python_apps/pypo/scripts/old_files/include_live_in.liq delete mode 100644 python_apps/pypo/scripts/old_files/include_notify.liq delete mode 100644 python_apps/pypo/scripts/old_files/include_scheduler.liq delete mode 100644 python_apps/pypo/scripts/old_files/library.liq delete mode 100755 python_apps/pypo/scripts/old_files/log_run.sh delete mode 100644 python_apps/pypo/scripts/old_files/ls_config.liq.dist delete mode 100644 python_apps/pypo/scripts/old_files/ls_cue.liq delete mode 100755 python_apps/pypo/scripts/old_files/ls_run.sh delete mode 100644 python_apps/pypo/scripts/old_files/ls_script.liq delete mode 100644 python_apps/pypo/scripts/old_files/silence-playlist.lsp diff --git a/dev_tools/pl.sh b/dev_tools/pl.sh index 4e1c70134..9d3729e15 100755 --- a/dev_tools/pl.sh +++ b/dev_tools/pl.sh @@ -2,4 +2,4 @@ echo echo "This will tail the pypo-liquidsoap log file." echo "Type in password for pypo user (default password is 'pypo'):" -su -l pypo -c "tail -F /etc/service/pypo-liquidsoap/log/main/current" +su -l pypo -c "tail -F /var/log/airtime/pypo-liquidsoap/main/current" diff --git a/dev_tools/pr.sh b/dev_tools/pr.sh index aadab42ec..afb9426a9 100755 --- a/dev_tools/pr.sh +++ b/dev_tools/pr.sh @@ -4,4 +4,4 @@ echo echo "This will tail the recorder log file." echo "Type in password for pypo user (default password is 'pypo'):" -su -l pypo -c "tail -F /etc/service/recorder/log/main/current" +su -l pypo -c "tail -F /var/log/airtime/show-recorder/main/current" diff --git a/install/airtime-uninstall.php b/install/airtime-uninstall.php index ac3270d0e..78c5cf533 100644 --- a/install/airtime-uninstall.php +++ b/install/airtime-uninstall.php @@ -17,9 +17,9 @@ if (!file_exists(AirtimeIni::CONF_FILE_AIRTIME)) { } require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php'); -echo "Uninstalling Airtime ".AIRTIME_VERSION.PHP_EOL; - +echo PHP_EOL; echo "******************************* Uninstall Begin ********************************".PHP_EOL; +echo "* Uninstalling Airtime ".AIRTIME_VERSION.PHP_EOL; AirtimeInstall::RemoveSymlinks(); AirtimeInstall::UninstallBinaries(); AirtimeInstall::UninstallPhpCode(); @@ -76,17 +76,24 @@ if ($results == 0) { echo " * Nothing to delete.".PHP_EOL; } +# Disabled as this should be a manual process +#AirtimeInstall::DeleteFilesRecursive(AirtimeInstall::CONF_DIR_STORAGE); -//------------------------------------------------------------------------ -// Delete files -//------------------------------------------------------------------------ -AirtimeInstall::DeleteFilesRecursive(AirtimeInstall::CONF_DIR_STORAGE); -AirtimeIni::RemoveIniFiles(); - +echo PHP_EOL."*** Uninstalling Pypo ***".PHP_EOL; $command = "python ".__DIR__."/../python_apps/pypo/install/pypo-uninstall.py"; system($command); +echo PHP_EOL."*** Uninstalling Show Recorder ***".PHP_EOL; $command = "python ".__DIR__."/../python_apps/show-recorder/install/recorder-uninstall.py"; system($command); -echo "****************************** Uninstall Complete ******************************".PHP_EOL; +#Disabled as this should be a manual process +#AirtimeIni::RemoveIniFiles(); + +echo PHP_EOL; +echo "****************************** Uninstall Complete ******************************".PHP_EOL; +echo PHP_EOL; +echo "NOTE: To fully remove all Airtime files, you will also have to manually delete".PHP_EOL; +echo " the directories '".AirtimeInstall::CONF_DIR_STORAGE."'(where the media files are stored)".PHP_EOL; +echo " and '/etc/airtime'(where the config files are stored).".PHP_EOL; +echo PHP_EOL; diff --git a/install/include/AirtimeInstall.php b/install/include/AirtimeInstall.php index f215aadc0..23fee89c4 100644 --- a/install/include/AirtimeInstall.php +++ b/install/include/AirtimeInstall.php @@ -303,8 +303,13 @@ class AirtimeInstall AirtimeIni::CONF_FILE_LIQUIDSOAP, AirtimeIni::CONF_FILE_PYPO, AirtimeIni::CONF_FILE_RECORDER, - "/usr/lib/pypo", - "/usr/lib/show-recorder"); + "/usr/lib/airtime/pypo", + "/usr/lib/airtime/show-recorder", + "/var/log/airtime", + "/var/log/airtime/pypo", + "/var/log/airtime/show-recorder", + "/var/tmp/airtime/pypo", + "/var/tmp/airtime/show-recorder"); foreach ($dirs as $f) { if (file_exists($f)) { echo "+ $f".PHP_EOL; diff --git a/python_apps/pypo/install/pypo-daemontools-liquidsoap.sh b/python_apps/pypo/install/pypo-daemontools-liquidsoap.sh index cd6177164..3a0f3eef7 100755 --- a/python_apps/pypo/install/pypo-daemontools-liquidsoap.sh +++ b/python_apps/pypo/install/pypo-daemontools-liquidsoap.sh @@ -1,12 +1,12 @@ #!/bin/sh ls_user="pypo" -export HOME="/home/pypo/" -api_client_path="/opt/pypo/" -ls_path="/opt/pypo/bin/liquidsoap/liquidsoap" -ls_param="/opt/pypo/bin/scripts/ls_script.liq" +export HOME="/var/tmp/airtime/pypo/" +api_client_path="/usr/lib/airtime/pypo/" +ls_path="/usr/lib/airtime/pypo/bin/liquidsoap/liquidsoap" +ls_param="/usr/lib/airtime/pypo/bin/scripts/ls_script.liq" echo "*** Daemontools: starting liquidsoap" exec 2>&1 -cd /opt/pypo/bin/scripts +cd /usr/lib/airtime/pypo/bin/scripts sudo PYTHONPATH=${api_client_path} -u ${ls_user} ${ls_path} ${ls_param} # EOF diff --git a/python_apps/pypo/install/pypo-daemontools.sh b/python_apps/pypo/install/pypo-daemontools.sh index 1f276cc4e..891c3b259 100755 --- a/python_apps/pypo/install/pypo-daemontools.sh +++ b/python_apps/pypo/install/pypo-daemontools.sh @@ -1,9 +1,9 @@ #!/bin/sh pypo_user="pypo" -export HOME="/home/pypo/" +export HOME="/var/tmp/airtime/pypo/" # Location of pypo_cli.py Python script -pypo_path="/opt/pypo/bin/" -api_client_path="/opt/pypo/" +pypo_path="/usr/lib/airtime/pypo/bin/" +api_client_path="/usr/lib/airtime/pypo/" pypo_script="pypo-cli.py" echo "*** Daemontools: starting daemon" cd ${pypo_path} diff --git a/python_apps/pypo/install/pypo-install.py b/python_apps/pypo/install/pypo-install.py index 66d94fcc5..dc0075baf 100755 --- a/python_apps/pypo/install/pypo-install.py +++ b/python_apps/pypo/install/pypo-install.py @@ -13,18 +13,21 @@ import logging.config import shutil import string import platform +from configobj import ConfigObj from subprocess import Popen, PIPE, STDOUT if os.geteuid() != 0: print "Please run this as root." sys.exit(1) -BASE_PATH = '/opt/pypo/' +PATH_INI_FILE = '/etc/airtime/pypo.cfg' def create_path(path): if not (os.path.exists(path)): print "Creating directory " + path os.makedirs(path) + else: + print "Directory already exists " + path def create_user(username): print "Checking for user "+username @@ -49,20 +52,27 @@ def create_user(username): def copy_dir(src_dir, dest_dir): if (os.path.exists(dest_dir)) and (dest_dir != "/"): - print "Removing old directory "+dest_dir + #print "Removing old directory "+dest_dir shutil.rmtree(dest_dir) if not (os.path.exists(dest_dir)): - print "Copying directory "+src_dir+" to "+dest_dir + print "Copying directory "+os.path.realpath(src_dir)+" to "+os.path.realpath(dest_dir) shutil.copytree(src_dir, dest_dir) def get_current_script_dir(): current_script_dir = os.path.realpath(__file__) index = current_script_dir.rindex('/') - print current_script_dir[0:index] + #print current_script_dir[0:index] return current_script_dir[0:index] try: + # load config file + try: + config = ConfigObj(PATH_INI_FILE) + except Exception, e: + print 'Error loading config file: ', e + sys.exit() + current_script_dir = get_current_script_dir() print "Checking and removing any existing pypo processes" os.system("python %s/pypo-uninstall.py 1>/dev/null 2>&1"% current_script_dir) @@ -71,21 +81,18 @@ try: # Create users create_user("pypo") - print "Creating log directories" - create_path("/var/log/airtime/pypo") - os.system("chmod -R 755 /var/log/airtime/pypo") - os.system("chown -R pypo:pypo /var/log/airtime/pypo") + create_path(config["pypo_log_dir"]) + os.system("chmod -R 755 " + config["pypo_log_dir"]) + os.system("chown -R pypo:pypo "+config["pypo_log_dir"]) - create_path("/var/log/airtime/pypo-liquidsoap") - os.system("chmod -R 755 /var/log/airtime/pypo-liquidsoap") - os.system("chown -R pypo:pypo /var/log/airtime/pypo-liquidsoap") + create_path(config["liquidsoap_log_dir"]) + os.system("chmod -R 755 " + config["liquidsoap_log_dir"]) + os.system("chown -R pypo:pypo "+config["liquidsoap_log_dir"]) - create_path(BASE_PATH) - create_path(BASE_PATH+"bin") - create_path(BASE_PATH+"cache") - create_path(BASE_PATH+"files") - create_path(BASE_PATH+"tmp") - create_path(BASE_PATH+"archive") + create_path(config["bin_dir"]+"/bin") + create_path(config["cache_dir"]) + create_path(config["file_dir"]) + create_path(config["tmp_dir"]) if platform.architecture()[0] == '64bit': print "Installing 64-bit liquidsoap binary" @@ -97,12 +104,13 @@ try: print "Unknown system architecture." sys.exit(1) - copy_dir("%s/.."%current_script_dir, BASE_PATH+"bin/") - copy_dir("%s/../../api_clients"%current_script_dir, BASE_PATH+"api_clients/") + copy_dir("%s/.."%current_script_dir, config["bin_dir"]+"/bin/") + copy_dir("%s/../../api_clients"%current_script_dir, config["bin_dir"]+"/api_clients/") print "Setting permissions" - os.system("chmod -R 755 "+BASE_PATH) - os.system("chown -R pypo:pypo "+BASE_PATH) + os.system("chmod -R 755 "+config["bin_dir"]) + os.system("chown -R pypo:pypo "+config["bin_dir"]) + os.system("chown -R pypo:pypo "+config["cache_base_dir"]) print "Installing pypo daemon" create_path("/etc/service/pypo") diff --git a/python_apps/pypo/install/pypo-uninstall.py b/python_apps/pypo/install/pypo-uninstall.py index 004556bf0..28907fefd 100755 --- a/python_apps/pypo/install/pypo-uninstall.py +++ b/python_apps/pypo/install/pypo-uninstall.py @@ -4,12 +4,13 @@ import os import sys import time +from configobj import ConfigObj if os.geteuid() != 0: print "Please run this as root." sys.exit(1) -BASE_PATH = '/opt/pypo/' +PATH_INI_FILE = '/etc/airtime/pypo.cfg' def remove_path(path): os.system("rm -rf " + path) @@ -29,14 +30,23 @@ def get_current_script_dir(): return current_script_dir[0:index] try: + # load config file + try: + config = ConfigObj(PATH_INI_FILE) + except Exception, e: + print 'Error loading config file: ', e + sys.exit() + os.system("python %s/pypo-stop.py" % get_current_script_dir()) print "Removing log directories" - remove_path("/var/log/airtime/pypo") - remove_path("/var/log/airtime/pypo-liquidsoap") + remove_path(config["log_base_dir"]) + + print "Removing cache directories" + remove_path(config["cache_base_dir"]) print "Removing pypo files" - remove_path(BASE_PATH) + remove_path(config["bin_dir"]) print "Removing daemontool script pypo" remove_path("/etc/service/pypo") diff --git a/python_apps/pypo/pypo.cfg b/python_apps/pypo/pypo.cfg index b1f9ed229..e2ab6fead 100644 --- a/python_apps/pypo/pypo.cfg +++ b/python_apps/pypo/pypo.cfg @@ -10,12 +10,22 @@ api_client = "airtime" ############################################ -# Directories / Hosts # -# _include_ trailing slash !! # +# Cache Directories # +# *include* trailing slash !! # ############################################ -cache_dir = '/opt/pypo/cache/' -file_dir = '/opt/pypo/files/' -tmp_dir = '/opt/pypo/tmp/' +cache_dir = '/var/tmp/airtime/pypo/cache/' +file_dir = '/var/tmp/airtime/pypo/files/' +tmp_dir = '/var/tmp/airtime/pypo/tmp/' + +############################################ +# Setup Directories # +# Do *not* include trailing slash !! # +############################################ +cache_base_dir = '/var/tmp/airtime/pypo' +bin_dir = '/usr/lib/airtime/pypo' +log_base_dir = '/var/log/airtime' +pypo_log_dir = '/var/log/airtime/pypo' +liquidsoap_log_dir = '/var/log/airtime/pypo-liquidsoap' # Hostname base_url = 'localhost' diff --git a/python_apps/pypo/scripts/ls_lib.liq b/python_apps/pypo/scripts/ls_lib.liq index 5bd611878..51a59e019 100644 --- a/python_apps/pypo/scripts/ls_lib.liq +++ b/python_apps/pypo/scripts/ls_lib.liq @@ -1,6 +1,6 @@ def notify(m) - system("/opt/pypo/bin/scripts/notify.sh --data='#{!pypo_data}' --media-id=#{m['schedule_table_id']}") - print("/opt/pypo/bin/scripts/notify.sh --data='#{!pypo_data}' --media-id=#{m['schedule_table_id']}") + system("/usr/lib/airtime/pypo/bin/scripts/notify.sh --data='#{!pypo_data}' --media-id=#{m['schedule_table_id']}") + print("/usr/lib/airtime/pypo/bin/scripts/notify.sh --data='#{!pypo_data}' --media-id=#{m['schedule_table_id']}") end # A function applied to each metadata chunk diff --git a/python_apps/pypo/scripts/old_files/README b/python_apps/pypo/scripts/old_files/README deleted file mode 100644 index 5e79bd7e3..000000000 --- a/python_apps/pypo/scripts/old_files/README +++ /dev/null @@ -1,23 +0,0 @@ -This directory contains scripts not directly related to pypo -These mainly are things related to liquidsoap & playout - -I added those scripts here to have them at hand for -development and also to update/share them via svn - - -scripts here: - -- ls_run.sh - wrapper to run liquid soap. makes sure that the "current" playlist is - filled with silence - -- ls_script.liq (called by ls_run.sh) - the main liquidsoap control-script - -- ls_cue.liq (included by ls_script.liq) - contains a custom protocol that registers the cue-in/out values from the playlist script - -- cue_file.py (called by ls_cue.liq) - a wrapper that does the actual cutting. - it is called with: path_to_file[path] cue_in[ss.ms] cue_out[ss.ms] and does the mp3 cutting (with mp3cut) - returns a temporary file that can be used by ls (make sure to set "TEMP_DIR" in script) \ No newline at end of file diff --git a/python_apps/pypo/scripts/old_files/cue_file.py b/python_apps/pypo/scripts/old_files/cue_file.py deleted file mode 100755 index 4d232ab1b..000000000 --- a/python_apps/pypo/scripts/old_files/cue_file.py +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - - -""" -cue script that gets called by liquidsoap if a file in the playlist -gives orders to cue (in/out). eg: -cue_file:cue_in=90.0,cue_out=110.0:annotate:*** - -cue_in is number of seconds from the beginning of the file. -cue_out is number of seconds from the end of the file. - -params: path_to_file, cue_in [float, seconds], cue_out [float, seconds] -returns: path to the cued temp-file - -examples: -calling: ./cue_file.py /storage/pypo/cache/2010-06-25-15-05-00/35.mp3 10 120.095 -returns: /tmp/lstf_UwDKcEngvF - -In this example, the first 10 seconds and last 120.095 seconds are cut off. The -middle part of the file is returned. - -One thing to mention here: -The way pypo (ab)uses liquidsoap can bring in some unwanted effects. liquidsoap -is built in a way that it tries to collect the needed files to playout in advance. -we 'force' liquidsoap to immediately start playing a newly loaded list, so ls has -no time to prepare the files. If a file is played without cues, this does not affect -the playout too much. My testing on a lame VM added a delay of +/- 10ms. - -If the first file in a playlist is cued, the "mp3cut" command takes time to execute. -On the same VM this takes an additional 200ms for an average size mp3-file. -So the playout will start a bit delayed. This should not be a too big issue, but -think about this behaviour if you eg access the files via network (nas) as the reading -of files could take some time as well. - -So maybe we should think about a different implementation. One way would be to do the -cueing during playlist preparation, so all the files would be pre-cut when they are -passed to liquidsoap. -Additionally this would allow to run an unpathed version of ls. - -""" - -import sys -import shutil -import random -import string -import time -from datetime import timedelta -import os - -from mutagen.mp3 import MP3 -from mutagen.oggvorbis import OggVorbis - -TEMP_DIR = '/tmp/'; - - -sys.stderr.write('\n** starting mp3/ogg cutter **\n\n') - -try: src = sys.argv[1] -except Exception, e: - sys.stderr.write('No file given. Exiting...\n') - sys.exit() - -try: cue_in = float(sys.argv[2]) -except Exception, e: - cue_in = float(0) - pass - -try: cue_out = float(sys.argv[3]) -except Exception, e: - cue_out = float(0) - pass - -sys.stderr.write('in: %s - out: %s file: %s \n' % (cue_in, cue_out, src)) -dst = TEMP_DIR + 'lstf_' + "".join( [random.choice(string.letters) for i in xrange(10)] ) -#TODO, there is no checking whether this randomly generated file name already exists! - - -# get length of track using mutagen. -#audio -#command -if src.lower().endswith('.mp3'): - audio = MP3(src) - dur = round(audio.info.length, 3) - - sys.stderr.write('duration: ' + str(dur) + '\n') - - cue_out = round(float(dur) - cue_out, 3) - - str_cue_in = str(timedelta(seconds=cue_in)).replace(".", "+") # hh:mm:ss+mss, eg 00:00:20+000 - str_cue_out = str(timedelta(seconds=cue_out)).replace(".", "+") # - - """ - now a bit a hackish part, don't know how to do this better... - need to cut the digits after the "+" - - """ - ts = str_cue_in.split("+") - try: - if len(ts[1]) == 6: - ts[1] = ts[1][0:3] - str_cue_in = "%s+%s" % (ts[0], ts[1]) - except Exception, e: - pass - - ts = str_cue_out.split("+") - try: - if len(ts[1]) == 6: - ts[1] = ts[1][0:3] - str_cue_out = "%s+%s" % (ts[0], ts[1]) - except Exception, e: - pass - - sys.stderr.write('in: ' + str_cue_in + '\n') - sys.stderr.write('abs: ' + str(str_cue_out) + '\n\n') - - command = 'mp3cut -o %s -t %s-%s %s' % (dst, str_cue_in, str_cue_out, src) -elif src.lower().endswith('.ogg'): - audio = OggVorbis(src) - dur = audio.info.length - sys.stderr.write('duration: ' + str(dur) + '\n') - - cue_out = float(dur) - cue_out - - #convert input format of ss.mmm to milliseconds and to string< - str_cue_in = str(int(round(cue_in*1000))) - - #convert input format of ss.mmm to milliseconds and to string - str_cue_out = str(int(round(cue_out*1000))) - - command = 'oggCut -s %s -e %s %s %s' % (str_cue_in, str_cue_out, src, dst) -else: - sys.stderr.write('File name with invalid extension. Exiting...\n') - sys.exit() - - - -sys.stderr.write(command + '\n\n\n') -os.system(command + ' > /dev/null 2>&1') - -print dst + "\n"; diff --git a/python_apps/pypo/scripts/old_files/include_daypart.liq b/python_apps/pypo/scripts/old_files/include_daypart.liq deleted file mode 100644 index e43c29e41..000000000 --- a/python_apps/pypo/scripts/old_files/include_daypart.liq +++ /dev/null @@ -1,70 +0,0 @@ - -######################################### -# A/B queue-setup daypart -######################################### - -# a/b queue setup -daypart_q0 = request.queue(conservative=true,length=600.,id="daypart_q0") -daypart_q1 = request.queue(conservative=true,length=600.,id="daypart_q1") - -daypart_q0 = audio_to_stereo(daypart_q0) -daypart_q1 = audio_to_stereo(daypart_q1) - -daypart_active = ref 0 -daypart_queue = ref 1 -daypart_q0_enabled = ref false -daypart_q1_enabled = ref false - -# push function, enqueues file in inactive queue (does not start automatically) -def daypart_push(s) - list.hd(server.execute("daypart_q#{!daypart_queue}.push #{s}")) - print('push to #{!daypart_queue} - #{s}') - "Done" -end - - -# flips the queues -def daypart_flip() - - # set a/b-queue corresponding to active, see fallback below - if !daypart_active==1 then daypart_q0_enabled:=true else daypart_q0_enabled:=false end - if !daypart_active==0 then daypart_q1_enabled:=true else daypart_q1_enabled:=false end - - # get playing (active) queue and flush it - l = list.hd(server.execute("daypart_q#{!daypart_active}.queue")) - l = string.split(separator=" ",l) - list.iter(fun (rid) -> ignore(server.execute("daypart_q#{!daypart_active}.ignore #{rid}")), l) - - # skip the playing item - # source.skip(if !daypart_active==0 then daypart_q0 else daypart_q1 end) - - # flip variables - daypart_active := 1-!daypart_active - daypart_queue := 1-!daypart_active - - "Done" -end - - -# print status -def daypart_status() - print('daypart_active: #{!daypart_active}') - print('daypart_queue : #{!daypart_queue}') - "Done" -end - -# register for telnet access -server.register(namespace="daypart","push", daypart_push) -server.register(namespace="daypart","flip", fun (_) -> daypart_flip()) -server.register(namespace="daypart","status", fun (_) -> daypart_status()) - - -# activate / deactivate queues, needed for fallback to work -daypart_q0 = switch(track_sensitive=true, [({!daypart_q0_enabled},daypart_q0)]) -daypart_q1 = switch(track_sensitive=true, [({!daypart_q1_enabled},daypart_q1)]) -daypart_q_holder = fallback(track_sensitive=true, [daypart_q0, daypart_q1]) - - -# finally the resulting daypart source -daypart = fallback(track_sensitive=false, [daypart_q_holder, default]) - diff --git a/python_apps/pypo/scripts/old_files/include_dynamic_vars.liq b/python_apps/pypo/scripts/old_files/include_dynamic_vars.liq deleted file mode 100644 index eb42668be..000000000 --- a/python_apps/pypo/scripts/old_files/include_dynamic_vars.liq +++ /dev/null @@ -1,17 +0,0 @@ -####################################################################### -# Dynamic variables -####################################################################### - -playlist_type = ref '0' -pypo_data = ref '0' - -def set_playlist_type(s) - playlist_type := s -end - -def set_pypo_data(s) - pypo_data := s -end - -server.register(namespace="vars", "playlist_type", fun (s) -> begin set_playlist_type(s) "Done!" end) -server.register(namespace="vars", "pypo_data", fun (s) -> begin set_pypo_data(s) "Done!" end) \ No newline at end of file diff --git a/python_apps/pypo/scripts/old_files/include_live_in.liq b/python_apps/pypo/scripts/old_files/include_live_in.liq deleted file mode 100644 index c2e6bef86..000000000 --- a/python_apps/pypo/scripts/old_files/include_live_in.liq +++ /dev/null @@ -1,20 +0,0 @@ -####################################################################### -# Live input - From external icecast server -####################################################################### -live_in = input.http(id="live_in",autostart=false,buffer=.1, max=12.,couchcaster_list) -live_in = buffer(id="buffer_live_in",buffer=.1,fallible=true,live_in) -live_in = mksafe(live_in) - -live_active = ref false -def live_switch(i) - print(i) - if i=='1' then live_active:=true else live_active:=false end - print(live_active) - "Done" -end -server.register(namespace="live","active", live_switch) - -live = switch(track_sensitive=false, [({!live_active},live_in)]) - -to_live_s = to_live(jingles_cc) -to_scheduler_s = to_scheduler() diff --git a/python_apps/pypo/scripts/old_files/include_notify.liq b/python_apps/pypo/scripts/old_files/include_notify.liq deleted file mode 100644 index 0c96cf31a..000000000 --- a/python_apps/pypo/scripts/old_files/include_notify.liq +++ /dev/null @@ -1,22 +0,0 @@ -######################################## -# call pypo api gateway -######################################## - -def notify(m) - - if !playlist_type=='5' then - #print('livesession') - system("./notify.sh --data='#{!pypo_data}' --media-id=#{m['media_id']} --export-source=scheduler") - end - - if !playlist_type=='6' then - #print('couchcaster') - system("./notify.sh --data='#{!pypo_data}' --media-id=#{m['media_id']} --export-source=scheduler") - end - - if !playlist_type=='0' or !playlist_type=='1' or !playlist_type=='2' or !playlist_type=='3' or !playlist_type=='4' then - #print('include_notify.liq: notify on playlist') - system("./notify.sh --data='#{!pypo_data}' --media-id=#{m['media_id']}") - end - -end \ No newline at end of file diff --git a/python_apps/pypo/scripts/old_files/include_scheduler.liq b/python_apps/pypo/scripts/old_files/include_scheduler.liq deleted file mode 100644 index 7ff446d4a..000000000 --- a/python_apps/pypo/scripts/old_files/include_scheduler.liq +++ /dev/null @@ -1,78 +0,0 @@ - -######################################### -# A/B queue-setup Scheduler -######################################### - -# a/b queue setup -scheduler_q0 = request.queue(conservative=true,length=600.,id="scheduler_q0") -scheduler_q1 = request.queue(conservative=true,length=600.,id="scheduler_q1") - -scheduler_q0 = audio_to_stereo(scheduler_q0) -scheduler_q1 = audio_to_stereo(scheduler_q1) - -scheduler_active = ref 0 -scheduler_queue = ref 1 -scheduler_q0_enabled = ref false -scheduler_q1_enabled = ref false - -# push function, enqueues file in inactive queue (does not start automatically) -def scheduler_push(s) - list.hd(server.execute("scheduler_q#{!scheduler_queue}.push #{s}")) - print('push to #{!scheduler_queue} - #{s}') - "Done" -end - - -# flips the queues -def scheduler_flip() - - # set a/b-queue corresponding to active, see fallback below - if !scheduler_active==1 then scheduler_q0_enabled:=true else scheduler_q0_enabled:=false end - if !scheduler_active==0 then scheduler_q1_enabled:=true else scheduler_q1_enabled:=false end - - # get playing (active) queue and flush it - l = list.hd(server.execute("scheduler_q#{!scheduler_active}.queue")) - l = string.split(separator=" ",l) - list.iter(fun (rid) -> ignore(server.execute("scheduler_q#{!scheduler_active}.ignore #{rid}")), l) - - # skip the playing item - source.skip(if !scheduler_active==0 then scheduler_q0 else scheduler_q1 end) - - # flip variables - scheduler_active := 1-!scheduler_active - scheduler_queue := 1-!scheduler_active - - - "Done" -end - - -# print status -def scheduler_status() - print('scheduler_active: #{!scheduler_active}') - print('scheduler_queue : #{!scheduler_queue}') - print('pypo_data: #{!pypo_data}') - - #print('user_id: #{!user_id}') - #print('playlist_id: #{!playlist_id}') - #print('transmission_id: #{!transmission_id}') - #print('playlist_type: #{!playlist_type}') - - "Done" -end - -# register for telnet access -server.register(namespace="scheduler","push", scheduler_push) -server.register(namespace="scheduler","flip", fun (_) -> scheduler_flip()) -server.register(namespace="scheduler","status", fun (_) -> scheduler_status()) - - -# activate / deactivate queues, needed for fallback to work -scheduler_q0 = switch(track_sensitive=true, [({!scheduler_q0_enabled},scheduler_q0)]) -scheduler_q1 = switch(track_sensitive=true, [({!scheduler_q1_enabled},scheduler_q1)]) -scheduler_q_holder = fallback(track_sensitive=true, [scheduler_q0, scheduler_q1]) - - -# finally the resulting scheduler source -scheduler = fallback(track_sensitive=false, [scheduler_q_holder, default]) - diff --git a/python_apps/pypo/scripts/old_files/library.liq b/python_apps/pypo/scripts/old_files/library.liq deleted file mode 100644 index 5b93ac8ff..000000000 --- a/python_apps/pypo/scripts/old_files/library.liq +++ /dev/null @@ -1,37 +0,0 @@ -# Define a transition that fades out the -# old source, adds a single, and then -# plays the new source -def to_live(jingle,old,new) = - # Fade out old source - old = fade.final(old) - # Supperpose the jingle - s = add([jingle,old]) - # Compose this in sequence with - # the new source - sequence([s,new]) -end - -def to_scheduler(old,new) = - # We skip the file - # currently in new - # in order to being with - # a fresh file - # source.skip(new) - sequence([old,new]) -end - -# A transition when switching back to files: -def to_file(old,new) = - # We skip the file - # currently in new - # in order to being with - # a fresh file - # source.skip(new) - sequence([old,new]) -end - - -def dp_to_scheduler(old,new) = - old = fade.final(type='log',duration=2.1,old) - sequence([old,new]) -end \ No newline at end of file diff --git a/python_apps/pypo/scripts/old_files/log_run.sh b/python_apps/pypo/scripts/old_files/log_run.sh deleted file mode 100755 index d373cac25..000000000 --- a/python_apps/pypo/scripts/old_files/log_run.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -DATE=$(date '+%Y-%m-%d') -CI_LOG=/var/log/obp/ci/log-$DATE.php - -clear -echo -echo "##############################" -echo "# STARTING PYPO MULTI-LOG #" -echo "##############################" -sleep 1 -clear - -# split -multitail -s 2 -cS pyml /var/log/obp/pypo/debug.log \ --cS pyml /var/log/obp/pypo/error.log \ --l "tail -f -n 50 $CI_LOG | grep API" \ -/var/log/obp/ls/ls_script.log diff --git a/python_apps/pypo/scripts/old_files/ls_config.liq.dist b/python_apps/pypo/scripts/old_files/ls_config.liq.dist deleted file mode 100644 index b71931879..000000000 --- a/python_apps/pypo/scripts/old_files/ls_config.liq.dist +++ /dev/null @@ -1,44 +0,0 @@ -########################################### -# liquidsoap config file # -########################################### - -# This config assumes that there are -# two instances of LS running -# the "scheduler" & the "fallback" instance - - -########################################### -# general settings # -########################################### - -log_file = "/var/log/pypo/