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

This commit is contained in:
Yuchen Wang 2011-10-11 16:48:56 -04:00
commit 45aa38111c
8 changed files with 26 additions and 14 deletions

View File

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

View File

@ -804,7 +804,7 @@ class Application_Model_Show {
$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->setDbFirstShow($utcStartDateTime->format("Y-m-d"));
$showDay->setDbLastShow($endDate);

View File

@ -83,15 +83,15 @@ class Application_Model_StreamSetting {
$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 = '$value'"
." SET value = '$msg'"
." WHERE keyname = '$keyname'";
}else{
$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){

View File

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

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 = 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)
logger.debug(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 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} > ~/temp/temp.log 2>&1")
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}")
5.
end

View File

@ -10,4 +10,4 @@ SCRIPT=`readlink -f $0`
# Absolute path this script is in
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
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("-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("-c", "--connect", help="liquidsoap connected", action="store_true", metavar="connect")
@ -109,13 +109,13 @@ if __name__ == '__main__':
# initialize
logger = logging.getLogger()
if options.error_msg and options.stream_id:
if options.error and options.stream_id:
try:
n = Notify()
n.notify_liquidsoap_error(options.error_msg, options.stream_id)
n.notify_liquidsoap_error(options.error, options.stream_id)
except Exception, e:
print e
elif optioins.connect and options.stream_id:
elif options.connect and options.stream_id:
try:
n = Notify()
n.notify_liquidsoap_connection(options.stream_id)