From 4fcb4a530f6cda910cf808510dc4a1fbe214c224 Mon Sep 17 00:00:00 2001 From: denise Date: Fri, 20 Apr 2012 10:21:14 -0400 Subject: [PATCH 01/18] CC-3330: Regression in library behavior: left click anywhere in a row should bring up menu, right click anywhere in row should bring up metadata -added README for jquery.contextMenu.js bug fix --- .../public/js/contextmenu/AIRTIME_DEV_README | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 airtime_mvc/public/js/contextmenu/AIRTIME_DEV_README diff --git a/airtime_mvc/public/js/contextmenu/AIRTIME_DEV_README b/airtime_mvc/public/js/contextmenu/AIRTIME_DEV_README new file mode 100644 index 000000000..d10d53c7b --- /dev/null +++ b/airtime_mvc/public/js/contextmenu/AIRTIME_DEV_README @@ -0,0 +1,23 @@ +Before you overwrite jquery.contextMenu.js, note that we have changed a few lines +in this file. + +denise@denise-DX4860:~/airtime/airtime_mvc/public/js/contextmenu$ diff -u jquery.contextMenu_orig.js jquery.contextMenu.js +--- jquery.contextMenu_orig.js 2012-04-20 10:15:59.943215571 -0400 ++++ jquery.contextMenu.js 2012-04-20 10:00:18.911178927 -0400 +@@ -306,6 +306,15 @@ + e.stopImmediatePropagation(); + $this.remove(); + root.$menu.trigger('contextmenu:hide'); ++ /* (Airtime) added this to allow user to exit out of menu. ++ * if ignoreThisClick remains false, every right click ++ * thereafter continues to show the menu ++ */ ++ if (ignoreRightClick) { ++ if (e.button == 2) { ++ ignoreThisClick = true; ++ } ++ } + }, + // key handled :hover + keyStop: function(e, opt) { + From c1a6202da87073ef75682f1dc123604f5e65b537 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 20 Apr 2012 10:56:51 -0400 Subject: [PATCH 02/18] CC-3630: Deleting files from organize folder if they don't have correct Meta data - done --- .../airtimefilemonitor/airtimeprocessevent.py | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py index 40022f571..e1e847b41 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py @@ -142,8 +142,15 @@ class AirtimeProcessEvent(ProcessEvent): #delete files from organize if they can not be read properly. if pathname is None: - os.remove(oldPath) - return + try: + self.logger.info("Deleting file because it cannot be read properly: %s", oldPath) + os.remove(oldPath) + return + except Exception, e: + import traceback + top = traceback.format_exc() + self.logger.error('Exception: %s', e) + self.logger.error("traceback: %s", top) self.mmc.set_needed_file_permissions(pathname, dir) is_recorded = self.mmc.is_parent_directory(pathname, self.config.recorded_directory) @@ -245,7 +252,14 @@ class AirtimeProcessEvent(ProcessEvent): #delete files from organize if they can not be read properly. if filepath is None: - os.remove(event.pathname) + try: + self.logger.info("Deleting file because it cannot be read properly: %s", event.pathname) + os.remove(event.pathname) + except Exception, e: + import traceback + top = traceback.format_exc() + self.logger.error('Exception: %s', e) + self.logger.error("traceback: %s", top) else: filepath = event.pathname @@ -258,7 +272,14 @@ class AirtimeProcessEvent(ProcessEvent): #delete files from organize if they can not be read properly. if filepath is None: - os.remove(event.pathname) + try: + self.logger.info("Deleting file because it cannot be read properly: %s", event.pathname) + os.remove(event.pathname) + except Exception, e: + import traceback + top = traceback.format_exc() + self.logger.error('Exception: %s', e) + self.logger.error("traceback: %s", top) else: #show dragged from unwatched folder into a watched folder. Do not "organize".:q! if self.mmc.is_parent_directory(event.pathname, self.config.recorded_directory): From da8a5296b0176cdc44c93826b784ae26f8c8d31d Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 20 Apr 2012 11:31:24 -0400 Subject: [PATCH 03/18] CC-3590: Calendar GUI->DJ user should not be able to invoke "Add Show" window -add user type into javascript as a variable so we can check permissions on js side --- airtime_mvc/application/Bootstrap.php | 8 ++++++++ airtime_mvc/application/models/User.php | 8 ++++++-- .../public/js/airtime/schedule/full-calendar-functions.js | 6 ++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php index bc41379a0..af676f201 100644 --- a/airtime_mvc/application/Bootstrap.php +++ b/airtime_mvc/application/Bootstrap.php @@ -76,6 +76,14 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap $view->headScript()->appendFile($baseUrl.'/js/airtime/common/common.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $user = Application_Model_User::GetCurrentUser(); + if (!is_null($user)){ + $userType = $user->getType(); + } else { + $userType = ""; + } + $view->headScript()->appendScript("var userType = '$userType';"); + if (Application_Model_Preference::GetPlanLevel() != "disabled" && ($_SERVER['REQUEST_URI'] != '/Dashboard/stream-player' || $_SERVER['REQUEST_URI'] != '/audiopreview/audio-preview-player')) { $client_id = Application_Model_Preference::GetClientId(); diff --git a/airtime_mvc/application/models/User.php b/airtime_mvc/application/models/User.php index 081110b50..6d012f1ff 100644 --- a/airtime_mvc/application/models/User.php +++ b/airtime_mvc/application/models/User.php @@ -295,7 +295,11 @@ class Application_Model_User { public static function GetCurrentUser() { $userinfo = Zend_Auth::getInstance()->getStorage()->read(); - - return new self($userinfo->id); + + if (is_null($userinfo)){ + return null; + } else { + return new self($userinfo->id); + } } } diff --git a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js index ac06b6962..7e5f8b53a 100644 --- a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js +++ b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js @@ -94,7 +94,7 @@ function pad(number, length) { function dayClick(date, allDay, jsEvent, view){ // The show from will be preloaded if the user is admin or program manager. // Hence, if the user if DJ then it won't open anything. - if($.trim($("#add-show-form").html()) != ""){ + if(userType == "A" || userType == "P"){ var now, today, selected, chosenDate, chosenTime; now = adjustDateToServerDate(new Date(), serverTimezoneOffset); @@ -212,7 +212,9 @@ function viewDisplay( view ) { } if(($("#add-show-form").length == 1) && ($("#add-show-form").css('display')=='none') && ($('.fc-header-left > span').length == 5)) { - if($.trim($("#add-show-form").html()) != ""){ + + //userType is defined in bootstrap.php, and is derived from the currently logged in user. + if(userType == "A" || userType == "P"){ makeAddShowButton(); } } From 558d2e5d9af03768c9b5a79c4fa5da286db12741 Mon Sep 17 00:00:00 2001 From: denise Date: Fri, 20 Apr 2012 13:01:47 -0400 Subject: [PATCH 04/18] CC-3330: Regression in library behavior: left click anywhere in a row should bring up menu, right click anywhere in row should bring up metadata --- airtime_mvc/public/js/contextmenu/jquery.contextMenu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/airtime_mvc/public/js/contextmenu/jquery.contextMenu.js b/airtime_mvc/public/js/contextmenu/jquery.contextMenu.js index 4f97a0dc3..759f54334 100755 --- a/airtime_mvc/public/js/contextmenu/jquery.contextMenu.js +++ b/airtime_mvc/public/js/contextmenu/jquery.contextMenu.js @@ -310,7 +310,7 @@ var // currently active contextMenu trigger * if ignoreThisClick remains false, every right click * thereafter continues to show the menu */ - if (ignoreRightClick) { + if (handle.ignoreRightClick) { if (e.button == 2) { ignoreThisClick = true; } From 5aa2339a1d7330b6d32e28b266caada1a679de60 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 20 Apr 2012 13:11:28 -0400 Subject: [PATCH 05/18] CC-3693: Uninstalling + Reinstall of Airtime + refreshing the page as a non-existant user causes a stack trace. -Fixed --- airtime_mvc/application/models/User.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/models/User.php b/airtime_mvc/application/models/User.php index 6d012f1ff..4a8fa8789 100644 --- a/airtime_mvc/application/models/User.php +++ b/airtime_mvc/application/models/User.php @@ -295,11 +295,18 @@ class Application_Model_User { public static function GetCurrentUser() { $userinfo = Zend_Auth::getInstance()->getStorage()->read(); - + if (is_null($userinfo)){ return null; } else { - return new self($userinfo->id); + try { + return new self($userinfo->id); + } catch (Exception $e){ + //we get here if $userinfo->id is defined, but doesn't exist + //in the database anymore. + Zend_Auth::getInstance()->clearIdentity(); + return null; + } } } } From 85bc15015965167b923f82650377f6cc11d233e1 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 20 Apr 2012 14:46:23 -0400 Subject: [PATCH 06/18] CC-3694: Upgrade fails with Propel database conversion. -fixed --- airtime_mvc/application/configs/airtime-conf-production.php | 1 + 1 file changed, 1 insertion(+) diff --git a/airtime_mvc/application/configs/airtime-conf-production.php b/airtime_mvc/application/configs/airtime-conf-production.php index 78e26d9d3..785b729c9 100644 --- a/airtime_mvc/application/configs/airtime-conf-production.php +++ b/airtime_mvc/application/configs/airtime-conf-production.php @@ -8,6 +8,7 @@ * that the user can customize these. */ +require_once (__DIR__."/conf.php"); global $CC_CONFIG; From 2a9ea435f2b000952d689840c7fa6184d1426a4c Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 20 Apr 2012 15:06:20 -0400 Subject: [PATCH 07/18] CC-3694: Upgrade fails with Propel database conversion. -fixed --- .../configs/airtime-conf-production.php | 2 -- airtime_mvc/application/configs/db-conf.php | 18 ++++++++++++++++++ .../include/airtime-installed-check.php | 2 +- install_minimal/include/airtime-upgrade.php | 4 +--- 4 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 airtime_mvc/application/configs/db-conf.php diff --git a/airtime_mvc/application/configs/airtime-conf-production.php b/airtime_mvc/application/configs/airtime-conf-production.php index 785b729c9..c880f6342 100644 --- a/airtime_mvc/application/configs/airtime-conf-production.php +++ b/airtime_mvc/application/configs/airtime-conf-production.php @@ -8,8 +8,6 @@ * that the user can customize these. */ -require_once (__DIR__."/conf.php"); - global $CC_CONFIG; $dbhost = $CC_CONFIG['dsn']['hostspec']; diff --git a/airtime_mvc/application/configs/db-conf.php b/airtime_mvc/application/configs/db-conf.php new file mode 100644 index 000000000..493d8e9b0 --- /dev/null +++ b/airtime_mvc/application/configs/db-conf.php @@ -0,0 +1,18 @@ +exec($sql); -$values = parse_ini_file(CONF_FILE_AIRTIME, true); -$phpDir = $values['general']['airtime_dir']; - $newVersion = AIRTIME_VERSION; $sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '$newVersion')"; $con->exec($sql); From 1654de64b1510e657119fa9d4525778831108a0f Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 20 Apr 2012 16:10:19 -0400 Subject: [PATCH 08/18] CC-1927: remove-pear-db -fixed install/uninstall messages --- install_minimal/include/AirtimeInstall.php | 10 ++++++++++ install_minimal/include/airtime-uninstall.php | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/install_minimal/include/AirtimeInstall.php b/install_minimal/include/AirtimeInstall.php index 107a002da..9b7038a82 100644 --- a/install_minimal/include/AirtimeInstall.php +++ b/install_minimal/include/AirtimeInstall.php @@ -60,6 +60,16 @@ class AirtimeInstall return null; } + try { + $version = $con->query($sql)->fetchColumn(0); + } catch (PDOException $e){ + // no pref table therefore Airtime is not installed. + //We only get here if airtime database exists, but the table doesn't + //This state sometimes happens if a previous Airtime uninstall couldn't remove + //the database because it was busy, so it just removed the tables instead. + return null; + } + $sql = "SELECT valstr FROM cc_pref WHERE keystr = 'system_version' LIMIT 1"; $version = $con->query($sql)->fetchColumn(0); diff --git a/install_minimal/include/airtime-uninstall.php b/install_minimal/include/airtime-uninstall.php index 0bfc38b63..8bd929851 100644 --- a/install_minimal/include/airtime-uninstall.php +++ b/install_minimal/include/airtime-uninstall.php @@ -18,6 +18,10 @@ if (!file_exists(AirtimeIni::CONF_FILE_AIRTIME)) { require_once(__DIR__.'/airtime-constants.php'); require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php'); + +require_once 'propel/runtime/lib/Propel.php'; +Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php"); + echo PHP_EOL; echo "* Uninstalling Airtime ".AIRTIME_VERSION.PHP_EOL; //AirtimeInstall::UninstallPhpCode(); From 79d8eda53ad3fd3a1bc1e448f926cf236a364cd5 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 20 Apr 2012 16:16:27 -0400 Subject: [PATCH 09/18] CC-1927: remove-pear-db -fixed install/uninstall messages --- install_minimal/include/AirtimeInstall.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/install_minimal/include/AirtimeInstall.php b/install_minimal/include/AirtimeInstall.php index 9b7038a82..4dc8555a8 100644 --- a/install_minimal/include/AirtimeInstall.php +++ b/install_minimal/include/AirtimeInstall.php @@ -60,6 +60,8 @@ class AirtimeInstall return null; } + $sql = "SELECT valstr FROM cc_pref WHERE keystr = 'system_version' LIMIT 1"; + try { $version = $con->query($sql)->fetchColumn(0); } catch (PDOException $e){ @@ -70,17 +72,10 @@ class AirtimeInstall return null; } - $sql = "SELECT valstr FROM cc_pref WHERE keystr = 'system_version' LIMIT 1"; - $version = $con->query($sql)->fetchColumn(0); - - if (!$version) { - // no pref table something is wrong. - return null; - } - + //if version is empty string, then version is older than version 1.8.0 if ($version == '') { try { - // If this table exists, then it's 1.7.0 + // If this table exists, then it's version 1.7.0 $sql = "SELECT * FROM cc_show_rebroadcast LIMIT 1"; $result = $con->query($sql)->fetchColumn(0); $version = "1.7.0"; From 6e9b179afc0d62cfc97b0d5d7de02de1245e05cb Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 20 Apr 2012 16:57:32 -0400 Subject: [PATCH 10/18] CC-3603: Calendar->Once you update the rebroadcasted show it disappears -fixed --- .../controllers/ScheduleController.php | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index d1ebe0721..c71794a83 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -31,7 +31,6 @@ class ScheduleController extends Zend_Controller_Action ->addActionContext('set-time-interval', 'json') ->addActionContext('edit-show-instance', 'json') ->addActionContext('dj-edit-show', 'json') - ->addActionContext('edit-show-rebroadcast', 'json') ->initContext(); $this->sched_sess = new Zend_Session_Namespace("schedule"); @@ -522,11 +521,6 @@ class ScheduleController extends Zend_Controller_Action // repeating shows. It's value is either "instance","rebroadcast", or "all" $type = $this->_getParam('type'); - /*if($type == "rebroadcast") { - //$this->view->action = "edit-show-rebroadcast"; - } else { - $this->view->action = "edit-show"; - }*/ $this->view->action = "edit-show"; try{ $showInstance = new Application_Model_ShowInstance($showInstanceId); @@ -695,17 +689,6 @@ class ScheduleController extends Zend_Controller_Action $this->view->form = $this->view->render('schedule/add-show-form.phtml'); } } - - public function editShowRebroadcastAction(){ - $js = $this->_getParam('data'); - $data = array(); - - //need to convert from serialized jQuery array. - foreach($js as $j){ - $data[$j["name"]] = $j["value"]; - } - - } public function djEditShowAction(){ $js = $this->_getParam('data'); From dae8682e51e85051d7d81fda0e0f834b187846b4 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Fri, 20 Apr 2012 18:32:10 -0400 Subject: [PATCH 11/18] CC-3691: Pypo needs to write stderr + stdout to the log file -fixed --- install_minimal/include/airtime-copy-files.sh | 1 + python_apps/media-monitor/MediaMonitor.py | 10 ++++++++-- python_apps/pypo/pypo-notify.py | 8 +++++++- python_apps/pypo/pypocli.py | 7 ++++++- python_apps/pypo/pypofetch.py | 7 ++++++- python_apps/pypo/pypofile.py | 8 +++++++- python_apps/pypo/pypomessagehandler.py | 8 +++++++- python_apps/pypo/pypopush.py | 7 ++++++- python_apps/std_err_override/LogWriter.py | 11 +++++++++++ python_apps/std_err_override/__init__.py | 0 10 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 python_apps/std_err_override/LogWriter.py create mode 100644 python_apps/std_err_override/__init__.py diff --git a/install_minimal/include/airtime-copy-files.sh b/install_minimal/include/airtime-copy-files.sh index 9689bc2ea..62ac6524a 100755 --- a/install_minimal/include/airtime-copy-files.sh +++ b/install_minimal/include/airtime-copy-files.sh @@ -69,6 +69,7 @@ fi mkdir -p /usr/lib/airtime cp -R $AIRTIMEROOT/utils /usr/lib/airtime +cp -R $AIRTIMEROOT/python_apps/std_err_override /usr/lib/airtime echo "* Creating symbolic links in /usr/bin" #create symbolic links diff --git a/python_apps/media-monitor/MediaMonitor.py b/python_apps/media-monitor/MediaMonitor.py index 9bc2c3052..d3f8bb0cd 100644 --- a/python_apps/media-monitor/MediaMonitor.py +++ b/python_apps/media-monitor/MediaMonitor.py @@ -6,6 +6,7 @@ import os import signal from api_clients import api_client as apc +from std_err_override import LogWriter from multiprocessing import Process, Queue as mpQueue @@ -23,12 +24,17 @@ from airtimefilemonitor.airtimemediamonitorbootstrap import AirtimeMediaMonitorB # configure logging try: logging.config.fileConfig("logging.cfg") + + #need to wait for Python 2.7 for this.. + #logging.captureWarnings(True) + + logger = logging.getLogger() + LogWriter.override_std_err(logger) + except Exception, e: print 'Error configuring logging: ', e sys.exit(1) -logger = logging.getLogger() - logger.info("\n\n*** Media Monitor bootup ***\n\n") try: diff --git a/python_apps/pypo/pypo-notify.py b/python_apps/pypo/pypo-notify.py index ebd8e0f5b..d5b4edff5 100644 --- a/python_apps/pypo/pypo-notify.py +++ b/python_apps/pypo/pypo-notify.py @@ -36,6 +36,7 @@ from configobj import ConfigObj # custom imports #from util import * from api_clients import * +from std_err_override import LogWriter # Set up command-line options parser = OptionParser() @@ -59,13 +60,18 @@ parser.add_option("-y", "--source-status", help="source connection stauts", meta # configure logging logging.config.fileConfig("logging.cfg") +logger = logging.getLogger() +LogWriter.override_std_err(logger) + +#need to wait for Python 2.7 for this.. +#logging.captureWarnings(True) # loading config file try: config = ConfigObj('/etc/airtime/pypo.cfg') except Exception, e: - print 'error: ', e + logger.error('Error loading config file: %s', e) sys.exit() diff --git a/python_apps/pypo/pypocli.py b/python_apps/pypo/pypocli.py index 6a9649d5a..06bb71380 100644 --- a/python_apps/pypo/pypocli.py +++ b/python_apps/pypo/pypocli.py @@ -23,6 +23,7 @@ from configobj import ConfigObj # custom imports from api_clients import api_client +from std_err_override import LogWriter PYPO_VERSION = '1.1' @@ -45,12 +46,16 @@ parser.add_option("-c", "--check", help="Check the cached schedule and exit", de # configure logging logging.config.fileConfig("logging.cfg") +logger = logging.getLogger() +LogWriter.override_std_err(logger) + +#need to wait for Python 2.7 for this.. +#logging.captureWarnings(True) # loading config file try: config = ConfigObj('/etc/airtime/pypo.cfg') except Exception, e: - logger = logging.getLogger() logger.error('Error loading config file: %s', e) sys.exit() diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index de806f3c8..a7695490d 100644 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -10,11 +10,17 @@ import copy from threading import Thread from api_clients import api_client +from std_err_override import LogWriter from configobj import ConfigObj # configure logging logging.config.fileConfig("logging.cfg") +logger = logging.getLogger() +LogWriter.override_std_err(logger) + +#need to wait for Python 2.7 for this.. +#logging.captureWarnings(True) # loading config file try: @@ -24,7 +30,6 @@ try: POLL_INTERVAL = int(config['poll_interval']) except Exception, e: - logger = logging.getLogger() logger.error('Error loading config file: %s', e) sys.exit() diff --git a/python_apps/pypo/pypofile.py b/python_apps/pypo/pypofile.py index 271aa9e0a..1a52fd5c8 100644 --- a/python_apps/pypo/pypofile.py +++ b/python_apps/pypo/pypofile.py @@ -8,8 +8,15 @@ import shutil import os import sys +from std_err_override import LogWriter + # configure logging logging.config.fileConfig("logging.cfg") +logger = logging.getLogger() +LogWriter.override_std_err(logger) + +#need to wait for Python 2.7 for this.. +#logging.captureWarnings(True) # loading config file try: @@ -19,7 +26,6 @@ try: POLL_INTERVAL = int(config['poll_interval']) except Exception, e: - logger = logging.getLogger() logger.error('Error loading config file: %s', e) sys.exit(1) diff --git a/python_apps/pypo/pypomessagehandler.py b/python_apps/pypo/pypomessagehandler.py index 23e269b16..128ebec13 100644 --- a/python_apps/pypo/pypomessagehandler.py +++ b/python_apps/pypo/pypomessagehandler.py @@ -10,8 +10,15 @@ from kombu.messaging import Exchange, Queue from kombu.simple import SimpleQueue import json +from std_err_override import LogWriter + # configure logging logging.config.fileConfig("logging.cfg") +logger = logging.getLogger('message_h') +LogWriter.override_std_err(logger) + +#need to wait for Python 2.7 for this.. +#logging.captureWarnings(True) # loading config file try: @@ -21,7 +28,6 @@ try: POLL_INTERVAL = int(config['poll_interval']) except Exception, e: - logger = logging.getLogger('message_h') logger.error('Error loading config file: %s', e) sys.exit() diff --git a/python_apps/pypo/pypopush.py b/python_apps/pypo/pypopush.py index 6efa6d857..c6063e9d6 100644 --- a/python_apps/pypo/pypopush.py +++ b/python_apps/pypo/pypopush.py @@ -16,11 +16,17 @@ from Queue import Empty from threading import Thread from api_clients import api_client +from std_err_override import LogWriter from configobj import ConfigObj # configure logging logging.config.fileConfig("logging.cfg") +logger = logging.getLogger() +LogWriter.override_std_err(logger) + +#need to wait for Python 2.7 for this.. +#logging.captureWarnings(True) # loading config file try: @@ -30,7 +36,6 @@ try: PUSH_INTERVAL = 2 MAX_LIQUIDSOAP_QUEUE_LENGTH = 2 except Exception, e: - logger = logging.getLogger() logger.error('Error loading config file %s', e) sys.exit() diff --git a/python_apps/std_err_override/LogWriter.py b/python_apps/std_err_override/LogWriter.py new file mode 100644 index 000000000..65da21ff8 --- /dev/null +++ b/python_apps/std_err_override/LogWriter.py @@ -0,0 +1,11 @@ +import sys + +class LogWriter(): + def __init__(self, logger): + self.logger = logger + + def write(self, txt): + self.logger.error(txt) + +def override_std_err(logger): + sys.stderr = LogWriter(logger) diff --git a/python_apps/std_err_override/__init__.py b/python_apps/std_err_override/__init__.py new file mode 100644 index 000000000..e69de29bb From a4dc68c465b8b59b2bf6a97db506e37936d4950d Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Sat, 21 Apr 2012 20:20:05 -0400 Subject: [PATCH 12/18] -missing -m option for arglist --- utils/airtime-test-stream.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/utils/airtime-test-stream.py b/utils/airtime-test-stream.py index 2f349c592..9e10a63a4 100644 --- a/utils/airtime-test-stream.py +++ b/utils/airtime-test-stream.py @@ -42,7 +42,7 @@ def find_liquidsoap_binary(): return None -optlist, args = getopt.getopt(sys.argv[1:], 'hvo:H:P:u:p:') +optlist, args = getopt.getopt(sys.argv[1:], 'hvo:H:P:u:p:m:') stream_types = set(["shoutcast", "icecast"]) verbose = False @@ -102,6 +102,8 @@ try: if not verbose: command += " 2>/dev/null | grep \"failed\"" + else: + print command #print command rv = subprocess.call(command, shell=True) From 86282a8d8a2f4c1c4865f31294792c086f85efd4 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Sun, 22 Apr 2012 12:01:40 -0400 Subject: [PATCH 13/18] CC-3699: Calls to system() function from our Liquidsoap script are blocking -fixed --- python_apps/pypo/liquidsoap_scripts/ls_lib.liq | 12 ++++++------ python_apps/pypo/liquidsoap_scripts/ls_script.liq | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/python_apps/pypo/liquidsoap_scripts/ls_lib.liq b/python_apps/pypo/liquidsoap_scripts/ls_lib.liq index 3d070152c..e076327a5 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_lib.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_lib.liq @@ -1,6 +1,6 @@ def notify(m) - log("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --data='#{!pypo_data}' --media-id=#{m['schedule_table_id']}") - system("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --data='#{!pypo_data}' --media-id=#{m['schedule_table_id']}") + log("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --data='#{!pypo_data}' --media-id=#{m['schedule_table_id']} &") + system("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --data='#{!pypo_data}' --media-id=#{m['schedule_table_id']} &") end # A function applied to each metadata chunk @@ -65,14 +65,14 @@ end def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, description, genre, user, s, stream, connected) = def on_error(msg) connected := "false" - 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}") + 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() connected := "true" - 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}") + 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 7391be42c..efbd221de 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -81,8 +81,8 @@ end set("harbor.bind_addr", "0.0.0.0") def update_source_status(sourcename, status) = - system("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --source-name=#{sourcename} --source-status=#{status}") - log("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --source-name=#{sourcename} --source-status=#{status}") + system("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --source-name=#{sourcename} --source-status=#{status} &") + log("/usr/lib/airtime/pypo/bin/liquidsoap_scripts/notify.sh --source-name=#{sourcename} --source-status=#{status} &") end def live_dj_connect(header) = From 7c49fc77d51cea8c1bec26de91481fded24fa6a3 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Sun, 22 Apr 2012 13:42:45 -0400 Subject: [PATCH 14/18] CC-3700: media-monitor- Surround all accesses to external resources with try/except -fixed --- python_apps/media-monitor/MediaMonitor.py | 8 ++-- .../airtimefilemonitor/airtimemetadata.py | 4 +- .../airtimefilemonitor/airtimenotifier.py | 7 +++- .../airtimefilemonitor/airtimeprocessevent.py | 31 +++++++------- .../airtimefilemonitor/mediaconfig.py | 2 +- .../airtimefilemonitor/mediamonitorcommon.py | 41 +++++++++++++------ .../airtimefilemonitor/workerprocess.py | 2 + 7 files changed, 58 insertions(+), 37 deletions(-) diff --git a/python_apps/media-monitor/MediaMonitor.py b/python_apps/media-monitor/MediaMonitor.py index d3f8bb0cd..3fa9fe912 100644 --- a/python_apps/media-monitor/MediaMonitor.py +++ b/python_apps/media-monitor/MediaMonitor.py @@ -4,6 +4,7 @@ import logging.config import sys import os import signal +import traceback from api_clients import api_client as apc from std_err_override import LogWriter @@ -59,7 +60,8 @@ try: multi_queue = mpQueue() logger.info("Initializing event processor") except Exception, e: - logger.error('Exception: %s', e) + logger.error('Exception: %s', e) + logger.error("traceback: %s", traceback.format_exc()) try: @@ -96,7 +98,5 @@ except KeyboardInterrupt: notifier.stop() logger.info("Keyboard Interrupt") except Exception, e: - import traceback - top = traceback.format_exc() logger.error('Exception: %s', e) - logger.error("traceback: %s", top) + logger.error("traceback: %s", traceback.format_exc()) diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimemetadata.py b/python_apps/media-monitor/airtimefilemonitor/airtimemetadata.py index ad5047380..cab57381c 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimemetadata.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimemetadata.py @@ -140,9 +140,7 @@ class AirtimeMetadata: if key in self.mutagen2airtime and len(file_info[key]) > 0: md[self.mutagen2airtime[key]] = file_info[key][0] if 'MDATA_KEY_TITLE' not in md: - #get rid of file extention from original name, name might have more than 1 '.' in it. - #filepath = to_unicode(filepath) - #filepath = filepath.encode('utf-8') + #get rid of file extension from original name, name might have more than 1 '.' in it. original_name = os.path.basename(filepath) original_name = original_name.split(".")[0:-1] original_name = ''.join(original_name) diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimenotifier.py b/python_apps/media-monitor/airtimefilemonitor/airtimenotifier.py index 72dee15f2..42f22b0ba 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimenotifier.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimenotifier.py @@ -2,6 +2,7 @@ import json import time import os import logging +import traceback # For RabbitMQ from kombu.connection import BrokerConnection @@ -116,7 +117,11 @@ class AirtimeNotifier(Notifier): if m['delete']: self.logger.info("Deleting file: %s ", filepath) - os.unlink(filepath) + try: + os.unlink(filepath) + except Exception, e: + self.logger.error('Exception: %s', e) + self.logger.error("traceback: %s", traceback.format_exc()) """ diff --git a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py index e1e847b41..0d6a6e602 100644 --- a/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py +++ b/python_apps/media-monitor/airtimefilemonitor/airtimeprocessevent.py @@ -4,6 +4,7 @@ import time import os import shutil import difflib +import traceback import pyinotify from pyinotify import ProcessEvent @@ -147,10 +148,8 @@ class AirtimeProcessEvent(ProcessEvent): os.remove(oldPath) return except Exception, e: - import traceback - top = traceback.format_exc() self.logger.error('Exception: %s', e) - self.logger.error("traceback: %s", top) + self.logger.error("traceback: %s", traceback.format_exc()) self.mmc.set_needed_file_permissions(pathname, dir) is_recorded = self.mmc.is_parent_directory(pathname, self.config.recorded_directory) @@ -255,11 +254,10 @@ class AirtimeProcessEvent(ProcessEvent): try: self.logger.info("Deleting file because it cannot be read properly: %s", event.pathname) os.remove(event.pathname) + return except Exception, e: - import traceback - top = traceback.format_exc() self.logger.error('Exception: %s', e) - self.logger.error("traceback: %s", top) + self.logger.error("traceback: %s", traceback.format_exc()) else: filepath = event.pathname @@ -275,11 +273,10 @@ class AirtimeProcessEvent(ProcessEvent): try: self.logger.info("Deleting file because it cannot be read properly: %s", event.pathname) os.remove(event.pathname) + return except Exception, e: - import traceback - top = traceback.format_exc() self.logger.error('Exception: %s', e) - self.logger.error("traceback: %s", top) + self.logger.error("traceback: %s", traceback.format_exc()) else: #show dragged from unwatched folder into a watched folder. Do not "organize".:q! if self.mmc.is_parent_directory(event.pathname, self.config.recorded_directory): @@ -370,9 +367,15 @@ class AirtimeProcessEvent(ProcessEvent): # handling those cases. We are manully calling handle_created_file # function. if os.path.exists(k): - # check if file is open - command = "lsof "+k - f = os.popen(command) + # check if file is open + try: + command = "lsof "+k + f = os.popen(command) + except Exception, e: + self.logger.error('Exception: %s', e) + self.logger.error("traceback: %s", traceback.format_exc()) + continue + if not f.readlines(): self.logger.info("Handling file: %s", k) self.handle_created_file(False, k, os.path.basename(k)) @@ -387,9 +390,7 @@ class AirtimeProcessEvent(ProcessEvent): except socket.timeout: pass except Exception, e: - import traceback - top = traceback.format_exc() self.logger.error('Exception: %s', e) - self.logger.error("traceback: %s", top) + self.logger.error("traceback: %s", traceback.format_exc()) time.sleep(3) diff --git a/python_apps/media-monitor/airtimefilemonitor/mediaconfig.py b/python_apps/media-monitor/airtimefilemonitor/mediaconfig.py index 2ddd71680..1d60d7b97 100644 --- a/python_apps/media-monitor/airtimefilemonitor/mediaconfig.py +++ b/python_apps/media-monitor/airtimefilemonitor/mediaconfig.py @@ -18,7 +18,7 @@ class AirtimeMediaConfig: self.cfg = config except Exception, e: logger.info('Error loading config: ', e) - sys.exit() + sys.exit(1) self.storage_directory = None diff --git a/python_apps/media-monitor/airtimefilemonitor/mediamonitorcommon.py b/python_apps/media-monitor/airtimefilemonitor/mediamonitorcommon.py index 4563915a8..7a6e833c1 100644 --- a/python_apps/media-monitor/airtimefilemonitor/mediamonitorcommon.py +++ b/python_apps/media-monitor/airtimefilemonitor/mediamonitorcommon.py @@ -4,6 +4,7 @@ import pwd import logging import stat import subprocess +import traceback from subprocess import Popen, PIPE from airtimemetadata import AirtimeMetadata @@ -49,22 +50,25 @@ class MediaMonitorCommon: #check if file is readable by "nobody" def has_correct_permissions(self, filepath, euid='nobody', egid='nogroup'): - uid = pwd.getpwnam(euid)[2] - gid = grp.getgrnam(egid)[2] - - #drop root permissions and become "nobody" - os.setegid(gid) - os.seteuid(uid) try: + uid = pwd.getpwnam(euid)[2] + gid = grp.getgrnam(egid)[2] + + #drop root permissions and become "nobody" + os.setegid(gid) + os.seteuid(uid) + open(filepath) readable = True except IOError: self.logger.warn("File does not have correct permissions: '%s'", filepath) readable = False + self.logger.error("traceback: %s", traceback.format_exc()) except Exception, e: self.logger.error("Unexpected exception thrown: %s", e) readable = False + self.logger.error("traceback: %s", traceback.format_exc()) finally: #reset effective user to root os.seteuid(0) @@ -96,10 +100,11 @@ class MediaMonitorCommon: os.chmod(item, bitor) except Exception, e: self.logger.error("Failed to change file's owner/group/permissions. %s", e) - return False; + self.logger.error("traceback: %s", traceback.format_exc()) + return False finally: os.umask(omask) - return True; + return True #checks if path is a directory, and if it doesnt exist, then creates it. @@ -125,6 +130,7 @@ class MediaMonitorCommon: os.rename(source, dest) except Exception, e: self.logger.error("failed to move file. %s", e) + self.logger.error("traceback: %s", traceback.format_exc()) finally: os.umask(omask) @@ -137,8 +143,13 @@ class MediaMonitorCommon: def cleanup_empty_dirs(self, dir): if os.path.normpath(dir) != self.config.organize_directory: if len(os.listdir(dir)) == 0: - os.rmdir(dir) - + try: + os.rmdir(dir) + except Exception, e: + #non-critical exception because we probably tried to delete a non-empty dir. + #Don't need to log this, let's just "return" + return + pdir = os.path.dirname(dir) self.cleanup_empty_dirs(pdir) @@ -272,9 +283,13 @@ class MediaMonitorCommon: def touch_index_file(self): dirname = os.path.dirname(self.timestamp_file) - if not os.path.exists(dirname): - os.makedirs(dirname) - open(self.timestamp_file, "w") + try: + if not os.path.exists(dirname): + os.makedirs(dirname) + open(self.timestamp_file, "w") + except Exception, e: + self.logger.error('Exception: %s', e) + self.logger.error("traceback: %s", traceback.format_exc()) def organize_new_file(self, pathname): self.logger.info("Organizing new file: %s", pathname) diff --git a/python_apps/media-monitor/airtimefilemonitor/workerprocess.py b/python_apps/media-monitor/airtimefilemonitor/workerprocess.py index ddbea39a6..5e8fddcb6 100644 --- a/python_apps/media-monitor/airtimefilemonitor/workerprocess.py +++ b/python_apps/media-monitor/airtimefilemonitor/workerprocess.py @@ -1,5 +1,6 @@ from mediaconfig import AirtimeMediaConfig import mediamonitorcommon +import traceback class MediaMonitorWorkerProcess: @@ -20,3 +21,4 @@ class MediaMonitorWorkerProcess: notifier.update_airtime(event) except Exception, e: notifier.logger.error(e) + notifier.logger.error("traceback: %s", traceback.format_exc()) From 71a1fb393e4992b664a76056934ec6a68953ba8a Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Sun, 22 Apr 2012 13:43:05 -0400 Subject: [PATCH 15/18] -lsof may not be installed on all distributions... --- install_full/ubuntu/airtime-full-install | 2 +- install_full/ubuntu/airtime-full-install-nginx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/install_full/ubuntu/airtime-full-install b/install_full/ubuntu/airtime-full-install index 18881796b..7f2892500 100755 --- a/install_full/ubuntu/airtime-full-install +++ b/install_full/ubuntu/airtime-full-install @@ -39,7 +39,7 @@ php-pear php5-gd postgresql odbc-postgresql python2.6 libsoundtouch-ocaml \ libtaglib-ocaml libao-ocaml libmad-ocaml ecasound \ libesd0 libportaudio2 libsamplerate0 rabbitmq-server patch \ php5-curl mpg123 monit python-virtualenv multitail libcamomile-ocaml-data \ -libpulse0 vorbis-tools lsb-release +libpulse0 vorbis-tools lsb-release lsof #install packages with --force-yes option (this is useful in the case #of Debian, where these packages are unauthorized) diff --git a/install_full/ubuntu/airtime-full-install-nginx b/install_full/ubuntu/airtime-full-install-nginx index 2466ff33e..049168739 100755 --- a/install_full/ubuntu/airtime-full-install-nginx +++ b/install_full/ubuntu/airtime-full-install-nginx @@ -42,7 +42,7 @@ php-pear php5-gd postgresql odbc-postgresql python2.6 libsoundtouch-ocaml \ libtaglib-ocaml libao-ocaml libmad-ocaml ecasound \ libesd0 libportaudio2 libsamplerate0 rabbitmq-server patch \ php5-curl mpg123 monit python-virtualenv multitail libcamomile-ocaml-data \ -libpulse0 vorbis-tools lsb-release +libpulse0 vorbis-tools lsb-release lsof #install packages with --force-yes option (this is useful in the case #of Debian, where these packages are unauthorized) From 4d776772a90142eedb1d811523a938b223956f4d Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Sun, 22 Apr 2012 13:45:38 -0400 Subject: [PATCH 16/18] CC-3698: php5-fpm service with airtime pool won't start because of php_admin_value[phar.readonly] = off -fixed --- airtime_mvc/public/.htaccess | 3 +-- install_full/php5-fpm/airtime.conf | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/airtime_mvc/public/.htaccess b/airtime_mvc/public/.htaccess index e60e50a67..c9d6c4c1c 100644 --- a/airtime_mvc/public/.htaccess +++ b/airtime_mvc/public/.htaccess @@ -2,7 +2,6 @@ php_value post_max_size 500M php_value upload_max_filesize 500M php_value request_order "GPC" php_value session.gc_probability 0 -php_value phar.readonly Off php_value session.auto_start 0 RewriteEngine On @@ -22,4 +21,4 @@ AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript -AddOutputFilterByType DEFLATE application/json \ No newline at end of file +AddOutputFilterByType DEFLATE application/json diff --git a/install_full/php5-fpm/airtime.conf b/install_full/php5-fpm/airtime.conf index ea396422f..cb0e2f335 100644 --- a/install_full/php5-fpm/airtime.conf +++ b/install_full/php5-fpm/airtime.conf @@ -247,5 +247,4 @@ php_admin_value[post_max_size] = 500M php_admin_value[upload_max_filesize] = 500M php_admin_value[request_order] = GPC php_admin_value[session.gc_probability] = 0 -php_admin_value[phar.readonly] = off php_admin_value[upload_tmp_dir] = /tmp From 5e5ced6fe57a50ecfe21388663e4ee0d78323074 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Sun, 22 Apr 2012 14:28:02 -0400 Subject: [PATCH 17/18] CC-3701: Need to differentiate between a service being down vs not-monitored (airtime-check-system) -fixed --- .../application/models/Systemstatus.php | 20 ++++++++++++++++++- utils/airtime-check-system.php | 4 ++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/airtime_mvc/application/models/Systemstatus.php b/airtime_mvc/application/models/Systemstatus.php index 679b57c19..81969d9d6 100644 --- a/airtime_mvc/application/models/Systemstatus.php +++ b/airtime_mvc/application/models/Systemstatus.php @@ -43,6 +43,16 @@ class Application_Model_Systemstatus "memory_perc"=>"0%", "memory_kb"=>"0", "cpu_perc"=>"0%"); + + $notMonitored = array( + "name"=>$p_serviceName, + "process_id"=>"NOT MONITORED", + "uptime_seconds"=>"-1", + "status"=>false, + "memory_perc"=>"0%", + "memory_kb"=>"0", + "cpu_perc"=>"0%" + ); $notRunning = array( "name"=>$p_serviceName, @@ -66,8 +76,16 @@ class Application_Model_Systemstatus $status = $monitor->item(0)->nodeValue; if ($status == "2"){ $data = $starting; + } else if ($status == 1){ + //is monitored, but is it running? + $pid = $item->getElementsByTagName("pid"); + if ($pid->length == 0){ + $data = $notRunning; + } else { + //running! + } } else if ($status == 0){ - $data = $notRunning; + $data = $notMonitored; } } diff --git a/utils/airtime-check-system.php b/utils/airtime-check-system.php index 736aac80c..a91fa4efa 100644 --- a/utils/airtime-check-system.php +++ b/utils/airtime-check-system.php @@ -222,6 +222,7 @@ class AirtimeCheck { global $showColor; $RED = "[0;31m"; + $ORANGE = "[0;33m"; $GREEN = "[1;32m"; $color = $GREEN; @@ -229,6 +230,9 @@ class AirtimeCheck { if ($value == "FAILED"){ $color = $RED; self::$AIRTIME_STATUS_OK = false; + } else if ($value == "NOT MONITORED"){ + $color = $ORANGE; + self::$AIRTIME_STATUS_OK = false; } if ($showColor) From b9ab11ce28744e6ea7f7729b0e7eabcdbe37954c Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Mon, 23 Apr 2012 17:18:34 -0400 Subject: [PATCH 18/18] CC-3702: System -> Status: No difference between a service is failed vs a service is not monitor -fixed --- airtime_mvc/application/controllers/ApiController.php | 1 + airtime_mvc/application/models/Systemstatus.php | 10 +++++----- airtime_mvc/public/css/styles.css | 10 +++++++++- airtime_mvc/public/js/airtime/status/status.js | 10 +++++++++- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 9243ee0a6..37c091e7f 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -784,6 +784,7 @@ class ApiController extends Zend_Controller_Action $request = $this->getRequest(); $api_key = $request->getParam('api_key'); $getDiskInfo = $request->getParam('diskinfo') == "true"; + if (!in_array($api_key, $CC_CONFIG["apiKey"]) && is_null(Zend_Auth::getInstance()->getStorage()->read())) { diff --git a/airtime_mvc/application/models/Systemstatus.php b/airtime_mvc/application/models/Systemstatus.php index 81969d9d6..fd798bc57 100644 --- a/airtime_mvc/application/models/Systemstatus.php +++ b/airtime_mvc/application/models/Systemstatus.php @@ -39,7 +39,7 @@ class Application_Model_Systemstatus "name"=>"", "process_id"=>"STARTING...", "uptime_seconds"=>"-1", - "status"=>true, + "status"=>0, "memory_perc"=>"0%", "memory_kb"=>"0", "cpu_perc"=>"0%"); @@ -47,8 +47,8 @@ class Application_Model_Systemstatus $notMonitored = array( "name"=>$p_serviceName, "process_id"=>"NOT MONITORED", - "uptime_seconds"=>"-1", - "status"=>false, + "uptime_seconds"=>"1", + "status"=>1, "memory_perc"=>"0%", "memory_kb"=>"0", "cpu_perc"=>"0%" @@ -58,7 +58,7 @@ class Application_Model_Systemstatus "name"=>$p_serviceName, "process_id"=>"FAILED", "uptime_seconds"=>"-1", - "status"=>false, + "status"=>0, "memory_perc"=>"0%", "memory_kb"=>"0", "cpu_perc"=>"0%" @@ -97,7 +97,7 @@ class Application_Model_Systemstatus $process_id = $item->getElementsByTagName("pid"); if ($process_id->length > 0){ $data["process_id"] = $process_id->item(0)->nodeValue; - $data["status"] = true; + $data["status"] = 0; } $uptime = $item->getElementsByTagName("uptime"); diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index 983bb64a5..d00131463 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -2310,6 +2310,14 @@ tfoot tr th { margin:0; display:block; } +.warning-icon { + width:100%; + margin:0; + background: url("images/warning-icon.png") no-repeat center center; + height:16px; + margin:0; + display:block; +} .statustable ul { margin:4px 0; padding:0; @@ -2656,4 +2664,4 @@ dd .stream-status { background-color: #727272; outline: 0; border-top-color:#333333 -} \ No newline at end of file +} diff --git a/airtime_mvc/public/js/airtime/status/status.js b/airtime_mvc/public/js/airtime/status/status.js index 5f4a245e2..db2b09ad4 100644 --- a/airtime_mvc/public/js/airtime/status/status.js +++ b/airtime_mvc/public/js/airtime/status/status.js @@ -48,7 +48,15 @@ function success(data, textStatus, jqXHR){ var s = services[key]; var children = $("#"+s.name).children(); $(children[0]).text(s.name); - $($(children[1]).children()[0]).attr("class", s.status ? "checked-icon": "not-available-icon"); + + var status_class = "not-available-icon"; + if (s.status == 0){ + status_class = "checked-icon"; + } else if (s.status == 1) { + status_class = "warning-icon"; + } + + $($(children[1]).children()[0]).attr("class", status_class); $(children[2]).text(sprintf('%(days)sd %(hours)sh %(minutes)sm %(seconds)ss', convertSecondsToDaysHoursMinutesSeconds(s.uptime_seconds))); $(children[3]).text(s.cpu_perc); $(children[4]).text(sprintf('%01.1fMB (%s)', parseInt(s.memory_kb)/1000, s.memory_perc));