Merge branch '2.0.x' of dev.sourcefabric.org:airtime into 2.0.x
This commit is contained in:
commit
192c30bacc
5 changed files with 166 additions and 32 deletions
|
@ -15,4 +15,25 @@
|
||||||
*/
|
*/
|
||||||
class CcShowInstances extends BaseCcShowInstances {
|
class CcShowInstances extends BaseCcShowInstances {
|
||||||
|
|
||||||
|
public function computeDbTimeFilled(PropelPDO $con)
|
||||||
|
{
|
||||||
|
$stmt = $con->prepare('SELECT SUM(clip_length) FROM "cc_schedule" WHERE cc_schedule.INSTANCE_ID = :p1');
|
||||||
|
$stmt->bindValue(':p1', $this->getDbId());
|
||||||
|
$stmt->execute();
|
||||||
|
$result = $stmt->fetchColumn();
|
||||||
|
|
||||||
|
//$result is in the form H:i:s.u
|
||||||
|
//patch fix for the current problem of > 23:59:59.99 for a show content
|
||||||
|
//which causes problems with a time without timezone column type
|
||||||
|
|
||||||
|
try {
|
||||||
|
$dt = new DateTime($result);
|
||||||
|
}
|
||||||
|
catch(Exception $e) {
|
||||||
|
$result = "23:59:59";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
} // CcShowInstances
|
} // CcShowInstances
|
||||||
|
|
|
@ -234,4 +234,16 @@ class UpgradeCommon{
|
||||||
}
|
}
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function queryDb($p_sql){
|
||||||
|
global $CC_DBC;
|
||||||
|
|
||||||
|
$result = $CC_DBC->query($p_sql);
|
||||||
|
if (PEAR::isError($result)) {
|
||||||
|
echo "Error executing $sql. Exiting.";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,10 @@ class AirtimeDatabaseUpgrade{
|
||||||
public static function start(){
|
public static function start(){
|
||||||
self::doDbMigration();
|
self::doDbMigration();
|
||||||
|
|
||||||
self::SetDefaultTimezone();
|
|
||||||
self::setPhpDefaultTimeZoneToSystemTimezone();
|
self::setPhpDefaultTimeZoneToSystemTimezone();
|
||||||
|
self::SetDefaultTimezone();
|
||||||
|
|
||||||
|
echo "* Converting database to store all schedule times in UTC. This may take a a while...".PHP_EOL;
|
||||||
self::convert_cc_playlist();
|
self::convert_cc_playlist();
|
||||||
self::convert_cc_schedule();
|
self::convert_cc_schedule();
|
||||||
self::convert_cc_show_days();
|
self::convert_cc_show_days();
|
||||||
|
@ -69,7 +71,29 @@ class AirtimeDatabaseUpgrade{
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function convert_cc_playlist(){
|
private static function convert_cc_playlist(){
|
||||||
/* cc_playlist has a field that keeps track of when the playlist was last modified. */
|
echo " * Converting playlists to UTC".PHP_EOL;
|
||||||
|
|
||||||
|
$sql = "SELECT * FROM cc_playlist";
|
||||||
|
$result = UpgradeCommon::queryDb($sql);
|
||||||
|
|
||||||
|
while ($result->fetchInto($row, DB_FETCHMODE_ASSOC)){
|
||||||
|
$dt = new DateTime($row['mtime'], new DateTimeZone(date_default_timezone_get()));
|
||||||
|
$dt->setTimezone(new DateTimeZone("UTC"));
|
||||||
|
|
||||||
|
$id = $row['id'];
|
||||||
|
$mtime = $dt->format("Y-m-d H:i:s");
|
||||||
|
|
||||||
|
$sql = "UPDATE cc_playlist SET mtime = '$mtime' WHERE id = $id";
|
||||||
|
UpgradeCommon::queryDb($sql);
|
||||||
|
//echo ".";
|
||||||
|
//flush();
|
||||||
|
//usleep(100000);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
echo " * Converting playlists to UTC".PHP_EOL;
|
||||||
|
// cc_playlist has a field that keeps track of when the playlist was last modified.
|
||||||
$playlists = CcPlaylistQuery::create()->find();
|
$playlists = CcPlaylistQuery::create()->find();
|
||||||
|
|
||||||
foreach ($playlists as $pl){
|
foreach ($playlists as $pl){
|
||||||
|
@ -78,11 +102,39 @@ class AirtimeDatabaseUpgrade{
|
||||||
$pl->setDbMtime($dt);
|
$pl->setDbMtime($dt);
|
||||||
|
|
||||||
$pl->save();
|
$pl->save();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function convert_cc_schedule(){
|
private static function convert_cc_schedule(){
|
||||||
/* cc_schedule has start and end fields that need to be changed to UTC. */
|
|
||||||
|
echo " * Converting schedule to UTC".PHP_EOL;
|
||||||
|
|
||||||
|
$sql = "SELECT * FROM cc_schedule";
|
||||||
|
$result = UpgradeCommon::queryDb($sql);
|
||||||
|
|
||||||
|
while ($result->fetchInto($row, DB_FETCHMODE_ASSOC)){
|
||||||
|
$dtStarts = new DateTime($row['starts'], new DateTimeZone(date_default_timezone_get()));
|
||||||
|
$dtStarts->setTimezone(new DateTimeZone("UTC"));
|
||||||
|
|
||||||
|
$dtEnds = new DateTime($row['ends'], new DateTimeZone(date_default_timezone_get()));
|
||||||
|
$dtEnds->setTimezone(new DateTimeZone("UTC"));
|
||||||
|
|
||||||
|
$id = $row['id'];
|
||||||
|
$starts = $dtStarts->format("Y-m-d H:i:s");
|
||||||
|
$ends = $dtEnds->format("Y-m-d H:i:s");
|
||||||
|
|
||||||
|
$sql = "UPDATE cc_schedule SET starts = '$starts', ends = '$ends' WHERE id = $id";
|
||||||
|
UpgradeCommon::queryDb($sql);
|
||||||
|
//echo ".";
|
||||||
|
//flush();
|
||||||
|
//usleep(100000);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
|
||||||
|
echo " * Converting schedule to UTC".PHP_EOL;
|
||||||
|
//cc_schedule has start and end fields that need to be changed to UTC.
|
||||||
$schedules = CcScheduleQuery::create()->find();
|
$schedules = CcScheduleQuery::create()->find();
|
||||||
|
|
||||||
foreach ($schedules as $s){
|
foreach ($schedules as $s){
|
||||||
|
@ -95,35 +147,69 @@ class AirtimeDatabaseUpgrade{
|
||||||
$s->setDbEnds($dt);
|
$s->setDbEnds($dt);
|
||||||
|
|
||||||
$s->save();
|
$s->save();
|
||||||
|
echo ".";
|
||||||
}
|
}
|
||||||
|
* */
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function convert_cc_show_days(){
|
private static function convert_cc_show_days(){
|
||||||
/* cc_show_days has first_show, last_show and start_time fields that need to be changed to UTC. */
|
|
||||||
|
echo " * Converting show days to UTC".PHP_EOL;
|
||||||
|
|
||||||
|
$sql = "SELECT * FROM cc_show_days";
|
||||||
|
$result = UpgradeCommon::queryDb($sql);
|
||||||
|
|
||||||
|
while ($result->fetchInto($row, DB_FETCHMODE_ASSOC)){
|
||||||
|
|
||||||
|
$id = $row['id'];
|
||||||
|
$timezone = date_default_timezone_get();
|
||||||
|
|
||||||
|
$sql = "UPDATE cc_show_days SET timezone = '$timezone' WHERE id = $id";
|
||||||
|
UpgradeCommon::queryDb($sql);
|
||||||
|
//echo ".";
|
||||||
|
//flush();
|
||||||
|
//usleep(100000);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// cc_show_days has first_show, last_show and start_time fields that need to be changed to UTC.
|
||||||
$showDays = CcShowDaysQuery::create()->find();
|
$showDays = CcShowDaysQuery::create()->find();
|
||||||
|
|
||||||
foreach ($showDays as $sd){
|
foreach ($showDays as $sd){
|
||||||
/*
|
|
||||||
$dt = new DateTime($sd->getDbFirstShow()." ".$sd->getDbStartTime(), new DateTimeZone(date_default_timezone_get()));
|
|
||||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
|
||||||
$sd->setDbFirstShow($dt->format("Y-m-d"));
|
|
||||||
$sd->setDbStartTime($dt->format("H:i:s"));
|
|
||||||
|
|
||||||
$dt = new DateTime($sd->getDbLastShow()." ".$sd->getDbStartTime(), new DateTimeZone(date_default_timezone_get()));
|
|
||||||
$dt->setTimezone(new DateTimeZone("UTC"));
|
|
||||||
$sd->setDbLastShow($dt->format("Y-m-d"));
|
|
||||||
|
|
||||||
$sd->save();
|
|
||||||
* */
|
|
||||||
|
|
||||||
$sd->setDbTimezone(date_default_timezone_get())->save();
|
$sd->setDbTimezone(date_default_timezone_get())->save();
|
||||||
|
|
||||||
|
echo ".";
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function convert_cc_show_instances(){
|
private static function convert_cc_show_instances(){
|
||||||
/* convert_cc_show_instances has starts and ends fields that need to be changed to UTC. */
|
echo " * Converting show instances to UTC".PHP_EOL;
|
||||||
|
|
||||||
|
// convert_cc_show_instances has starts and ends fields that need to be changed to UTC.
|
||||||
|
|
||||||
|
$sql = "SELECT * FROM cc_show_instances";
|
||||||
|
$result = UpgradeCommon::queryDb($sql);
|
||||||
|
|
||||||
|
while ($result->fetchInto($row, DB_FETCHMODE_ASSOC)){
|
||||||
|
$dtStarts = new DateTime($row['starts'], new DateTimeZone(date_default_timezone_get()));
|
||||||
|
$dtStarts->setTimezone(new DateTimeZone("UTC"));
|
||||||
|
|
||||||
|
$dtEnds = new DateTime($row['ends'], new DateTimeZone(date_default_timezone_get()));
|
||||||
|
$dtEnds->setTimezone(new DateTimeZone("UTC"));
|
||||||
|
|
||||||
|
$id = $row['id'];
|
||||||
|
$starts = $dtStarts->format("Y-m-d H:i:s");
|
||||||
|
$ends = $dtEnds->format("Y-m-d H:i:s");
|
||||||
|
|
||||||
|
$sql = "UPDATE cc_show_instances SET starts = '$starts', ends = '$ends' WHERE id = $id";
|
||||||
|
UpgradeCommon::queryDb($sql);
|
||||||
|
//echo ".";
|
||||||
|
//flush();
|
||||||
|
//usleep(100000);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
$showInstances = CcShowInstancesQuery::create()->find();
|
$showInstances = CcShowInstancesQuery::create()->find();
|
||||||
|
|
||||||
foreach ($showInstances as $si){
|
foreach ($showInstances as $si){
|
||||||
|
@ -136,7 +222,10 @@ class AirtimeDatabaseUpgrade{
|
||||||
$si->setDbEnds($dt);
|
$si->setDbEnds($dt);
|
||||||
|
|
||||||
$si->save();
|
$si->save();
|
||||||
|
|
||||||
|
echo ".";
|
||||||
}
|
}
|
||||||
|
* */
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function doDbMigration(){
|
private static function doDbMigration(){
|
||||||
|
@ -356,9 +445,17 @@ class AirtimeMiscUpgrade{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo "Pausing Pypo".PHP_EOL;
|
||||||
|
exec("/etc/init.d/airtime-playout stop");
|
||||||
|
|
||||||
|
while (@ob_end_flush());
|
||||||
|
|
||||||
UpgradeCommon::connectToDatabase();
|
UpgradeCommon::connectToDatabase();
|
||||||
|
|
||||||
AirtimeDatabaseUpgrade::start();
|
AirtimeDatabaseUpgrade::start();
|
||||||
AirtimeStorWatchedDirsUpgrade::start();
|
AirtimeStorWatchedDirsUpgrade::start();
|
||||||
AirtimeConfigFileUpgrade::start();
|
AirtimeConfigFileUpgrade::start();
|
||||||
AirtimeMiscUpgrade::start();
|
AirtimeMiscUpgrade::start();
|
||||||
|
|
||||||
|
//echo "Resuming Pypo".PHP_EOL;
|
||||||
|
//exec("/etc/init.d/airtime-playout start");
|
||||||
|
|
|
@ -106,13 +106,13 @@ try:
|
||||||
print "* Waiting for pypo processes to start..."
|
print "* Waiting for pypo processes to start..."
|
||||||
if os.environ["liquidsoap_keep_alive"] == "f":
|
if os.environ["liquidsoap_keep_alive"] == "f":
|
||||||
print " * Restarting any previous Liquidsoap instances"
|
print " * Restarting any previous Liquidsoap instances"
|
||||||
p = Popen("/etc/init.d/airtime-playout stop", shell=True)
|
p = Popen("/etc/init.d/airtime-playout stop > /dev/null 2>&1", shell=True)
|
||||||
sts = os.waitpid(p.pid, 0)[1]
|
sts = os.waitpid(p.pid, 0)[1]
|
||||||
else:
|
else:
|
||||||
print " * Keeping any previous Liquidsoap instances running"
|
print " * Keeping any previous Liquidsoap instances running"
|
||||||
p = Popen("/etc/init.d/airtime-playout pypo-stop", shell=True)
|
p = Popen("/etc/init.d/airtime-playout pypo-stop > /dev/null 2>&1", shell=True)
|
||||||
sts = os.waitpid(p.pid, 0)[1]
|
sts = os.waitpid(p.pid, 0)[1]
|
||||||
p = Popen("/etc/init.d/airtime-playout start-no-monit", shell=True)
|
p = Popen("/etc/init.d/airtime-playout start-no-monit > /dev/null 2>&1", shell=True)
|
||||||
sts = os.waitpid(p.pid, 0)[1]
|
sts = os.waitpid(p.pid, 0)[1]
|
||||||
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
The purpose of this script is to consolidate into one location where
|
The purpose of this script is to consolidate into one location where
|
||||||
we need to update database host, dbname, username and password.
|
we need to update database host, dbname, username and password.
|
||||||
|
|
||||||
This script reads from airtime.conf.
|
This script reads from /etc/airtime/airtime.conf.
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -14,9 +14,11 @@ if os.geteuid() != 0:
|
||||||
print "Please run this as root."
|
print "Please run this as root."
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
airtime_conf = '/etc/airtime/airtime.conf'
|
||||||
|
|
||||||
#Read the universal values
|
#Read the universal values
|
||||||
parser = ConfigParser.SafeConfigParser()
|
parser = ConfigParser.SafeConfigParser()
|
||||||
parser.read('/etc/airtime/airtime.conf')
|
parser.read(airtime_conf)
|
||||||
|
|
||||||
host = 'resources.db.params.host'
|
host = 'resources.db.params.host'
|
||||||
dbname = 'resources.db.params.dbname'
|
dbname = 'resources.db.params.dbname'
|
||||||
|
@ -24,7 +26,11 @@ username = 'resources.db.params.username'
|
||||||
password = 'resources.db.params.password'
|
password = 'resources.db.params.password'
|
||||||
|
|
||||||
airtime_dir = parser.get('general', 'airtime_dir')
|
airtime_dir = parser.get('general', 'airtime_dir')
|
||||||
print 'Airtime root folder found at %s' % airtime_dir
|
if os.path.exists(airtime_dir):
|
||||||
|
print 'Airtime root folder found at %s' % airtime_dir
|
||||||
|
else:
|
||||||
|
print 'Could not find Airtime root folder specified by "airtime_dir" in %s' % airtime_conf
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
print ("Updating %s/application/configs/application.ini" % airtime_dir)
|
print ("Updating %s/application/configs/application.ini" % airtime_dir)
|
||||||
f = file('%s/application/configs/application.ini' % airtime_dir,'r')
|
f = file('%s/application/configs/application.ini' % airtime_dir,'r')
|
||||||
|
@ -47,7 +53,7 @@ f.writelines(file_lines)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
print ("Updating %s/build.properties" % airtime_dir)
|
print ("Updating %s/build/build.properties" % airtime_dir)
|
||||||
|
|
||||||
f = file('%s/build/build.properties' % airtime_dir, 'r')
|
f = file('%s/build/build.properties' % airtime_dir, 'r')
|
||||||
file_lines = []
|
file_lines = []
|
||||||
|
@ -66,7 +72,7 @@ f = file('%s/build/build.properties' % airtime_dir, 'w')
|
||||||
f.writelines(file_lines)
|
f.writelines(file_lines)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
print ("Updating %s/runtime-conf.xml" % airtime_dir)
|
print ("Updating %s/build/runtime-conf.xml" % airtime_dir)
|
||||||
|
|
||||||
doc = xml.dom.minidom.parse('%s/build/runtime-conf.xml' % airtime_dir)
|
doc = xml.dom.minidom.parse('%s/build/runtime-conf.xml' % airtime_dir)
|
||||||
|
|
||||||
|
@ -78,6 +84,4 @@ xml_file = open('%s/build/runtime-conf.xml' % airtime_dir, "w")
|
||||||
xml_file.writelines(doc.toxml('utf-8'))
|
xml_file.writelines(doc.toxml('utf-8'))
|
||||||
xml_file.close()
|
xml_file.close()
|
||||||
|
|
||||||
print 'Regenerating propel-config.php'
|
print "Success!"
|
||||||
os.system('cd %s/build && %s/library/propel/generator/bin/propel-gen' % (airtime_dir, airtime_dir))
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue