cc-2263: unable to cancel recording show

-made cancelled recorded shows still upload.
This commit is contained in:
martin 2011-05-18 14:33:11 -04:00
parent 62806fa7ef
commit 3416ba20d9
4 changed files with 57 additions and 53 deletions

View File

@ -289,6 +289,8 @@ class ApiController extends Zend_Controller_Action
$file = StoredFile::uploadFile($upload_dir); $file = StoredFile::uploadFile($upload_dir);
$show_instance = $this->_getParam('show_instance'); $show_instance = $this->_getParam('show_instance');
try {
$show_inst = new ShowInstance($show_instance); $show_inst = new ShowInstance($show_instance);
$show_inst->setRecordedFile($file->getId()); $show_inst->setRecordedFile($file->getId());
@ -322,6 +324,13 @@ class ApiController extends Zend_Controller_Action
sleep($CC_CONFIG['soundcloud-connection-wait']); sleep($CC_CONFIG['soundcloud-connection-wait']);
} }
} }
} catch (Exception $e){
//we've reached here probably because the show was
//cancelled, and therefore the show instance does not
//exist anymore (ShowInstance constructor threw this error).
//We've done all we can do (upload the file and put it in
//the library), now lets just return.
}
$this->view->id = $file->getId(); $this->view->id = $file->getId();
} }

View File

@ -1173,16 +1173,21 @@ class Show {
class ShowInstance { class ShowInstance {
private $_instanceId; private $_instanceId;
private $_showInstance;
public function __construct($instanceId) public function __construct($instanceId)
{ {
$this->_instanceId = $instanceId; $this->_instanceId = $instanceId;
$this->_showInstance = CcShowInstancesQuery::create()->findPK($instanceId);
if (is_null($this->_showInstance)){
throw new Exception();
}
} }
public function getShowId() public function getShowId()
{ {
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId); return $this->_showInstance->getDbShowId();
return $showInstance->getDbShowId();
} }
public function getShowInstanceId() public function getShowInstanceId()
@ -1192,14 +1197,12 @@ class ShowInstance {
public function isRebroadcast() public function isRebroadcast()
{ {
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId); return $this->_showInstance->getDbOriginalShow();
return $showInstance->getDbOriginalShow();
} }
public function isRecorded() public function isRecorded()
{ {
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId); return $this->_showInstance->getDbRecord();
return $showInstance->getDbRecord();
} }
public function getName() public function getName()
@ -1216,14 +1219,12 @@ class ShowInstance {
public function getShowStart() public function getShowStart()
{ {
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId); return $this->_showInstance->getDbStarts();
return $showInstance->getDbStarts();
} }
public function getShowEnd() public function getShowEnd()
{ {
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId); return $this->_showInstance->getDbEnds();
return $showInstance->getDbEnds();
} }
public function getStartDate() public function getStartDate()
@ -1243,21 +1244,18 @@ class ShowInstance {
public function setSoundCloudFileId($p_soundcloud_id) public function setSoundCloudFileId($p_soundcloud_id)
{ {
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId); $this->_showInstance->setDbSoundCloudId($p_soundcloud_id)
$showInstance->setDbSoundCloudId($p_soundcloud_id)
->save(); ->save();
} }
public function getSoundCloudFileId() public function getSoundCloudFileId()
{ {
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId); return $this->_showInstance->getDbSoundCloudId();
return $showInstance->getDbSoundCloudId();
} }
public function getRecordedFile() public function getRecordedFile()
{ {
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId); $file_id = $this->_showInstance->getDbRecordedFile();
$file_id = $showInstance->getDbRecordedFile();
if(isset($file_id)) { if(isset($file_id)) {
$file = StoredFile::Recall($file_id); $file = StoredFile::Recall($file_id);
@ -1276,16 +1274,14 @@ class ShowInstance {
public function setShowStart($start) public function setShowStart($start)
{ {
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId); $this->_showInstance->setDbStarts($start)
$showInstance->setDbStarts($start)
->save(); ->save();
RabbitMq::PushSchedule(); RabbitMq::PushSchedule();
} }
public function setShowEnd($end) public function setShowEnd($end)
{ {
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId); $this->_showInstance->setDbEnds($end)
$showInstance->setDbEnds($end)
->save(); ->save();
RabbitMq::PushSchedule(); RabbitMq::PushSchedule();
} }
@ -1293,8 +1289,7 @@ class ShowInstance {
public function updateScheduledTime() public function updateScheduledTime()
{ {
$con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME); $con = Propel::getConnection(CcShowInstancesPeer::DATABASE_NAME);
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId); $this->_showInstance->updateDbTimeFilled($con);
$showInstance->updateDbTimeFilled($con);
} }
public function correctScheduleStartTimes(){ public function correctScheduleStartTimes(){
@ -1539,8 +1534,7 @@ class ShowInstance {
public function getTimeScheduled() public function getTimeScheduled()
{ {
$showInstance = CcShowInstancesQuery::create()->findPK($this->_instanceId); $time = $this->_showInstance->getDbTimeFilled();
$time = $showInstance->getDbTimeFilled();
if(is_null($time)) { if(is_null($time)) {
$time = "00:00:00"; $time = "00:00:00";

View File

@ -188,7 +188,7 @@ class AirtimeInstall
echo "* Creating database tables".PHP_EOL; echo "* Creating database tables".PHP_EOL;
// Put Propel sql files in Database // Put Propel sql files in Database
$command = AirtimeInstall::CONF_DIR_WWW."/library/propel/generator/bin/propel-gen ".AirtimeInstall::CONF_DIR_WWW."/build/ insert-sql 2>propel-error.log"; $command = AirtimeInstall::CONF_DIR_WWW."/library/propel/generator/bin/propel-gen ".AirtimeInstall::CONF_DIR_WWW."/build/ insert-sql";
@exec($command, $output, $results); @exec($command, $output, $results);
} }

View File

@ -73,7 +73,7 @@ class ShowRecorder(Thread):
self.p = Popen(args) self.p = Popen(args)
#blocks at the following lines until the child process #blocks at the following line until the child process
#quits #quits
code = self.p.wait() code = self.p.wait()
self.p = None self.p = None
@ -109,6 +109,7 @@ class ShowRecorder(Thread):
code, filepath = self.record_show() code, filepath = self.record_show()
if code == 0: if code == 0:
self.logger.info("Preparing to upload %s" % filepath)
self.upload_file(filepath) self.upload_file(filepath)
else: else:
self.logger.info("problem recording show") self.logger.info("problem recording show")