Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
Yuchen Wang 2011-11-09 15:36:09 -05:00
commit 38719b1a4e
4 changed files with 86 additions and 13 deletions

View File

@ -310,13 +310,9 @@ class ScheduleController extends Zend_Controller_Action
return; return;
} }
$start = explode(" ", $start_timestamp); $dateInfo_s = getDate(strtotime(Application_Model_DateHelper::ConvertToLocalDateTimeString($start_timestamp)));
$end = explode(" ", $end_timestamp); $dateInfo_e = getDate(strtotime(Application_Model_DateHelper::ConvertToLocalDateTimeString($end_timestamp)));
$startTime = explode(":", $start[1]);
$endTime = explode(":", $end[1]);
$dateInfo_s = getDate(strtotime($start_timestamp));
$dateInfo_e = getDate(strtotime($end_timestamp));
$this->view->showContent = $show->getShowContent(); $this->view->showContent = $show->getShowContent();
$this->view->timeFilled = $show->getTimeScheduled(); $this->view->timeFilled = $show->getTimeScheduled();
$this->view->showName = $show->getName(); $this->view->showName = $show->getName();
@ -329,8 +325,8 @@ class ScheduleController extends Zend_Controller_Action
$this->view->e_wday = $dateInfo_e['weekday']; $this->view->e_wday = $dateInfo_e['weekday'];
$this->view->e_month = $dateInfo_e['month']; $this->view->e_month = $dateInfo_e['month'];
$this->view->e_day = $dateInfo_e['mday']; $this->view->e_day = $dateInfo_e['mday'];
$this->view->startTime = sprintf("%d:%02d", $startTime[0], $startTime[1]); $this->view->startTime = sprintf("%02d:%02d", $dateInfo_s['hours'], $dateInfo_s['minutes']);
$this->view->endTime = sprintf("%d:%02d", $endTime[0], $endTime[1]); $this->view->endTime = sprintf("%02d:%02d", $dateInfo_e['hours'], $dateInfo_e['minutes']);
$this->view->chosen = $this->view->render('schedule/scheduled-content.phtml'); $this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
$this->view->dialog = $this->view->render('schedule/schedule-show-dialog.phtml'); $this->view->dialog = $this->view->render('schedule/schedule-show-dialog.phtml');

View File

@ -7,7 +7,7 @@ class Application_Model_Preference
global $CC_CONFIG, $CC_DBC; global $CC_CONFIG, $CC_DBC;
//called from a daemon process //called from a daemon process
if(!Zend_Auth::getInstance()->hasIdentity()) { if(!class_exists("Zend_Auth", false) || !Zend_Auth::getInstance()->hasIdentity()) {
$id = NULL; $id = NULL;
} }
else { else {
@ -369,11 +369,16 @@ class Application_Model_Preference
$outputArray['NUM_OF_SCHEDULED_PLAYLISTS'] = Application_Model_Schedule::getSchduledPlaylistCount(); $outputArray['NUM_OF_SCHEDULED_PLAYLISTS'] = Application_Model_Schedule::getSchduledPlaylistCount();
$outputArray['NUM_OF_PAST_SHOWS'] = Application_Model_ShowInstance::GetShowInstanceCount(date("Y-m-d H:i:s")); $outputArray['NUM_OF_PAST_SHOWS'] = Application_Model_ShowInstance::GetShowInstanceCount(date("Y-m-d H:i:s"));
$outputArray['UNIQUE_ID'] = self::GetUniqueId(); $outputArray['UNIQUE_ID'] = self::GetUniqueId();
$outputArray['SAAS'] = self::GetPlanLevel();
$outputArray['INSTALL_METHOD'] = self::GetInstallMethod();
$outputArray = array_merge($systemInfoArray, $outputArray); $outputArray = array_merge($systemInfoArray, $outputArray);
$outputString = "\n"; $outputString = "\n";
foreach($outputArray as $key => $out){ foreach($outputArray as $key => $out){
if($key == 'SAAS' && ($out != '' || $out != 'disabled')){
continue;
}
if($out != ''){ if($out != ''){
$outputString .= $key.' : '.$out."\n"; $outputString .= $key.' : '.$out."\n";
} }
@ -386,6 +391,20 @@ class Application_Model_Preference
return $outputString; return $outputString;
} }
} }
public static function GetInstallMethod(){
$easy_install = file_exists('/usr/bin/airtime-easy-install');
$debian_install = file_exists('/var/lib/dpkg/info/airtime.config');
if($debian_install){
if($easy_install){
return "easy_install";
}else{
return "debian_install";
}
}else{
return "manual_install";
}
}
public static function SetRemindMeDate($now){ public static function SetRemindMeDate($now){
$weekAfter = mktime(0, 0, 0, date("m") , date("d")+7, date("Y")); $weekAfter = mktime(0, 0, 0, date("m") , date("d")+7, date("Y"));
@ -446,7 +465,11 @@ class Application_Model_Preference
} }
public static function GetPlanLevel(){ public static function GetPlanLevel(){
return self::GetValue("plan_level"); $plan = self::GetValue("plan_level");
if(trim($plan) == ''){
$plan = 'disabled';
}
return $plan;
} }
public static function SetTrialEndingDate($date){ public static function SetTrialEndingDate($date){

View File

@ -274,7 +274,8 @@ class AirtimeProcessEvent(ProcessEvent):
# check if file exist # check if file exist
# When whole directory is copied to the organized dir, # When whole directory is copied to the organized dir,
# inotify doesn't fire IN_CLOSE_WRITE, hench we need special way of # inotify doesn't fire IN_CLOSE_WRITE, hench we need special way of
# handling those cases. # handling those cases. We are manully calling handle_created_file
# function.
if os.path.exists(k): if os.path.exists(k):
# check if file is open # check if file is open
command = "lsof "+k command = "lsof "+k

View File

@ -20,6 +20,7 @@ if (substr($sapi_type, 0, 3) == 'cli') {
class AirtimeCheck { class AirtimeCheck {
private static $AIRTIME_STATUS_OK = true; private static $AIRTIME_STATUS_OK = true;
CONST UNKNOWN = "UNKNOWN";
/** /**
* Ensures that the user is running this PHP script with root * Ensures that the user is running this PHP script with root
@ -29,11 +30,29 @@ class AirtimeCheck {
public static function ExitIfNotRoot() public static function ExitIfNotRoot()
{ {
// Need to check that we are superuser before running this. // Need to check that we are superuser before running this.
if(exec("whoami") != "root"){ $user = exec("whoami");
if($user != "root" && $user != "www-data"){
echo "Must be root user.\n"; echo "Must be root user.\n";
exit(1); exit(1);
} }
} }
public static function GetCpuInfo()
{
$command = "cat /proc/cpuinfo |grep -m 1 'model name' ";
exec($command, $output, $rv);
if ($rv != 0 || !isset($output[0]))
return self::UNKNOWN;
$choppedStr = explode(":", $output[0]);
if (!isset($choppedStr[1]))
return self::UNKNOWN;
$status = trim($choppedStr[1]);
return $status;
}
public static function GetAirtimeConf() public static function GetAirtimeConf()
{ {
@ -46,6 +65,37 @@ class AirtimeCheck {
return $ini; return $ini;
} }
public static function CheckOsTypeVersion(){
exec("lsb_release -ds", $output, $rv);
if ($rv != 0 || !isset($output[0])){
$os_string = self::UNKNOWN;
} else {
$os_string = $output[0];
}
unset($output);
// Figure out if 32 or 64 bit
exec("uname -m", $output, $rv);
if ($rv != 0 || !isset($output[0])){
$machine = self::UNKNOWN;
} else {
$machine = $output[0];
}
return $os_string." ".$machine;
}
public static function GetServerType(){
$headerInfo = get_headers("http://localhost",1);
if (!isset($headerInfo['Server'][0]))
return self::UNKNOWN;
else
return $headerInfo['Server'][0];
}
public static function GetStatus($p_apiKey){ public static function GetStatus($p_apiKey){
@ -82,6 +132,9 @@ class AirtimeCheck {
self::output_status("TOTAL_MEMORY_MBYTES", $data->platform->memory); self::output_status("TOTAL_MEMORY_MBYTES", $data->platform->memory);
self::output_status("TOTAL_SWAP_MBYTES", $data->platform->swap); self::output_status("TOTAL_SWAP_MBYTES", $data->platform->swap);
self::output_status("AIRTIME_VERSION", $data->airtime_version); self::output_status("AIRTIME_VERSION", $data->airtime_version);
self::output_status("OS", self::CheckOsTypeVersion());
self::output_status("CPU", self::GetCpuInfo());
self::output_status("WEB_SERVER", self::GetServerType());
if ($data->services->pypo){ if ($data->services->pypo){
self::output_status("PLAYOUT_ENGINE_PROCESS_ID", $data->services->pypo->process_id); self::output_status("PLAYOUT_ENGINE_PROCESS_ID", $data->services->pypo->process_id);
self::output_status("PLAYOUT_ENGINE_RUNNING_SECONDS", $data->services->pypo->uptime_seconds); self::output_status("PLAYOUT_ENGINE_RUNNING_SECONDS", $data->services->pypo->uptime_seconds);