Merge branch '2.5.x' of dev.sourcefabric.org:airtime into 2.5.x

This commit is contained in:
denise 2013-10-15 15:21:19 -04:00
commit f166d966f9
1 changed files with 53 additions and 34 deletions

View File

@ -69,7 +69,7 @@ class ShowRecorder(Thread):
self.p = None
def record_show(self):
length = str(self.filelength) + ".0"
length = str(self.filelength)
filename = self.start_time
filename = filename.replace(" ", "-")
@ -104,7 +104,7 @@ class ShowRecorder(Thread):
for msg in outmsgs:
m = re.search('^ERROR',msg)
if not m == None:
self.logger.info('Recording error is found: %s', msg)
self.logger.info('Recording error is found: %s', outmsgs)
self.logger.info("finishing record, return code %s", self.p.returncode)
code = self.p.returncode
@ -113,12 +113,6 @@ class ShowRecorder(Thread):
return code, filepath
def cancel_recording(self):
#add 3 second delay before actually cancelling the show. The reason
#for this is because it appears that ecasound starts 1 second later than
#it should, and therefore this method is sometimes incorrectly called 1
#second before the show ends.
#time.sleep(3)
#send signal interrupt (2)
self.logger.info("Show manually cancelled!")
if (self.p is not None):
@ -213,8 +207,8 @@ class Recorder(Thread):
command = msg["event_type"]
self.logger.info("Received msg from Pypo Message Handler: %s", msg)
if command == 'cancel_recording':
if self.sr is not None and self.sr.is_recording():
self.sr.cancel_recording()
if self.currently_recording():
self.cancel_recording()
else:
self.process_recorder_schedule(msg)
self.loops = 0
@ -253,6 +247,16 @@ class Recorder(Thread):
self.logger.debug("Now %s", tnow)
return out
def cancel_recording(self):
self.sr.cancel_recording()
self.sr = None
def currently_recording(self):
if self.sr is not None and self.sr.is_recording():
return True
else:
return False
def start_record(self):
if len(self.shows_to_record) == 0: return None
try:
@ -274,8 +278,23 @@ class Recorder(Thread):
start_time_formatted = '%(year)d-%(month)02d-%(day)02d %(hour)02d:%(min)02d:%(sec)02d' % \
{'year': start_time_on_server.year, 'month': start_time_on_server.month, 'day': start_time_on_server.day, \
'hour': start_time_on_server.hour, 'min': start_time_on_server.minute, 'sec': start_time_on_server.second}
self.sr = ShowRecorder(show_instance, show_name, show_length.seconds, start_time_formatted)
seconds_waiting = 0
#avoiding CC-5299
while(True):
if self.currently_recording():
self.logger.info("Previous record not finished, sleeping 100ms")
seconds_waiting = seconds_waiting + 0.1
time.sleep(0.1)
else:
show_length_seconds = show_length.seconds - seconds_waiting
self.sr = ShowRecorder(show_instance, show_name, show_length_seconds, start_time_formatted)
self.sr.start()
break
#remove show from shows to record.
del self.shows_to_record[start_time]
#self.time_till_next_show = self.get_time_till_next_show()