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()
315 plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
317 session = Session(desktop = getDesktop(0), summary_desktop = getDesktop(1), navigation = Navigation())
321 for p in plugins.getPlugins(PluginDescriptor.WHERE_WIZARD):
322 screensToRun.append(p.__call__)
324 screensToRun += wizardManager.getWizards()
326 screensToRun.append(Screens.InfoBar.InfoBar)
328 def runNextScreen(session, screensToRun, *result):
330 quitMainloop(*result)
333 screen = screensToRun[0]
335 if len(screensToRun):
336 session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen)
340 runNextScreen(session, screensToRun)
342 CONNECT(keyPressedSignal(), session.keyEvent)
344 vol = VolumeControl(session)
350 from Tools.DreamboxHardware import setFPWakeuptime
351 from time import time
352 nextRecordingTime = session.nav.RecordTimer.getNextRecordingTime()
353 if nextRecordingTime != -1:
354 if (nextRecordingTime - time() < 330): # no time to switch box back on
355 setFPWakeuptime(time() + 30) # so switch back on in 30 seconds
357 setFPWakeuptime(nextRecordingTime - (300))
359 session.nav.shutdown()
364 keymapparser.readKeymap()
366 skin.loadSkin(getDesktop(0))
368 import Components.InputDevice
369 Components.InputDevice.InitInputDevices()
371 import Components.AVSwitch
372 Components.AVSwitch.InitAVSwitch()
374 import Components.RecordingConfig
375 Components.RecordingConfig.InitRecordingConfig()
377 import Components.UsageConfig
378 Components.UsageConfig.InitUsageConfig()
380 import Components.Network
381 Components.Network.InitNetwork()
383 import Components.Lcd
384 Components.Lcd.InitLcd()
386 import Components.SetupDevices
387 Components.SetupDevices.InitSetupDevices()
389 import Components.RFmod
390 Components.RFmod.InitRFmod()
392 import Components.NimManager
394 # first, setup a screen
400 print 'EXCEPTION IN PYTHON STARTUP CODE:'
402 traceback.print_exc(file=sys.stdout)