cc-2263: unable to cancel recording show.
-almost final check-in. Everything looks good right now...
This commit is contained in:
parent
167a55591b
commit
a48f467de7
|
@ -263,6 +263,14 @@ class ApiController extends Zend_Controller_Action
|
||||||
$end_timestamp = $now->add(new DateInterval("PT2H"));
|
$end_timestamp = $now->add(new DateInterval("PT2H"));
|
||||||
$end_timestamp = $end_timestamp->format("Y-m-d H:i:s");
|
$end_timestamp = $end_timestamp->format("Y-m-d H:i:s");
|
||||||
$this->view->shows = Show::getShows($today_timestamp, $end_timestamp, $excludeInstance=NULL, $onlyRecord=TRUE);
|
$this->view->shows = Show::getShows($today_timestamp, $end_timestamp, $excludeInstance=NULL, $onlyRecord=TRUE);
|
||||||
|
|
||||||
|
|
||||||
|
$this->view->is_recording = false;
|
||||||
|
|
||||||
|
$rows = Show_DAL::GetCurrentShow($today_timestamp);
|
||||||
|
if (count($rows) > 0){
|
||||||
|
$this->view->is_recording = ($rows[0]['record'] == 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function uploadRecordedAction()
|
public function uploadRecordedAction()
|
||||||
|
|
|
@ -238,7 +238,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
|
|
||||||
if (strtotime($show->getShowStart()) <= strtotime($today_timestamp) &&
|
if (strtotime($show->getShowStart()) <= strtotime($today_timestamp) &&
|
||||||
strtotime($today_timestamp) < strtotime($show->getShowEnd()) &&
|
strtotime($today_timestamp) < strtotime($show->getShowEnd()) &&
|
||||||
$user->isAdmin() && !$show->isRecorded()) {
|
$user->isAdmin()) {
|
||||||
$menu[] = array('action' => array('type' => 'fn',
|
$menu[] = array('action' => array('type' => 'fn',
|
||||||
'callback' => "window['confirmCancelShow']($id)"),
|
'callback' => "window['confirmCancelShow']($id)"),
|
||||||
'title' => 'Cancel Current Show');
|
'title' => 'Cancel Current Show');
|
||||||
|
|
|
@ -14,12 +14,12 @@ from poster.encode import multipart_encode
|
||||||
from poster.streaminghttp import register_openers
|
from poster.streaminghttp import register_openers
|
||||||
import urllib2
|
import urllib2
|
||||||
|
|
||||||
from subprocess import call
|
from subprocess import Popen
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
# For RabbitMQ
|
# For RabbitMQ - to be implemented in the future
|
||||||
from kombu.connection import BrokerConnection
|
#from kombu.connection import BrokerConnection
|
||||||
from kombu.messaging import Exchange, Queue, Consumer, Producer
|
#from kombu.messaging import Exchange, Queue, Consumer, Producer
|
||||||
|
|
||||||
from api_clients import api_client
|
from api_clients import api_client
|
||||||
|
|
||||||
|
@ -56,9 +56,9 @@ class ShowRecorder(Thread):
|
||||||
self.filetype = filetype
|
self.filetype = filetype
|
||||||
self.show_instance = show_instance
|
self.show_instance = show_instance
|
||||||
self.logger = logging.getLogger('root')
|
self.logger = logging.getLogger('root')
|
||||||
|
self.p = None
|
||||||
|
|
||||||
def record_show(self):
|
def record_show(self):
|
||||||
|
|
||||||
length = str(self.filelength)+".0"
|
length = str(self.filelength)+".0"
|
||||||
filename = self.show_name+" "+self.start_time
|
filename = self.show_name+" "+self.start_time
|
||||||
filename = filename.replace(" ", "-")
|
filename = filename.replace(" ", "-")
|
||||||
|
@ -71,12 +71,27 @@ class ShowRecorder(Thread):
|
||||||
self.logger.info("starting record")
|
self.logger.info("starting record")
|
||||||
self.logger.info("command " + command)
|
self.logger.info("command " + command)
|
||||||
|
|
||||||
#Run command with arguments. Wait for command to complete, then return the returncode attribute.
|
self.p = Popen(args)
|
||||||
code = call(args)
|
|
||||||
self.logger.info("finishing record, return code %s", code)
|
|
||||||
|
|
||||||
|
#blocks at the following lines until the child process
|
||||||
|
#quits
|
||||||
|
code = self.p.wait()
|
||||||
|
self.p = None
|
||||||
|
|
||||||
|
self.logger.info("finishing record, return code %s", code)
|
||||||
return code, filepath
|
return code, filepath
|
||||||
|
|
||||||
|
def cancel_recording(self):
|
||||||
|
#send signal interrupt (2)
|
||||||
|
self.logger.info("Show manually cancelled!")
|
||||||
|
if (self.p is not None):
|
||||||
|
self.p.terminate()
|
||||||
|
self.p = None
|
||||||
|
|
||||||
|
#if self.p is defined, then the child process ecasound is recording
|
||||||
|
def is_recording(self):
|
||||||
|
return (self.p is not None)
|
||||||
|
|
||||||
def upload_file(self, filepath):
|
def upload_file(self, filepath):
|
||||||
|
|
||||||
filename = os.path.split(filepath)[1]
|
filename = os.path.split(filepath)[1]
|
||||||
|
@ -105,6 +120,7 @@ class Record():
|
||||||
self.api_client = api_client.api_client_factory(config)
|
self.api_client = api_client.api_client_factory(config)
|
||||||
self.shows_to_record = {}
|
self.shows_to_record = {}
|
||||||
self.logger = logging.getLogger('root')
|
self.logger = logging.getLogger('root')
|
||||||
|
self.sr = None
|
||||||
|
|
||||||
def process_shows(self, shows):
|
def process_shows(self, shows):
|
||||||
|
|
||||||
|
@ -117,7 +133,6 @@ class Record():
|
||||||
|
|
||||||
self.shows_to_record[show[u'starts']] = [time_delta, show[u'instance_id'], show[u'name']]
|
self.shows_to_record[show[u'starts']] = [time_delta, show[u'instance_id'], show[u'name']]
|
||||||
|
|
||||||
|
|
||||||
def check_record(self):
|
def check_record(self):
|
||||||
|
|
||||||
tnow = datetime.datetime.now()
|
tnow = datetime.datetime.now()
|
||||||
|
@ -140,8 +155,8 @@ class Record():
|
||||||
show_instance = self.shows_to_record[start_time][1]
|
show_instance = self.shows_to_record[start_time][1]
|
||||||
show_name = self.shows_to_record[start_time][2]
|
show_name = self.shows_to_record[start_time][2]
|
||||||
|
|
||||||
show = ShowRecorder(show_instance, show_length.seconds, show_name, start_time, filetype="mp3")
|
self.sr = ShowRecorder(show_instance, show_length.seconds, show_name, start_time, filetype="mp3")
|
||||||
show.start()
|
self.sr.start()
|
||||||
|
|
||||||
#remove show from shows to record.
|
#remove show from shows to record.
|
||||||
del self.shows_to_record[start_time]
|
del self.shows_to_record[start_time]
|
||||||
|
@ -150,6 +165,12 @@ class Record():
|
||||||
def get_shows(self):
|
def get_shows(self):
|
||||||
|
|
||||||
shows = self.api_client.get_shows_to_record()
|
shows = self.api_client.get_shows_to_record()
|
||||||
|
|
||||||
|
if self.sr is not None:
|
||||||
|
if not shows['is_recording'] and self.sr.is_recording():
|
||||||
|
self.sr.cancel_recording()
|
||||||
|
|
||||||
|
|
||||||
if shows is not None:
|
if shows is not None:
|
||||||
shows = shows[u'shows']
|
shows = shows[u'shows']
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue