Skip to content

Commit

Permalink
modify recording check before stb goes in deep standby
Browse files Browse the repository at this point in the history
  • Loading branch information
iPkay committed Jan 26, 2016
1 parent c51f3e0 commit 979de8d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 48 deletions.
23 changes: 23 additions & 0 deletions Navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,29 @@ def getRecordingsTypesOnly(self, type=pNavigation.isAnyRecording):
def getRecordingsServicesAndTypes(self, type=pNavigation.isAnyRecording):
return self.pnav and self.pnav.getRecordingsServicesAndTypes(type)

def getRecordingsCheckBeforeActivateDeepStandby(self, modifyTimer = True):
import Components.RecordingConfig
rec = False
next_rec_time = 0
recordings = self.getRecordings(False,Components.RecordingConfig.recType(config.recording.warn_box_restart_rec_types.getValue()))
if not recordings:
next_rec_time = self.RecordTimer.getNextRecordingTime()
if recordings or (next_rec_time > 0 and (next_rec_time - time()) <= 900) or self.RecordTimer.isRecording():
if not self.RecordTimer.isRecTimerWakeup():# if not timer wake up - enable trigger file for automatical shutdown after recording
f = open("/tmp/was_rectimer_wakeup", "w")
f.write('1')
f.close()
lastrecordEnd = 0
for timer in self.RecordTimer.timer_list:
if modifyTimer and (lastrecordEnd == 0 or lastrecordEnd >= timer.begin):
if timer.afterEvent < 2:
timer.afterEvent = 2
print "Set after-event for recording %s to DEEP-STANDBY." % timer.name
if timer.end > lastrecordEnd:
lastrecordEnd = timer.end + 900
rec = True
return rec

def getCurrentService(self):
if not self.currentlyPlayingService:
self.currentlyPlayingService = self.pnav and self.pnav.getCurrentService()
Expand Down
22 changes: 4 additions & 18 deletions data/menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,9 @@ self.session.openWithCallback(msgClosed, FactoryReset)
<code>
from Screens.Standby import TryQuitMainloop
from Screens.MessageBox import MessageBox
recordings = self.session.nav.getRecordings()
recordings = self.session.nav.getRecordingsCheckBeforeActivateDeepStandby()
if recordings:
lastrecordEnd = 0
for timer in self.session.nav.RecordTimer.timer_list:
if lastrecordEnd == 0 or lastrecordEnd >= timer.begin:
print "Set after-event for recording %s to DEEP-STANDBY." % timer.name
timer.afterEvent = 2
if timer.end > lastrecordEnd:
lastrecordEnd = timer.end + 900
self.session.openWithCallback(self.gotoStandby,MessageBox,_("PowerOff while Recording in progress!\nEntering standby, after recording the box will shutdown."), type = MessageBox.TYPE_INFO, timeout = 10)
self.session.openWithCallback(self.gotoStandby,MessageBox,_("PowerOff while Recording in progress or next recording begins in next 15 minutes!\nEntering standby, after recording the box will shutdown."), type = MessageBox.TYPE_INFO, close_on_any_key = True, timeout = 10)
else:
self.session.open(TryQuitMainloop, 1)
</code>
Expand All @@ -244,16 +237,9 @@ else:
<code>
from Screens.Standby import TryQuitMainloop
from Screens.MessageBox import MessageBox
recordings = self.session.nav.getRecordings()
recordings = self.session.nav.getRecordingsCheckBeforeActivateDeepStandby()
if recordings:
lastrecordEnd = 0
for timer in self.session.nav.RecordTimer.timer_list:
if lastrecordEnd == 0 or lastrecordEnd >= timer.begin:
print "Set after-event for recording %s to DEEP-STANDBY." % timer.name
timer.afterEvent = 2
if timer.end > lastrecordEnd:
lastrecordEnd = timer.end + 900
self.session.openWithCallback(self.gotoStandby,MessageBox,_("PowerOff while Recording in progress!\nEntering standby, after recording the box will shutdown."), type = MessageBox.TYPE_INFO, timeout = 10)
self.session.openWithCallback(self.gotoStandby,MessageBox,_("PowerOff while Recording in progress or next recording begins in next 15 minutes!\nEntering standby, after recording the box will shutdown."), type = MessageBox.TYPE_INFO, close_on_any_key = True, timeout = 10)
else:
self.session.open(TryQuitMainloop, 45)
</code>
Expand Down
34 changes: 8 additions & 26 deletions mytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,33 +379,15 @@ def MenuClosed(self, *val):
self.session.infobar = None

def shutdown(self):
wasRecTimerWakeup = False
recordings = self.session.nav.getRecordings(False,Components.RecordingConfig.recType(config.recording.warn_box_restart_rec_types.getValue()))
if not recordings:
next_rec_time = self.session.nav.RecordTimer.getNextRecordingTime()
if recordings or (next_rec_time > 0 and (next_rec_time - time()) < 360):
if os.path.exists("/tmp/was_rectimer_wakeup") and not self.session.nav.RecordTimer.isRecTimerWakeup():
f = open("/tmp/was_rectimer_wakeup", "r")
file = f.read()
f.close()
wasRecTimerWakeup = int(file) and True or False
if self.session.nav.RecordTimer.isRecTimerWakeup() or wasRecTimerWakeup or self.session.nav.RecordTimer.isRecording():
print "PowerOff (timer wakewup) - Recording in progress or a timer about to activate, entering standby!"
lastrecordEnd = 0
for timer in self.session.nav.RecordTimer.timer_list:
if lastrecordEnd == 0 or lastrecordEnd >= timer.begin:
print "Set after-event for recording %s to DEEP-STANDBY." % timer.name
timer.afterEvent = 2
if timer.end > lastrecordEnd:
lastrecordEnd = timer.end + 900
from Screens.MessageBox import MessageBox
self.session.openWithCallback(self.gotoStandby,MessageBox,_("PowerOff while Recording in progress!\nEntering standby, after recording the box will shutdown."), type = MessageBox.TYPE_INFO, timeout = 10)
else:
print "PowerOff - Now!"
recordings = self.session.nav.getRecordingsCheckBeforeActivateDeepStandby()
if recordings:
from Screens.MessageBox import MessageBox
# print "PowerOff - Recording in progress or a timer about to activate, entering standby!"
self.session.openWithCallback(self.gotoStandby,MessageBox,_("PowerOff while Recording in progress or next recording begins in next 15 minutes!\nEntering standby, after recording the box will shutdown."), type = MessageBox.TYPE_INFO, close_on_any_key = True, timeout = 10)
else:
if not Screens.Standby.inTryQuitMainloop and self.session.current_dialog and self.session.current_dialog.ALLOW_SUSPEND:
# print "PowerOff - Now!"
self.session.open(Screens.Standby.TryQuitMainloop, 1)
elif not Screens.Standby.inTryQuitMainloop and self.session.current_dialog and self.session.current_dialog.ALLOW_SUSPEND:
print "PowerOff - Now!"
self.session.open(Screens.Standby.TryQuitMainloop, 1)

def powerlong(self):
if Screens.Standby.inTryQuitMainloop or (self.session.current_dialog and not self.session.current_dialog.ALLOW_SUSPEND):
Expand Down
7 changes: 3 additions & 4 deletions po/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -14710,12 +14710,11 @@ msgstr "Rechts vom Servicenamen"

#
msgid ""
"PowerOff while Recording in progress!\n"
"PowerOff while Recording in progress or next recording begins in next 15 minutes!\n"
"Entering standby, after recording the box will shutdown."
msgstr ""
"Es läuft noch eine Aufnahme, Receiver wird bis zum Ende der\n"
"\n"
"Aufnahme in den Stby versetzt und danach heruntergefahren."
"Es läuft noch eine Aufnahme oder eine Aufnahme beginnt in den nächsten 15 Minuten!\n"
"Der Receiver wird jetzt in den Standby versetzt und am Ende der Aufnahme(n) heruntergefahren."

# boot-up action
msgid "Boot-up action"
Expand Down

0 comments on commit 979de8d

Please sign in to comment.