From 9e39bba2c65f68bb9fa9a9343d282f4405a27acc Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 29 Nov 2011 17:42:06 -0500 Subject: [PATCH 1/5] -remove APPLICATION_ENV from .htaccess file --- airtime_mvc/public/.htaccess | 2 -- 1 file changed, 2 deletions(-) diff --git a/airtime_mvc/public/.htaccess b/airtime_mvc/public/.htaccess index 3dfbebfef..48c40b1dd 100644 --- a/airtime_mvc/public/.htaccess +++ b/airtime_mvc/public/.htaccess @@ -11,5 +11,3 @@ RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L] RewriteBase / - -SetEnv APPLICATION_ENV development From 0e592ffba3a6a466ad75e783276f0f78dcb958ae Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Tue, 29 Nov 2011 17:42:25 -0500 Subject: [PATCH 2/5] -fix for testing scripts --- dev_tools/fabric/fab_release_test.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/dev_tools/fabric/fab_release_test.py b/dev_tools/fabric/fab_release_test.py index 417aa564d..9210b142f 100644 --- a/dev_tools/fabric/fab_release_test.py +++ b/dev_tools/fabric/fab_release_test.py @@ -186,11 +186,20 @@ def debian_squeeze_64(fresh_os=True): if (fresh_os): create_fresh_os('Debian_Squeeze_64', debian=True) +def airtime_180_tar(): + airtime_18x_tar("1.8.0") + +def airtime_181_tar(): + airtime_18x_tar("1.8.1") + def airtime_182_tar(): + airtime_18x_tar("1.8.2") + +def airtime_18x_tar(version): do_sudo('apt-get update') do_sudo('apt-get install -y tar gzip unzip apache2 php5-pgsql libapache2-mod-php5 ' + \ 'php-pear php5-gd postgresql odbc-postgresql python python-configobj poc-streamer ' + \ - 'lame daemontools daemontools-run python-mutagen libsoundtouch-ocaml do_sudo ' + \ + 'lame daemontools daemontools-run python-mutagen libsoundtouch-ocaml sudo ' + \ 'libtaglib-ocaml libao-ocaml libmad-ocaml libesd0 icecast2 oggvideotools ' + \ 'libportaudio2 libsamplerate0 libcamomile-ocaml-dev ecasound php5-curl mpg123 ' + \ 'python-setuptools python-pip rabbitmq-server libvorbis-ocaml-dev libmp3lame-dev flac') @@ -217,9 +226,9 @@ def airtime_182_tar(): sed('/etc/default/icecast2', 'ENABLE=false', 'ENABLE=true', use_sudo=True) do_sudo('service icecast2 start') - do_run('wget http://downloads.sourceforge.net/project/airtime/1.8.2/airtime-1.8.2.tar.gz') - do_run('tar xfz airtime-1.8.2.tar.gz') - do_sudo('cd ~/airtime-1.8.2/install && php airtime-install.php') + do_run('wget http://downloads.sourceforge.net/project/airtime/%s/airtime-%s.tar.gz' % (version, version)) + do_run('tar xfz airtime-%s.tar.gz' % version) + do_sudo('cd ~/airtime-%s/install && php airtime-install.php' % version) #need to reboot because of daemon-tools. reboot(45) From 9c65bfeba72b4a131da470fdb49d80a1c07f9afd Mon Sep 17 00:00:00 2001 From: James Date: Tue, 29 Nov 2011 20:15:38 -0500 Subject: [PATCH 3/5] CC-3131: Latency of stream authentication warning in Stream Settings page - it compares boot time of liquidsoap and the time user clicks on "Save" on stream setting page. The status only gets updated if the "boot_time" > "user update time" - as soon as a user click on save, status is set to "wating" - since there is no timing issue, quering interval is reduced to 1 sec --- .../application/controllers/ApiController.php | 6 ++-- .../controllers/PreferenceController.php | 5 +++ airtime_mvc/application/models/Preference.php | 19 ++++++++++++ .../application/models/StreamSetting.php | 31 ++++++++++++------- .../js/airtime/preferences/streamsetting.js | 4 ++- python_apps/api_clients/api_client.cfg | 4 +-- python_apps/api_clients/api_client.py | 6 ++-- .../pypo/liquidsoap_scripts/ls_lib.liq | 8 ++--- .../pypo/liquidsoap_scripts/ls_script.liq | 2 ++ python_apps/pypo/pypo-notify.py | 15 +++++---- 10 files changed, 71 insertions(+), 29 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 8e97e639c..9cc28589f 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -772,15 +772,17 @@ class ApiController extends Zend_Controller_Action $error_msg = $request->getParam('error_msg'); $stream_id = $request->getParam('stream_id'); - Application_Model_StreamSetting::setLiquidsoapError($stream_id, $error_msg); + $boot_time = $request->getParam('boot_time'); + Application_Model_StreamSetting::setLiquidsoapError($stream_id, $error_msg, $boot_time); } public function updateLiquidsoapConnectionAction(){ $request = $this->getRequest(); $stream_id = $request->getParam('stream_id'); + $boot_time = $request->getParam('boot_time'); // setting error_msg as "" when there is no error_msg - Application_Model_StreamSetting::setLiquidsoapError($stream_id, "OK"); + Application_Model_StreamSetting::setLiquidsoapError($stream_id, "OK", $boot_time); } /** diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index ec846c52e..83bd44748 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -203,6 +203,11 @@ class PreferenceController extends Zend_Controller_Action Application_Model_StreamSetting::setStreamSetting($values); $data = array(); $data['setting'] = Application_Model_StreamSetting::getStreamSetting(); + for($i=1;$i<=$num_of_stream;$i++){ + Application_Model_StreamSetting::setLiquidsoapError($i, "waiting"); + } + // store stream update timestamp + Application_Model_Preference::SetStreamUpdateTimestamp(); Application_Model_RabbitMq::SendMessageToPypo("update_stream_setting", $data); $this->view->statusMsg = "
Stream Setting Updated.
"; } diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 2307b458a..cc95e7fe3 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -573,6 +573,25 @@ class Application_Model_Preference return $val; } } + + /** + * Stores the last timestamp of user updating stream setting + */ + public static function SetStreamUpdateTimestamp() { + $now = time(); + self::SetValue("stream_update_timestamp", $now); + } + + /** + * Gets the last timestamp of user updating stream setting + */ + public static function GetStreamUpdateTimestemp() { + $update_time = self::GetValue("stream_update_timestamp"); + if($update_time == null){ + $update_time = 0; + } + return $update_time; + } /* User specific preferences start */ diff --git a/airtime_mvc/application/models/StreamSetting.php b/airtime_mvc/application/models/StreamSetting.php index d14843d8b..e742ff594 100644 --- a/airtime_mvc/application/models/StreamSetting.php +++ b/airtime_mvc/application/models/StreamSetting.php @@ -113,22 +113,29 @@ class Application_Model_StreamSetting { } } - public static function setLiquidsoapError($stream_id, $msg){ + /* + * Stores liquidsoap status if $boot_time > save time. + * save time is the time that user clicked save on stream setting page + */ + public static function setLiquidsoapError($stream_id, $msg, $boot_time=null){ global $CC_DBC; - $keyname = "s".$stream_id."_liquidsoap_error"; - $sql = "SELECT COUNT(*) FROM cc_stream_setting" - ." WHERE keyname = '$keyname'"; - $result = $CC_DBC->GetOne($sql); - if ($result == 1){ - $sql = "UPDATE cc_stream_setting" - ." SET value = '$msg'" + $update_time = Application_Model_Preference::GetStreamUpdateTimestemp(); + if($boot_time == null || $boot_time > $update_time ){ + $keyname = "s".$stream_id."_liquidsoap_error"; + $sql = "SELECT COUNT(*) FROM cc_stream_setting" ." WHERE keyname = '$keyname'"; - }else{ - $sql = "INSERT INTO cc_stream_setting (keyname, value, type)" - ." VALUES ('$keyname', '$msg', 'string')"; + $result = $CC_DBC->GetOne($sql); + if ($result == 1){ + $sql = "UPDATE cc_stream_setting" + ." SET value = '$msg'" + ." WHERE keyname = '$keyname'"; + }else{ + $sql = "INSERT INTO cc_stream_setting (keyname, value, type)" + ." VALUES ('$keyname', '$msg', 'string')"; + } + $res = $CC_DBC->query($sql); } - $res = $CC_DBC->query($sql); } public static function getLiquidsoapError($stream_id){ diff --git a/airtime_mvc/public/js/airtime/preferences/streamsetting.js b/airtime_mvc/public/js/airtime/preferences/streamsetting.js index 277d1e34a..eea41e0c2 100644 --- a/airtime_mvc/public/js/airtime/preferences/streamsetting.js +++ b/airtime_mvc/public/js/airtime/preferences/streamsetting.js @@ -96,6 +96,8 @@ function checkLiquidsoapStatus(){ html = '

Connected to the streaming server

' }else if(status == "N/A"){ html = '

The stream is disabled

' + }else if(status == "waiting"){ + html = '

Getting information from the server...

' }else{ html = '

Can not connect to the streaming server

'+status+'

' } @@ -163,6 +165,6 @@ $(document).ready(function() { }) showErrorSections() - setInterval('checkLiquidsoapStatus()', 7000) + setInterval('checkLiquidsoapStatus()', 1000) }); \ No newline at end of file diff --git a/python_apps/api_clients/api_client.cfg b/python_apps/api_clients/api_client.cfg index 3457db2e3..f9da7739a 100644 --- a/python_apps/api_clients/api_client.cfg +++ b/python_apps/api_clients/api_client.cfg @@ -93,10 +93,10 @@ generate_range_url = 'generate_range_dp.php' get_stream_setting = 'get-stream-setting/format/json/api_key/%%api_key%%/' #URL to update liquidsoap error msg -update_liquidsoap_error = 'update-liquidsoap-error/format/json/api_key/%%api_key%%/error_msg/%%error_msg%%/stream_id/%%stream_id%%' +update_liquidsoap_error = 'update-liquidsoap-error/format/json/api_key/%%api_key%%/error_msg/%%error_msg%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%' #URL to update liquidsoap connection -update_liquidsoap_connection = 'update-liquidsoap-connection/format/json/api_key/%%api_key%%/stream_id/%%stream_id%%' +update_liquidsoap_connection = 'update-liquidsoap-connection/format/json/api_key/%%api_key%%/stream_id/%%stream_id%%/boot_time/%%boot_time%%' ############## # OBP config # diff --git a/python_apps/api_clients/api_client.py b/python_apps/api_clients/api_client.py index 7c944b468..6ec5b6819 100755 --- a/python_apps/api_clients/api_client.py +++ b/python_apps/api_clients/api_client.py @@ -571,7 +571,7 @@ class AirTimeApiClient(ApiClientInterface): except Exception, e: logger.error("Exception: %s", e) - def notify_liquidsoap_error(self, error_msg, stream_id): + def notify_liquidsoap_error(self, error_msg, stream_id, time): logger = logging.getLogger() try: url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["update_liquidsoap_error"]) @@ -581,19 +581,21 @@ class AirTimeApiClient(ApiClientInterface): encoded_msg = urllib.quote(error_msg, '') url = url.replace("%%error_msg%%", encoded_msg) url = url.replace("%%stream_id%%", stream_id) + url = url.replace("%%boot_time%%", time) logger.debug(url) req = urllib2.Request(url) response = urllib2.urlopen(req).read() except Exception, e: logger.error("Exception: %s", e) - def notify_liquidsoap_connection(self, stream_id): + def notify_liquidsoap_connection(self, stream_id, time): logger = logging.getLogger() try: url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["update_liquidsoap_connection"]) url = url.replace("%%api_key%%", self.config["api_key"]) url = url.replace("%%stream_id%%", stream_id) + url = url.replace("%%boot_time%%", time) logger.debug(url) req = urllib2.Request(url) response = urllib2.urlopen(req).read() diff --git a/python_apps/pypo/liquidsoap_scripts/ls_lib.liq b/python_apps/pypo/liquidsoap_scripts/ls_lib.liq index d278d570b..f6e966989 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_lib.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_lib.liq @@ -39,13 +39,13 @@ end def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, description, genre, user, s, stream) = def on_error(msg) - system("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --error='#{msg}' --stream-id=#{stream}") - log("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --error='#{msg}' --stream-id=#{stream}") + system("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --error='#{msg}' --stream-id=#{stream} --time=#{time}") + log("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --error='#{msg}' --stream-id=#{stream} --time=#{time}") 5. end def on_connect() - system("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --connect --stream-id=#{stream}") - log("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --connect --stream-id=#{stream}") + system("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --connect --stream-id=#{stream} --time=#{time}") + log("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --connect --stream-id=#{stream} --time=#{time}") end if output_type == "icecast" then user_ref = ref user diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index 80b4dca26..7a7c3c7be 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -6,6 +6,8 @@ set("log.stdout", true) set("server.telnet", true) set("server.telnet.port", 1234) +time = gettimeofday() + queue = audio_to_stereo(request.queue(id="queue", length=0.5)) queue = cue_cut(queue) diff --git a/python_apps/pypo/pypo-notify.py b/python_apps/pypo/pypo-notify.py index 5b1842f1c..a6cf103dc 100644 --- a/python_apps/pypo/pypo-notify.py +++ b/python_apps/pypo/pypo-notify.py @@ -50,6 +50,7 @@ parser.add_option("-m", "--media-id", help="ID of the file that is currently pla parser.add_option("-e", "--error", action="store", dest="error", type="string", help="liquidsoap error msg.", metavar="error_msg") parser.add_option("-s", "--stream-id", help="ID stream", metavar="stream_id") parser.add_option("-c", "--connect", help="liquidsoap connected", action="store_true", metavar="connect") +parser.add_option("-t", "--time", help="liquidsoap boot up time", action="store", dest="time", metavar="time", type="string") # parse options (options, args) = parser.parse_args() @@ -80,23 +81,25 @@ class Notify: response = self.api_client.notify_media_item_start_playing(data, media_id) logger.debug("Response: "+json.dumps(response)) - def notify_liquidsoap_error(self, error_msg, stream_id): + # @pram time: time that LS started + def notify_liquidsoap_error(self, error_msg, stream_id, time): logger = logging.getLogger() logger.debug('#################################################') logger.debug('# Calling server to update liquidsoap error #') logger.debug('#################################################') logger.debug('error msg = '+ str(error_msg)) - response = self.api_client.notify_liquidsoap_error(error_msg, stream_id) + response = self.api_client.notify_liquidsoap_error(error_msg, stream_id, time) logger.debug("Response: "+json.dumps(response)) - def notify_liquidsoap_connection(self, stream_id): + # @pram time: time that LS started + def notify_liquidsoap_connection(self, stream_id, time): logger = logging.getLogger() logger.debug('#################################################') logger.debug('# Calling server to update liquidsoap connection#') logger.debug('#################################################') - response = self.api_client.notify_liquidsoap_connection(stream_id) + response = self.api_client.notify_liquidsoap_connection(stream_id, time) logger.debug("Response: "+json.dumps(response)) if __name__ == '__main__': @@ -112,13 +115,13 @@ if __name__ == '__main__': if options.error and options.stream_id: try: n = Notify() - n.notify_liquidsoap_error(options.error, options.stream_id) + n.notify_liquidsoap_error(options.error, options.stream_id, options.time) except Exception, e: print e elif options.connect and options.stream_id: try: n = Notify() - n.notify_liquidsoap_connection(options.stream_id) + n.notify_liquidsoap_connection(options.stream_id, options.time) except Exception, e: print e else: From c399a4ad0a59611dad864cf18a0235b72e68e0d0 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Wed, 30 Nov 2011 11:41:10 -0500 Subject: [PATCH 4/5] CC-3145: create debian full install -done --- dev_tools/fabric/fab_release_test.py | 14 +++++++------- install_full/debian/airtime-full-install | 14 ++++++++++++++ install_full/ubuntu/airtime-full-install | 9 +++++++++ 3 files changed, 30 insertions(+), 7 deletions(-) create mode 100755 install_full/debian/airtime-full-install diff --git a/dev_tools/fabric/fab_release_test.py b/dev_tools/fabric/fab_release_test.py index 9210b142f..6145a5733 100644 --- a/dev_tools/fabric/fab_release_test.py +++ b/dev_tools/fabric/fab_release_test.py @@ -143,8 +143,8 @@ def create_fresh_os(vm_name, lucid=False, debian=False): #installed before. do_sudo('echo "rabbitmq-server rabbitmq-server/upgrade_previous note" | debconf-set-selections') - if debian: - append('/etc/apt/sources.list', "deb http://www.debian-multimedia.org squeeze main non-free", use_sudo=True) + #if debian: + #append('/etc/apt/sources.list', "deb http://www.debian-multimedia.org squeeze main non-free", use_sudo=True) def ubuntu_lucid_32(fresh_os=True): if (fresh_os): @@ -187,15 +187,15 @@ def debian_squeeze_64(fresh_os=True): create_fresh_os('Debian_Squeeze_64', debian=True) def airtime_180_tar(): - airtime_18x_tar("1.8.0") + airtime_18x_tar("airtime", "1.8.0") def airtime_181_tar(): - airtime_18x_tar("1.8.1") + airtime_18x_tar("airtime", "1.8.1") def airtime_182_tar(): - airtime_18x_tar("1.8.2") + airtime_18x_tar("airtime-1.8.2" "1.8.2") -def airtime_18x_tar(version): +def airtime_18x_tar(root_dir, version): do_sudo('apt-get update') do_sudo('apt-get install -y tar gzip unzip apache2 php5-pgsql libapache2-mod-php5 ' + \ 'php-pear php5-gd postgresql odbc-postgresql python python-configobj poc-streamer ' + \ @@ -228,7 +228,7 @@ def airtime_18x_tar(version): do_run('wget http://downloads.sourceforge.net/project/airtime/%s/airtime-%s.tar.gz' % (version, version)) do_run('tar xfz airtime-%s.tar.gz' % version) - do_sudo('cd ~/airtime-%s/install && php airtime-install.php' % version) + do_sudo('cd ~/%s/install && php airtime-install.php' % root_dir) #need to reboot because of daemon-tools. reboot(45) diff --git a/install_full/debian/airtime-full-install b/install_full/debian/airtime-full-install new file mode 100755 index 000000000..805f1ee7e --- /dev/null +++ b/install_full/debian/airtime-full-install @@ -0,0 +1,14 @@ +#!/bin/bash +# +# Auto install script for airtime on Debian + + +#Current dir +# Absolute path to this script, e.g. /home/user/bin/foo.sh +SCRIPT=`readlink -f $0` +# Absolute path this script is in, thus /home/user/bin +SCRIPTPATH=`dirname $SCRIPT` + +cd $SCRIPTPATH/../ubuntu +./airtime-full-install + diff --git a/install_full/ubuntu/airtime-full-install b/install_full/ubuntu/airtime-full-install index c4c3f82c9..995acddfa 100755 --- a/install_full/ubuntu/airtime-full-install +++ b/install_full/ubuntu/airtime-full-install @@ -22,6 +22,15 @@ echo "----------------------------------------------------" echo " 1. Install Packages" echo "----------------------------------------------------" +dist=`lsb_release -is` + +if [ "$dist" -eq "Debian" ]; then + grep "deb http://www.debian-multimedia.org squeeze main non-free" /etc/apt/sources.list + if [ "$?" -ne "0" ]; then + echo "deb http://www.debian-multimedia.org squeeze main non-free" > /etc/apt/sources.list + fi +fi + apt-get update # Updated package list From 05dea59e558a1629caf530c5c1a5450f8f4a451c Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Wed, 30 Nov 2011 11:43:28 -0500 Subject: [PATCH 5/5] CC-3145: create debian full install -don't overwrite existing sources.list --- install_full/ubuntu/airtime-full-install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_full/ubuntu/airtime-full-install b/install_full/ubuntu/airtime-full-install index 995acddfa..3b94a73e7 100755 --- a/install_full/ubuntu/airtime-full-install +++ b/install_full/ubuntu/airtime-full-install @@ -27,7 +27,7 @@ dist=`lsb_release -is` if [ "$dist" -eq "Debian" ]; then grep "deb http://www.debian-multimedia.org squeeze main non-free" /etc/apt/sources.list if [ "$?" -ne "0" ]; then - echo "deb http://www.debian-multimedia.org squeeze main non-free" > /etc/apt/sources.list + echo "deb http://www.debian-multimedia.org squeeze main non-free" >> /etc/apt/sources.list fi fi