From 41e2b5d84024c4be6afc0507669aef2f56f24267 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Wed, 23 Apr 2014 11:52:10 -0400 Subject: [PATCH 1/5] Fix the failed uploads view --- airtime_mvc/application/controllers/PluploadController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/controllers/PluploadController.php b/airtime_mvc/application/controllers/PluploadController.php index abd03afc3..5b45a5924 100644 --- a/airtime_mvc/application/controllers/PluploadController.php +++ b/airtime_mvc/application/controllers/PluploadController.php @@ -49,9 +49,10 @@ class PluploadController extends Zend_Controller_Action $numTotalRecentUploads = $recentUploadsQuery->find()->count(); if ($filter == "pending") { - $recentUploadsQuery->filterByDbImportStatus("1"); + $recentUploadsQuery->filterByDbImportStatus(1); } else if ($filter == "failed") { - $recentUploadsQuery->filterByDbImportStatus(array('min' => 100)); + $recentUploadsQuery->filterByDbImportStatus(2); + //TODO: Consider using array('min' => 200)) or something if we have multiple errors codes for failure. } $recentUploads = $recentUploadsQuery->offset($rowStart)->limit($limit)->find(); From b920ed2598c875a8665f65b42e2b60a771c4b9d9 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Wed, 23 Apr 2014 12:21:39 -0400 Subject: [PATCH 2/5] Fixed a bunch of installer stuff for Naomi --- install_minimal/airtime-install | 12 +++++++-- install_minimal/include/airtime-copy-files.sh | 6 +++-- install_minimal/include/airtime-upgrade.php | 3 +++ utils/airtime-check-system.php | 27 ++++++++++--------- 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/install_minimal/airtime-install b/install_minimal/airtime-install index 833cb447e..25423119f 100755 --- a/install_minimal/airtime-install +++ b/install_minimal/airtime-install @@ -38,6 +38,7 @@ rabbitmq_install () { rabbitmqctl add_vhost $RABBITMQ_VHOST rabbitmqctl add_user $RABBITMQ_USER $RABBITMQ_PASSWORD rabbitmqctl set_permissions -p $RABBITMQ_VHOST $RABBITMQ_USER "$EXCHANGES" "$EXCHANGES" "$EXCHANGES" + rabbitmqctl set_permissions -p $RABBITMQ_VHOST $RABBITMQ_USER .\* .\* .\* export RABBITMQ_USER export RABBITMQ_PASSWORD @@ -49,6 +50,7 @@ preserve="f" nodb="f" reinstall="f" mediamonitor="f" +airtime_analyzer="f" pypo="f" showrecorder="f" web="f" @@ -64,6 +66,7 @@ do (-n|--no-db) nodb="t";; (-r|--reinstall) reinstall="t";; (-m|--media-monitor) mediamonitor="t";; + (-a|--airtime-analyzer) airtime_analyzer="t";; (-y|--pypo) pypo="t";; (-w|--web) web="t";; (-d|--disable-deb-check) disable_deb_check="t";; @@ -75,11 +78,12 @@ do shift done -if [ "$mediamonitor" = "f" -a "$pypo" = "f" -a "$web" = "f" ]; then +if [ "$mediamonitor" = "f" -a "$pypo" = "f" -a "$web" = "f" -a "$airtime_analyzer" = "f" ]; then #none of these install parameters were specified, so by default we install all of them - mediamonitor="t" + mediamonitor="f" # FIXME: Remove media_monitor! -- Albert pypo="t" showrecorder="t" + airtime_analyzer="t" web="t" fi @@ -181,6 +185,7 @@ fi #export these variables to make them available in sub bash scripts export DO_UPGRADE export mediamonitor +export airtime_analyzer export pypo export showrecorder export web @@ -236,6 +241,9 @@ if [ "$mediamonitor" = "t" -o "$pypo" = "t" ]; then deactivate fi +# Restart airtime_analyzer (or start it) +service airtime_analyzer restart + #An attempt to force apache to realize that files are updated on upgrade... touch /usr/share/airtime/public/index.php diff --git a/install_minimal/include/airtime-copy-files.sh b/install_minimal/include/airtime-copy-files.sh index ced1786de..8f26b7d3f 100755 --- a/install_minimal/include/airtime-copy-files.sh +++ b/install_minimal/include/airtime-copy-files.sh @@ -64,8 +64,10 @@ echo "* Creating /usr/lib/airtime" if [ "$python_service" -eq "0" ]; then python $AIRTIMEROOT/python_apps/api_clients/install/api_client_install.py - if [ "$mediamonitor" = "t" ]; then - python $AIRTIMEROOT/python_apps/media-monitor/install/media-monitor-copy-files.py + if [ "$airtime_analyzer" = "t" ]; then + pushd $AIRTIMEROOT/python_apps/airtime_analyzer/ + python setup.py install + popd fi if [ "$pypo" = "t" ]; then python $AIRTIMEROOT/python_apps/pypo/install/pypo-copy-files.py diff --git a/install_minimal/include/airtime-upgrade.php b/install_minimal/include/airtime-upgrade.php index af9f971d4..5e8754ec5 100644 --- a/install_minimal/include/airtime-upgrade.php +++ b/install_minimal/include/airtime-upgrade.php @@ -65,6 +65,9 @@ if ($return_code == 0) { exit(1); } +// Stop media-monitor +service media-monitor stop-with-monit + //convert strings like 1.9.0-devel to 1.9.0 $version = substr($version, 0, 5); diff --git a/utils/airtime-check-system.php b/utils/airtime-check-system.php index 3a4816dcf..76e313c74 100644 --- a/utils/airtime-check-system.php +++ b/utils/airtime-check-system.php @@ -195,19 +195,20 @@ class AirtimeCheck { $log = "/var/log/airtime/pypo-liquidsoap/ls_script.log"; self::show_log_file($log); } - if (isset($services->media_monitor) && $services->media_monitor->process_id != "FAILED") { - self::output_status("MEDIA_MONITOR_PROCESS_ID", $data->services->media_monitor->process_id); - self::output_status("MEDIA_MONITOR_RUNNING_SECONDS", $data->services->media_monitor->uptime_seconds); - self::output_status("MEDIA_MONITOR_MEM_PERC", $data->services->media_monitor->memory_perc); - self::output_status("MEDIA_MONITOR_CPU_PERC", $data->services->media_monitor->cpu_perc); - } else { - self::output_status("MEDIA_MONITOR_PROCESS_ID", "FAILED"); - self::output_status("MEDIA_MONITOR_RUNNING_SECONDS", "0"); - self::output_status("MEDIA_MONITOR_MEM_PERC", "0%"); - self::output_status("MEDIA_MONITOR_CPU_PERC", "0%"); - $log = "/var/log/airtime/media-monitor/media-monitor.log"; - self::show_log_file($log); - } + + #if (isset($services->media_monitor) && $services->media_monitor->process_id != "FAILED") { + # self::output_status("MEDIA_MONITOR_PROCESS_ID", $data->services->media_monitor->process_id); + # self::output_status("MEDIA_MONITOR_RUNNING_SECONDS", $data->services->media_monitor->uptime_seconds); + # self::output_status("MEDIA_MONITOR_MEM_PERC", $data->services->media_monitor->memory_perc); + # self::output_status("MEDIA_MONITOR_CPU_PERC", $data->services->media_monitor->cpu_perc); + #} else { + # self::output_status("MEDIA_MONITOR_PROCESS_ID", "FAILED"); + # self::output_status("MEDIA_MONITOR_RUNNING_SECONDS", "0"); + # self::output_status("MEDIA_MONITOR_MEM_PERC", "0%"); + # self::output_status("MEDIA_MONITOR_CPU_PERC", "0%"); + # $log = "/var/log/airtime/media-monitor/media-monitor.log"; + # self::show_log_file($log); + #} } if (self::$AIRTIME_STATUS_OK){ From 3e34f1cf96984ad59c6d6c1d35701aa39f354da3 Mon Sep 17 00:00:00 2001 From: Naomi Date: Wed, 23 Apr 2014 12:53:43 -0400 Subject: [PATCH 3/5] fixing up some datatables queries, propel usage. --- .../controllers/PluploadController.php | 53 +++++++++---------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/airtime_mvc/application/controllers/PluploadController.php b/airtime_mvc/application/controllers/PluploadController.php index 5b45a5924..84e1289c9 100644 --- a/airtime_mvc/application/controllers/PluploadController.php +++ b/airtime_mvc/application/controllers/PluploadController.php @@ -34,56 +34,53 @@ class PluploadController extends Zend_Controller_Action public function recentUploadsAction() { - if (isset($_GET['uploadFilter'])) { - $filter = $_GET['uploadFilter']; - } else { - $filter = "all"; - } + $request = $this->getRequest(); + + $filter = $request->getParam('uploadFilter', "all"); + $limit = intval($request->getParam('iDisplayLength', 10)); + $rowStart = intval($request->getParam('iDisplayStart', 0)); - $limit = isset($_GET['iDisplayLength']) ? $_GET['iDisplayLength'] : 10; - $rowStart = isset($_GET['iDisplayStart']) ? $_GET['iDisplayStart'] : 0; + $recentUploadsQuery = CcFilesQuery::create(); + //old propel 1.5 to reuse this query item (for counts/finds) + $recentUploadsQuery->keepQuery(true); - $recentUploadsQuery = CcFilesQuery::create()->filterByDbUtime(array('min' => time() - 30 * 24 * 60 * 60)) - ->orderByDbUtime(Criteria::DESC); - - $numTotalRecentUploads = $recentUploadsQuery->find()->count(); + $numTotalRecentUploads = $recentUploadsQuery->count(); + $numTotalDisplayUploads = $numTotalRecentUploads; if ($filter == "pending") { $recentUploadsQuery->filterByDbImportStatus(1); + $numTotalDisplayUploads = $recentUploadsQuery->count(); } else if ($filter == "failed") { - $recentUploadsQuery->filterByDbImportStatus(2); + $recentUploadsQuery->filterByDbImportStatus(2); + $numTotalDisplayUploads = $recentUploadsQuery->count(); //TODO: Consider using array('min' => 200)) or something if we have multiple errors codes for failure. } - $recentUploads = $recentUploadsQuery->offset($rowStart)->limit($limit)->find(); - - $numRecentUploads = $limit; - //CcFilesQuery::create()->filterByDbUtime(array('min' => time() - 30 * 24 * 60 * 60)) - - //$this->_helper->json->sendJson(array("jsonrpc" => "2.0", "tempfilepath" => $tempFileName)); + $recentUploads = $recentUploadsQuery + ->orderByDbUtime(Criteria::DESC) + ->offset($rowStart) + ->limit($limit) + ->find(); $uploadsArray = array(); + $utcTimezone = new DateTimeZone("UTC"); + $displayTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone()); foreach ($recentUploads as $upload) { $upload = $upload->toArray(BasePeer::TYPE_FIELDNAME); //TODO: $this->sanitizeResponse($upload)); - $utcTimezone = new DateTimeZone("UTC"); - $displayTimezone = new DateTimeZone(Application_Model_Preference::GetUserTimezone()); $upload['utime'] = new DateTime($upload['utime'], $utcTimezone); $upload['utime']->setTimeZone($displayTimezone); $upload['utime'] = $upload['utime']->format('Y-m-d H:i:s'); - - //$this->_helper->json->sendJson($upload->asJson()); + //TODO: Invoke sanitization here array_push($uploadsArray, $upload); } - - $this->view->sEcho = intval($this->getRequest()->getParam('sEcho')); - $this->view->iTotalDisplayRecords = $numTotalRecentUploads; - //$this->view->iTotalDisplayRecords = $numRecentUploads; //$r["iTotalDisplayRecords"]; - $this->view->iTotalRecords = $numTotalRecentUploads; //$r["iTotalRecords"]; - $this->view->files = $uploadsArray; //$r["aaData"]; + $this->view->sEcho = intval($request->getParam('sEcho')); + $this->view->iTotalDisplayRecords = $numTotalDisplayUploads; + $this->view->iTotalRecords = $numTotalRecentUploads; + $this->view->files = $uploadsArray; } } From 4f3298b9869c63eddad7e1714978903db7bb3fda Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Wed, 23 Apr 2014 14:17:58 -0400 Subject: [PATCH 4/5] Installer fix --- install_minimal/include/airtime-initialize.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install_minimal/include/airtime-initialize.sh b/install_minimal/include/airtime-initialize.sh index 63a7c55a2..05978955f 100755 --- a/install_minimal/include/airtime-initialize.sh +++ b/install_minimal/include/airtime-initialize.sh @@ -42,7 +42,9 @@ fi chmod 600 /etc/monit/conf.d/monit-airtime-generic.cfg chmod 600 /etc/monit/conf.d/monit-airtime-liquidsoap.cfg -chmod 600 /etc/monit/conf.d/monit-airtime-media-monitor.cfg +if [ "$mediamonitor" = "t" ]; then + chmod 600 /etc/monit/conf.d/monit-airtime-media-monitor.cfg +fi chmod 600 /etc/monit/conf.d/monit-airtime-playout.cfg chmod 600 /etc/monit/conf.d/monit-airtime-liquidsoap.cfg From f2ce77fecb9f610a590dfdda38462368477e749c Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Wed, 23 Apr 2014 14:20:48 -0400 Subject: [PATCH 5/5] Remove python-magic --- .../airtime_analyzer/airtime_analyzer/metadata_analyzer.py | 6 +----- python_apps/airtime_analyzer/setup.py | 1 - 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/python_apps/airtime_analyzer/airtime_analyzer/metadata_analyzer.py b/python_apps/airtime_analyzer/airtime_analyzer/metadata_analyzer.py index 4e4139be0..e6794fbc9 100644 --- a/python_apps/airtime_analyzer/airtime_analyzer/metadata_analyzer.py +++ b/python_apps/airtime_analyzer/airtime_analyzer/metadata_analyzer.py @@ -1,7 +1,6 @@ import time import datetime import mutagen -import magic # For MIME type detection from analyzer import Analyzer class MetadataAnalyzer(Analyzer): @@ -45,12 +44,9 @@ class MetadataAnalyzer(Analyzer): # Other fields for Airtime metadata["cueout"] = metadata["length"] - #Use the python-magic module to get the MIME type. + #Use the mutagen to get the MIME type. if audio_file.mime: metadata["mime"] = audio_file.mime[0] - else: - mime_magic = magic.Magic(mime=True) - metadata["mime"] = mime_magic.from_file(filename) #Try to get the number of channels if mutagen can... try: diff --git a/python_apps/airtime_analyzer/setup.py b/python_apps/airtime_analyzer/setup.py index 82c64d84c..a0dba0cfc 100644 --- a/python_apps/airtime_analyzer/setup.py +++ b/python_apps/airtime_analyzer/setup.py @@ -22,7 +22,6 @@ setup(name='airtime_analyzer', scripts=['bin/airtime_analyzer'], install_requires=[ 'mutagen', - 'python-magic', 'pika', 'nose', 'coverage',