1 from Tools import RedirectOutput
5 from Components.Language import language
8 print "language set to", language.getLanguage()
9 eServiceEvent.setEPGLanguage(language.getLanguage())
11 language.addCallback(setEPGLanguage)
14 import Screens.InfoBar
15 from Screens.SimpleSummary import SimpleSummary
20 import ServiceReference
22 from Navigation import Navigation
24 from skin import readSkin, applyAllAttributes
26 from Components.config import configfile
27 from Tools.Directories import InitFallbackFiles, resolveFilename, SCOPE_PLUGINS
29 eDVBDB.getInstance().reloadBouquets()
35 from twisted.internet import reactor
40 print "twisted not available"
44 # initialize autorun plugins and plugin menu entries
45 from Components.PluginComponent import plugins
47 from Screens.Wizard import wizardManager
48 from Screens.ImageWizard import *
49 from Screens.StartWizard import *
50 from Screens.TutorialWizard import *
51 from Tools.BoundFunction import boundFunction
52 from Plugins.Plugin import PluginDescriptor
56 def dump(dir, p = ""):
57 if isinstance(dir, dict):
58 for (entry, val) in dir.items():
59 dump(val, p + "(dict)/" + entry)
60 if hasattr(dir, "__dict__"):
61 for name, value in dir.__dict__.items():
62 if not had.has_key(str(value)):
64 dump(value, p + "/" + str(name))
66 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
68 print p + ":" + str(dir)
70 # + ":" + str(dir.__class__)
75 def create(self, screen): pass
79 class HTMLOutputDevice(OutputDevice):
80 def create(self, comp):
81 print comp.produceHTML()
83 html = HTMLOutputDevice()
85 class GUIOutputDevice(OutputDevice):
87 def create(self, comp, desktop):
88 comp.createGUIScreen(self.parent, desktop)
91 def __init__(self, desktop = None, summary_desktop = None, navigation = None):
92 self.desktop = desktop
93 self.summary_desktop = summary_desktop
95 self.delay_timer = eTimer()
96 self.delay_timer.timeout.get().append(self.processDelay)
98 self.current_dialog = None
100 self.dialog_stack = [ ]
101 self.summary_stack = [ ]
104 for p in plugins.getPlugins(PluginDescriptor.WHERE_SESSIONSTART):
105 p(reason=0, session=self)
107 def processDelay(self):
110 callback = self.current_dialog.callback
112 retval = self.current_dialog.returnValue
114 if self.current_dialog.isTmp:
115 self.current_dialog.doClose()
116 # dump(self.current_dialog)
117 del self.current_dialog
119 del self.current_dialog.callback
122 if callback is not None:
126 c = self.current_dialog
130 summary = c.createSummary() or SimpleSummary
131 self.summary = self.instantiateSummaryDialog(summary, c)
134 c.addSummary(self.summary)
137 # when execBegin opened a new dialog, don't bother showing the old one.
138 if c == self.current_dialog:
142 self.current_dialog.execEnd()
143 self.current_dialog.hide()
144 self.current_dialog.removeSummary(self.summary)
147 def create(self, screen, arguments, **kwargs):
148 # creates an instance of 'screen' (which is a class)
150 return screen(self, *arguments, **kwargs)
152 errstr = "Screen %s(%s, %s): %s" % (str(screen), str(arguments), str(kwargs), sys.exc_info()[0])
154 traceback.print_exc(file=sys.stdout)
157 def instantiateDialog(self, screen, *arguments, **kwargs):
158 return self.doInstantiateDialog(screen, arguments, kwargs, self.desktop)
160 def instantiateSummaryDialog(self, screen, *arguments, **kwargs):
161 return self.doInstantiateDialog(screen, arguments, kwargs, self.summary_desktop)
163 def doInstantiateDialog(self, screen, arguments, kwargs, desktop):
167 dlg = self.create(screen, arguments, **kwargs)
169 print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
171 traceback.print_exc(file=sys.stdout)
179 readSkin(dlg, None, dlg.skinName, desktop)
181 # create GUI view of this dialog
182 assert desktop is not None
186 for (key, value) in dlg.skinAttributes:
187 if key == "zPosition":
192 dlg.instance = eWindow(desktop, z)
194 applyAllAttributes(dlg.instance, desktop, dlg.skinAttributes)
195 gui = GUIOutputDevice()
196 gui.parent = dlg.instance
197 gui.create(dlg, desktop)
201 def pushCurrent(self):
202 if self.current_dialog:
203 self.dialog_stack.append(self.current_dialog)
206 def popCurrent(self):
207 if len(self.dialog_stack):
208 self.current_dialog = self.dialog_stack.pop()
211 self.current_dialog = None
213 def execDialog(self, dialog):
215 self.current_dialog = dialog
216 self.current_dialog.isTmp = False
217 self.current_dialog.callback = None # would cause re-entrancy problems.
220 def openWithCallback(self, callback, screen, *arguments, **kwargs):
221 dlg = self.open(screen, *arguments, **kwargs)
222 dlg.callback = callback
224 def open(self, screen, *arguments, **kwargs):
226 dlg = self.current_dialog = self.instantiateDialog(screen, *arguments, **kwargs)
232 def keyEvent(self, code):
233 print "code " + str(code)
235 def close(self, *retval):
236 self.current_dialog.returnValue = retval
237 self.delay_timer.start(0, 1)
239 def pushSummary(self):
240 if self.summary is not None:
242 self.summary_stack.append(self.summary)
245 def popSummary(self):
246 if self.summary is not None:
247 self.summary.doClose()
248 self.summary = self.summary_stack.pop()
249 if self.summary is not None:
252 from Screens.Volume import Volume
253 from Screens.Mute import Mute
254 from GlobalActions import globalActionMap
255 from Components.config import ConfigSubsection, configSequence, configElement, configsequencearg
257 #TODO .. move this to a own .py file
259 """Volume control, handles volUp, volDown, volMute actions and display
260 a corresponding dialog"""
261 def __init__(self, session):
262 global globalActionMap
263 globalActionMap.actions["volumeUp"]=self.volUp
264 globalActionMap.actions["volumeDown"]=self.volDown
265 globalActionMap.actions["volumeMute"]=self.volMute
267 config.audio = ConfigSubsection()
268 config.audio.volume = configElement("config.audio.volume", configSequence, [100], configsequencearg.get("INTEGER", (0, 100)))
270 self.volumeDialog = session.instantiateDialog(Volume)
271 self.muteDialog = session.instantiateDialog(Mute)
273 self.hideVolTimer = eTimer()
274 self.hideVolTimer.timeout.get().append(self.volHide)
276 vol = config.audio.volume.value[0]
277 self.volumeDialog.setValue(vol)
278 eDVBVolumecontrol.getInstance().setVolume(vol, vol)
281 config.audio.volume.value = eDVBVolumecontrol.getInstance().getVolume()
282 config.audio.volume.save()
285 if (eDVBVolumecontrol.getInstance().isMuted()):
287 eDVBVolumecontrol.getInstance().volumeUp()
288 self.volumeDialog.show()
289 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
291 self.hideVolTimer.start(3000, True)
294 if (eDVBVolumecontrol.getInstance().isMuted()):
296 eDVBVolumecontrol.getInstance().volumeDown()
297 self.volumeDialog.show()
298 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
300 self.hideVolTimer.start(3000, True)
303 self.volumeDialog.hide()
306 eDVBVolumecontrol.getInstance().volumeToggleMute()
307 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
309 if (eDVBVolumecontrol.getInstance().isMuted()):
310 self.muteDialog.show()
312 self.muteDialog.hide()
314 from Screens.Standby import Standby
317 """ PowerKey stuff - handles the powerkey press and powerkey release actions"""
319 def __init__(self, session):
320 self.session = session
321 self.powerKeyTimer = eTimer()
322 self.powerKeyTimer.timeout.get().append(self.powertimer)
323 globalActionMap.actions["powerdown"]=self.powerdown
324 globalActionMap.actions["powerup"]=self.powerup
325 self.standbyblocked = 0
326 # self["PowerKeyActions"] = HelpableActionMap(self, "PowerKeyActions",
328 #"powerdown": self.powerdown,
329 #"powerup": self.powerup,
330 #"discreteStandby": (self.standby, "Go standby"),
331 #"discretePowerOff": (self.quit, "Go to deep standby"),
334 def powertimer(self):
335 print "PowerOff - Now!"
339 self.standbyblocked = 0
340 self.powerKeyTimer.start(3000, True)
343 self.powerKeyTimer.stop()
344 if self.standbyblocked == 0:
345 self.standbyblocked = 1
349 self.session.open(Standby, self)
356 plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
358 session = Session(desktop = getDesktop(0), summary_desktop = getDesktop(1), navigation = Navigation())
362 for p in plugins.getPlugins(PluginDescriptor.WHERE_WIZARD):
363 screensToRun.append(p.__call__)
365 screensToRun += wizardManager.getWizards()
367 screensToRun.append(Screens.InfoBar.InfoBar)
369 def runNextScreen(session, screensToRun, *result):
371 quitMainloop(*result)
374 screen = screensToRun[0]
376 if len(screensToRun):
377 session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen)
381 runNextScreen(session, screensToRun)
383 CONNECT(keyPressedSignal(), session.keyEvent)
385 vol = VolumeControl(session)
386 power = PowerKey(session)
392 from Tools.DreamboxHardware import setFPWakeuptime
393 from time import time
394 nextRecordingTime = session.nav.RecordTimer.getNextRecordingTime()
395 if nextRecordingTime != -1:
396 if (nextRecordingTime - time() < 330): # no time to switch box back on
397 setFPWakeuptime(time() + 30) # so switch back on in 30 seconds
399 setFPWakeuptime(nextRecordingTime - (300))
401 session.nav.shutdown()
406 keymapparser.readKeymap()
408 skin.loadSkinData(getDesktop(0))
410 import Components.InputDevice
411 Components.InputDevice.InitInputDevices()
413 import Components.AVSwitch
414 Components.AVSwitch.InitAVSwitch()
416 import Components.RecordingConfig
417 Components.RecordingConfig.InitRecordingConfig()
419 import Components.UsageConfig
420 Components.UsageConfig.InitUsageConfig()
422 import Components.Network
423 Components.Network.InitNetwork()
425 import Components.Lcd
426 Components.Lcd.InitLcd()
428 import Components.SetupDevices
429 Components.SetupDevices.InitSetupDevices()
431 import Components.RFmod
432 Components.RFmod.InitRFmod()
434 import Components.NimManager
436 # first, setup a screen
442 print 'EXCEPTION IN PYTHON STARTUP CODE:'
444 traceback.print_exc(file=sys.stdout)