1 from Tools import RedirectOutput
5 from Components.Language import language
9 from Screens.SimpleSummary import SimpleSummary
14 import ServiceReference
16 from Navigation import Navigation
18 from skin import readSkin, applyAllAttributes
20 from Components.config import configfile
21 from Tools.Directories import InitFallbackFiles, resolveFilename, SCOPE_PLUGINS
23 eDVBDB.getInstance().reloadBouquets()
29 from twisted.internet import reactor
34 print "twisted not available"
38 # initialize autorun plugins and plugin menu entries
39 from Components.PluginComponent import plugins
40 plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
42 from Screens.Wizard import wizardManager
43 from Screens.StartWizard import *
44 from Screens.TutorialWizard import *
45 from Tools.BoundFunction import boundFunction
46 from Plugins.Plugin import PluginDescriptor
50 def dump(dir, p = ""):
51 if isinstance(dir, dict):
52 for (entry, val) in dir.items():
53 dump(val, p + "(dict)/" + entry)
54 if hasattr(dir, "__dict__"):
55 for name, value in dir.__dict__.items():
56 if not had.has_key(str(value)):
58 dump(value, p + "/" + str(name))
60 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
62 print p + ":" + str(dir)
64 # + ":" + str(dir.__class__)
69 def create(self, screen): pass
73 class HTMLOutputDevice(OutputDevice):
74 def create(self, comp):
75 print comp.produceHTML()
77 html = HTMLOutputDevice()
79 class GUIOutputDevice(OutputDevice):
81 def create(self, comp, desktop):
82 comp.createGUIScreen(self.parent, desktop)
85 def __init__(self, desktop = None, summary_desktop = None, navigation = None):
86 self.desktop = desktop
87 self.summary_desktop = summary_desktop
89 self.delay_timer = eTimer()
90 self.delay_timer.timeout.get().append(self.processDelay)
92 self.current_dialog = None
94 self.dialog_stack = [ ]
95 self.summary_stack = [ ]
98 def processDelay(self):
101 callback = self.current_dialog.callback
103 retval = self.current_dialog.returnValue
105 if self.current_dialog.isTmp:
106 self.current_dialog.doClose()
107 # dump(self.current_dialog)
108 del self.current_dialog
110 del self.current_dialog.callback
113 if callback is not None:
117 c = self.current_dialog
121 summary = c.createSummary() or SimpleSummary
122 self.summary = self.instantiateSummaryDialog(summary, c)
125 c.addSummary(self.summary)
128 # when execBegin opened a new dialog, don't bother showing the old one.
129 if c == self.current_dialog:
133 self.current_dialog.execEnd()
134 self.current_dialog.hide()
135 self.current_dialog.removeSummary(self.summary)
138 def create(self, screen, arguments, **kwargs):
139 # creates an instance of 'screen' (which is a class)
141 return screen(self, *arguments, **kwargs)
143 errstr = "Screen %s(%s, %s): %s" % (str(screen), str(arguments), str(kwargs), sys.exc_info()[0])
145 traceback.print_exc(file=sys.stdout)
148 def instantiateDialog(self, screen, *arguments, **kwargs):
149 return self.doInstantiateDialog(screen, arguments, kwargs, self.desktop)
151 def instantiateSummaryDialog(self, screen, *arguments, **kwargs):
152 return self.doInstantiateDialog(screen, arguments, kwargs, self.summary_desktop)
154 def doInstantiateDialog(self, screen, arguments, kwargs, desktop):
158 dlg = self.create(screen, arguments, **kwargs)
160 print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
162 traceback.print_exc(file=sys.stdout)
170 readSkin(dlg, None, dlg.skinName, desktop)
172 # create GUI view of this dialog
173 assert desktop is not None
177 for (key, value) in dlg.skinAttributes:
178 if key == "zPosition":
183 dlg.instance = eWindow(desktop, z)
185 applyAllAttributes(dlg.instance, desktop, dlg.skinAttributes)
186 gui = GUIOutputDevice()
187 gui.parent = dlg.instance
188 gui.create(dlg, desktop)
192 def pushCurrent(self):
193 if self.current_dialog:
194 self.dialog_stack.append(self.current_dialog)
197 def popCurrent(self):
198 if len(self.dialog_stack):
199 self.current_dialog = self.dialog_stack.pop()
202 self.current_dialog = None
204 def execDialog(self, dialog):
206 self.current_dialog = dialog
207 self.current_dialog.isTmp = False
208 self.current_dialog.callback = None # would cause re-entrancy problems.
211 def openWithCallback(self, callback, screen, *arguments, **kwargs):
212 dlg = self.open(screen, *arguments, **kwargs)
213 dlg.callback = callback
215 def open(self, screen, *arguments, **kwargs):
217 dlg = self.current_dialog = self.instantiateDialog(screen, *arguments, **kwargs)
223 def keyEvent(self, code):
224 print "code " + str(code)
226 def close(self, *retval):
227 self.current_dialog.returnValue = retval
228 self.delay_timer.start(0, 1)
230 def pushSummary(self):
231 if self.summary is not None:
233 self.summary_stack.append(self.summary)
236 def popSummary(self):
237 if self.summary is not None:
238 self.summary.doClose()
239 self.summary = self.summary_stack.pop()
240 if self.summary is not None:
243 from Screens.Volume import Volume
244 from Screens.Mute import Mute
245 from GlobalActions import globalActionMap
246 from Components.config import ConfigSubsection, configSequence, configElement, configsequencearg
248 #TODO .. move this to a own .py file
250 """Volume control, handles volUp, volDown, volMute actions and display
251 a corresponding dialog"""
252 def __init__(self, session):
253 global globalActionMap
254 globalActionMap.actions["volumeUp"]=self.volUp
255 globalActionMap.actions["volumeDown"]=self.volDown
256 globalActionMap.actions["volumeMute"]=self.volMute
258 config.audio = ConfigSubsection()
259 config.audio.volume = configElement("config.audio.volume", configSequence, [100], configsequencearg.get("INTEGER", (0, 100)))
261 self.volumeDialog = session.instantiateDialog(Volume)
262 self.muteDialog = session.instantiateDialog(Mute)
264 self.hideVolTimer = eTimer()
265 self.hideVolTimer.timeout.get().append(self.volHide)
267 vol = config.audio.volume.value[0]
268 self.volumeDialog.setValue(vol)
269 eDVBVolumecontrol.getInstance().setVolume(vol, vol)
272 config.audio.volume.value = eDVBVolumecontrol.getInstance().getVolume()
273 config.audio.volume.save()
276 if (eDVBVolumecontrol.getInstance().isMuted()):
278 eDVBVolumecontrol.getInstance().volumeUp()
279 self.volumeDialog.show()
280 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
282 self.hideVolTimer.start(3000, True)
285 if (eDVBVolumecontrol.getInstance().isMuted()):
287 eDVBVolumecontrol.getInstance().volumeDown()
288 self.volumeDialog.show()
289 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
291 self.hideVolTimer.start(3000, True)
294 self.volumeDialog.hide()
297 eDVBVolumecontrol.getInstance().volumeToggleMute()
298 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
300 if (eDVBVolumecontrol.getInstance().isMuted()):
301 self.muteDialog.show()
303 self.muteDialog.hide()
306 session = Session(desktop = getDesktop(0), summary_desktop = getDesktop(1), navigation = Navigation())
310 for p in plugins.getPlugins(PluginDescriptor.WHERE_WIZARD):
311 screensToRun.append(p.__call__)
313 screensToRun += wizardManager.getWizards()
315 screensToRun.append(Screens.InfoBar.InfoBar)
317 def runNextScreen(session, screensToRun, *result):
319 quitMainloop(*result)
322 screen = screensToRun[0]
324 if len(screensToRun):
325 session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen)
329 runNextScreen(session, screensToRun)
331 CONNECT(keyPressedSignal(), session.keyEvent)
333 vol = VolumeControl(session)
339 from Tools.DreamboxHardware import setFPWakeuptime
340 from time import time
341 nextRecordingTime = session.nav.RecordTimer.getNextRecordingTime()
342 if nextRecordingTime != -1:
343 if (nextRecordingTime - time() < 330): # no time to switch box back on
344 setFPWakeuptime(time() + 30) # so switch back on in 30 seconds
346 setFPWakeuptime(nextRecordingTime - (300))
348 session.nav.shutdown()
353 keymapparser.readKeymap()
355 skin.loadSkin(getDesktop(0))
357 import Components.InputDevice
358 Components.InputDevice.InitInputDevices()
360 import Components.AVSwitch
361 Components.AVSwitch.InitAVSwitch()
363 import Components.RecordingConfig
364 Components.RecordingConfig.InitRecordingConfig()
366 import Components.UsageConfig
367 Components.UsageConfig.InitUsageConfig()
369 import Components.Network
370 Components.Network.InitNetwork()
372 import Components.Lcd
373 Components.Lcd.InitLcd()
375 import Components.SetupDevices
376 Components.SetupDevices.InitSetupDevices()
378 import Components.RFmod
379 Components.RFmod.InitRFmod()
381 import Components.NimManager
383 # first, setup a screen
389 print 'EXCEPTION IN PYTHON STARTUP CODE:'
391 traceback.print_exc(file=sys.stdout)