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

This commit is contained in:
Martin Konecny 2011-10-12 14:45:20 +02:00
commit 3fee646e35
12 changed files with 30 additions and 20 deletions

View File

@ -7,7 +7,7 @@ class Application_Form_AddShowRR extends Zend_Form_SubForm
{ {
// Add record element // Add record element
$this->addElement('checkbox', 'add_show_record', array( $this->addElement('checkbox', 'add_show_record', array(
'label' => 'Record?', 'label' => 'Record from Line In?',
'required' => false, 'required' => false,
)); ));

View File

@ -34,7 +34,6 @@ class Application_Form_AddUser extends Zend_Form
$firstName = new Zend_Form_Element_Text('first_name'); $firstName = new Zend_Form_Element_Text('first_name');
$firstName->setLabel('Firstname:'); $firstName->setLabel('Firstname:');
$firstName->setAttrib('class', 'input_text'); $firstName->setAttrib('class', 'input_text');
$firstName->setRequired(true);
$firstName->addFilter('StringTrim'); $firstName->addFilter('StringTrim');
$firstName->addValidator('NotEmpty'); $firstName->addValidator('NotEmpty');
$this->addElement($firstName); $this->addElement($firstName);
@ -42,7 +41,6 @@ class Application_Form_AddUser extends Zend_Form
$lastName = new Zend_Form_Element_Text('last_name'); $lastName = new Zend_Form_Element_Text('last_name');
$lastName->setLabel('Lastname:'); $lastName->setLabel('Lastname:');
$lastName->setAttrib('class', 'input_text'); $lastName->setAttrib('class', 'input_text');
$lastName->setRequired(true);
$lastName->addFilter('StringTrim'); $lastName->addFilter('StringTrim');
$lastName->addValidator('NotEmpty'); $lastName->addValidator('NotEmpty');
$this->addElement($lastName); $this->addElement($lastName);

View File

@ -11,7 +11,7 @@ class Application_Form_WatchedDirPreferences extends Zend_Form_SubForm
$this->addElement('text', 'storageFolder', array( $this->addElement('text', 'storageFolder', array(
'class' => 'input_text', 'class' => 'input_text',
'label' => 'Airtime\'s Storage Folder:', 'label' => 'Import Folder:',
'required' => false, 'required' => false,
'filters' => array('StringTrim'), 'filters' => array('StringTrim'),
'value' => '', 'value' => '',
@ -22,7 +22,7 @@ class Application_Form_WatchedDirPreferences extends Zend_Form_SubForm
$this->addElement('text', 'watchedFolder', array( $this->addElement('text', 'watchedFolder', array(
'class' => 'input_text', 'class' => 'input_text',
'label' => 'Choose a Watched Folder:', 'label' => 'Watched Folders:',
'required' => false, 'required' => false,
'filters' => array('StringTrim'), 'filters' => array('StringTrim'),
'value' => '', 'value' => '',

View File

@ -75,7 +75,7 @@ class Application_Model_RabbitMq
$channel->exchange_declare($EXCHANGE, 'direct', false, true); $channel->exchange_declare($EXCHANGE, 'direct', false, true);
$now = new DateTime("@".time()); $now = new DateTime("@".time());
$end_timestamp = new DateTime("@".time() + 3600*2); $end_timestamp = new DateTime("@".(time() + 3600*2));
$temp['event_type'] = $event_type; $temp['event_type'] = $event_type;
$temp['server_timezone'] = Application_Model_Preference::GetTimezone(); $temp['server_timezone'] = Application_Model_Preference::GetTimezone();

View File

@ -804,7 +804,7 @@ class Application_Model_Show {
$utcStartDateTime->add(new DateInterval("P".$daysAdd."D")); $utcStartDateTime->add(new DateInterval("P".$daysAdd."D"));
} }
if (is_null($endDateTime) || $utcStartDateTime->getTimestamp() <= $endDateTime->getTimestamp()) { if (is_null($endDate) || $utcStartDateTime->getTimestamp() <= $endDateTime->getTimestamp()) {
$showDay = new CcShowDays(); $showDay = new CcShowDays();
$showDay->setDbFirstShow($utcStartDateTime->format("Y-m-d")); $showDay->setDbFirstShow($utcStartDateTime->format("Y-m-d"));
$showDay->setDbLastShow($endDate); $showDay->setDbLastShow($endDate);

View File

@ -83,15 +83,15 @@ class Application_Model_StreamSetting {
$sql = "SELECT COUNT(*) FROM cc_stream_setting" $sql = "SELECT COUNT(*) FROM cc_stream_setting"
." WHERE keyname = '$keyname'"; ." WHERE keyname = '$keyname'";
$result = $CC_DBC->GetOne($sql); $result = $CC_DBC->GetOne($sql);
if ($result == 1){ if ($result == 1){
$sql = "UPDATE cc_stream_setting" $sql = "UPDATE cc_stream_setting"
." SET value = '$value'" ." SET value = '$msg'"
." WHERE keyname = '$keyname'"; ." WHERE keyname = '$keyname'";
}else{ }else{
$sql = "INSERT INTO cc_stream_setting (keyname, value, type)" $sql = "INSERT INTO cc_stream_setting (keyname, value, type)"
." VALUES ($keyname, '$msg', 'string')"; ." VALUES ('$keyname', '$msg', 'string')";
} }
$res = $CC_DBC->query($sql);
} }
public static function getLiquidsoapError($stream_id){ public static function getLiquidsoapError($stream_id){

View File

@ -16,7 +16,7 @@
</ul> </ul>
<?php endif; ?> <?php endif; ?>
</dd> </dd>
<dd class="block-display selected-item"><strong>Current Storage Folder:</strong><?php $stor = Application_Model_MusicDir::getStorDir(); echo $stor->getDirectory(); ?></dd> <dd class="block-display selected-item"><strong>Current Import Folder:</strong><?php $stor = Application_Model_MusicDir::getStorDir(); echo $stor->getDirectory(); ?></dd>
<dt id="watchedFolder-label" class="block-display"> <dt id="watchedFolder-label" class="block-display">
<label class="required" for="watchedFolder"><?php echo $this->element->getElement('watchedFolder')->getLabel() ?></label> <label class="required" for="watchedFolder"><?php echo $this->element->getElement('watchedFolder')->getLabel() ?></label>

View File

@ -48,6 +48,17 @@ function removeAddShowButton(){
span.remove(); span.remove();
} }
function pad(number, length) {
var str = '' + number;
while (str.length < length) {
str = '0' + str;
}
return str;
}
function makeTimeStamp(date){ function makeTimeStamp(date){
var sy, sm, sd, h, m, s, timestamp; var sy, sm, sd, h, m, s, timestamp;
sy = date.getFullYear(); sy = date.getFullYear();
@ -57,7 +68,7 @@ function makeTimeStamp(date){
m = date.getMinutes(); m = date.getMinutes();
s = date.getSeconds(); s = date.getSeconds();
timestamp = sy+"-"+ sm +"-"+ sd +" "+ h +":"+ m +":"+ s; timestamp = sy+"-"+ pad(sm, 2) +"-"+ pad(sd, 2) +" "+ pad(h, 2) +":"+ pad(m, 2) +":"+ pad(s, 2);
return timestamp; return timestamp;
} }

View File

@ -577,7 +577,9 @@ class AirTimeApiClient(ApiClientInterface):
url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["update_liquidsoap_error"]) url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["update_liquidsoap_error"])
url = url.replace("%%api_key%%", self.config["api_key"]) url = url.replace("%%api_key%%", self.config["api_key"])
url = url.replace("%%error_msg%%", error_msg) error_msg = error_msg.replace('/', ' ')
encoded_msg = urllib.quote(error_msg, '')
url = url.replace("%%error_msg%%", encoded_msg)
url = url.replace("%%stream_id%%", stream_id) url = url.replace("%%stream_id%%", stream_id)
logger.debug(url) logger.debug(url)
req = urllib2.Request(url) req = urllib2.Request(url)

View File

@ -39,8 +39,7 @@ end
def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, description, genre, user, s, stream) = def output_to(output_type, type, bitrate, host, port, pass, mount_point, url, description, genre, user, s, stream) =
def on_error(msg) def on_error(msg)
system("airtime-check-system > ~/temp/temp1.log 2>&1") system("/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} > ~/temp/temp.log 2>&1")
log("/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}")
5. 5.
end end

View File

@ -10,4 +10,4 @@ SCRIPT=`readlink -f $0`
# Absolute path this script is in # Absolute path this script is in
SCRIPTPATH=`dirname $SCRIPT` SCRIPTPATH=`dirname $SCRIPT`
cd ${SCRIPTPATH}/../ && python pypo-notify.py $1 $2 $3 $4 $5 $6 $7 $8 & cd ${SCRIPTPATH}/../ && python pypo-notify.py "$@"

View File

@ -47,7 +47,7 @@ parser = OptionParser(usage=usage)
# Options # Options
parser.add_option("-d", "--data", help="Pass JSON data from liquidsoap into this script.", metavar="data") parser.add_option("-d", "--data", help="Pass JSON data from liquidsoap into this script.", metavar="data")
parser.add_option("-m", "--media-id", help="ID of the file that is currently playing.", metavar="media_id") parser.add_option("-m", "--media-id", help="ID of the file that is currently playing.", metavar="media_id")
parser.add_option("-e", "--error", help="liquidsoap error msg.", metavar="error_msg") 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("-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("-c", "--connect", help="liquidsoap connected", action="store_true", metavar="connect")
@ -109,13 +109,13 @@ if __name__ == '__main__':
# initialize # initialize
logger = logging.getLogger() logger = logging.getLogger()
if options.error_msg and options.stream_id: if options.error and options.stream_id:
try: try:
n = Notify() n = Notify()
n.notify_liquidsoap_error(options.error_msg, options.stream_id) n.notify_liquidsoap_error(options.error, options.stream_id)
except Exception, e: except Exception, e:
print e print e
elif optioins.connect and options.stream_id: elif options.connect and options.stream_id:
try: try:
n = Notify() n = Notify()
n.notify_liquidsoap_connection(options.stream_id) n.notify_liquidsoap_connection(options.stream_id)