1 from Tools import RedirectOutput
5 from Components.Language import language
13 import ServiceReference
15 from Navigation import Navigation
17 from skin import readSkin, applyAllAttributes
19 from Components.config import configfile
20 from Tools.Directories import InitFallbackFiles, resolveFilename, SCOPE_PLUGINS
22 eDVBDB.getInstance().reloadBouquets()
28 from twisted.internet import reactor
33 print "twisted not available"
37 # initialize autorun plugins and plugin menu entries
38 from Components.PluginComponent import plugins
39 plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
41 from Screens.Wizard import wizardManager
42 from Screens.StartWizard import *
43 from Screens.TutorialWizard import *
44 from Tools.BoundFunction import boundFunction
45 from Plugins.Plugin import PluginDescriptor
49 def dump(dir, p = ""):
50 if isinstance(dir, dict):
51 for (entry, val) in dir.items():
52 dump(val, p + "(dict)/" + entry)
53 if hasattr(dir, "__dict__"):
54 for name, value in dir.__dict__.items():
55 if not had.has_key(str(value)):
57 dump(value, p + "/" + str(name))
59 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
61 print p + ":" + str(dir)
63 # + ":" + str(dir.__class__)
68 def create(self, screen): pass
72 class HTMLOutputDevice(OutputDevice):
73 def create(self, comp):
74 print comp.produceHTML()
76 html = HTMLOutputDevice()
78 class GUIOutputDevice(OutputDevice):
80 def create(self, comp, desktop):
81 comp.createGUIScreen(self.parent, desktop)
86 self.delayTimer = eTimer()
87 self.delayTimer.timeout.get().append(self.processDelay)
89 self.currentDialog = None
91 self.dialogStack = [ ]
93 def processDelay(self):
96 callback = self.currentDialog.callback
98 retval = self.currentDialog.returnValue
100 if self.currentDialog.isTmp:
101 self.currentDialog.doClose()
102 # dump(self.currentDialog)
103 del self.currentDialog
105 del self.currentDialog.callback
108 if callback is not None:
112 c = self.currentDialog
115 # when execBegin opened a new dialog, don't bother showing the old one.
116 if c == self.currentDialog:
120 self.currentDialog.execEnd()
121 self.currentDialog.hide()
123 def create(self, screen, arguments, **kwargs):
124 # creates an instance of 'screen' (which is a class)
126 return screen(self, *arguments, **kwargs)
128 errstr = "Screen %s(%s, %s): %s" % (str(screen), str(arguments), str(kwargs), sys.exc_info()[0])
130 traceback.print_exc(file=sys.stdout)
134 def instantiateDialog(self, screen, *arguments, **kwargs):
138 dlg = self.create(screen, arguments, **kwargs)
140 print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
142 traceback.print_exc(file=sys.stdout)
150 readSkin(dlg, None, dlg.skinName, self.desktop)
152 # create GUI view of this dialog
153 assert self.desktop != None
156 for (key, value) in dlg.skinAttributes:
157 if key == "zPosition":
160 dlg.instance = eWindow(self.desktop, z)
161 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
162 gui = GUIOutputDevice()
163 gui.parent = dlg.instance
164 gui.create(dlg, self.desktop)
168 def pushCurrent(self):
169 if self.currentDialog:
170 self.dialogStack.append(self.currentDialog)
173 def popCurrent(self):
174 if len(self.dialogStack):
175 self.currentDialog = self.dialogStack.pop()
178 self.currentDialog = None
180 def execDialog(self, dialog):
182 self.currentDialog = dialog
183 self.currentDialog.isTmp = False
184 self.currentDialog.callback = None # would cause re-entrancy problems.
187 def openWithCallback(self, callback, screen, *arguments, **kwargs):
188 dlg = self.open(screen, *arguments, **kwargs)
189 dlg.callback = callback
191 def open(self, screen, *arguments, **kwargs):
193 dlg = self.currentDialog = self.instantiateDialog(screen, *arguments, **kwargs)
199 def keyEvent(self, code):
200 print "code " + str(code)
202 def close(self, *retval):
203 self.currentDialog.returnValue = retval
204 self.delayTimer.start(0, 1)
206 from Screens.Volume import Volume
207 from Screens.Mute import Mute
208 from GlobalActions import globalActionMap
209 from Components.config import ConfigSubsection, configSequence, configElement, configsequencearg
211 #TODO .. move this to a own .py file
213 """Volume control, handles volUp, volDown, volMute actions and display
214 a corresponding dialog"""
215 def __init__(self, session):
216 global globalActionMap
217 globalActionMap.actions["volumeUp"]=self.volUp
218 globalActionMap.actions["volumeDown"]=self.volDown
219 globalActionMap.actions["volumeMute"]=self.volMute
221 config.audio = ConfigSubsection()
222 config.audio.volume = configElement("config.audio.volume", configSequence, [100], configsequencearg.get("INTEGER", (0, 100)))
224 self.volumeDialog = session.instantiateDialog(Volume)
225 self.muteDialog = session.instantiateDialog(Mute)
227 self.hideVolTimer = eTimer()
228 self.hideVolTimer.timeout.get().append(self.volHide)
230 vol = config.audio.volume.value[0]
231 self.volumeDialog.setValue(vol)
232 eDVBVolumecontrol.getInstance().setVolume(vol, vol)
235 config.audio.volume.value = eDVBVolumecontrol.getInstance().getVolume()
236 config.audio.volume.save()
239 if (eDVBVolumecontrol.getInstance().isMuted()):
241 eDVBVolumecontrol.getInstance().volumeUp()
242 self.volumeDialog.show()
243 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
245 self.hideVolTimer.start(3000, True)
248 if (eDVBVolumecontrol.getInstance().isMuted()):
250 eDVBVolumecontrol.getInstance().volumeDown()
251 self.volumeDialog.show()
252 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
254 self.hideVolTimer.start(3000, True)
257 self.volumeDialog.hide()
260 eDVBVolumecontrol.getInstance().volumeToggleMute()
261 self.volumeDialog.setValue(eDVBVolumecontrol.getInstance().getVolume())
263 if (eDVBVolumecontrol.getInstance().isMuted()):
264 self.muteDialog.show()
266 self.muteDialog.hide()
270 session.desktop = getDesktop()
272 session.nav = Navigation()
276 for p in plugins.getPlugins(PluginDescriptor.WHERE_WIZARD):
277 screensToRun.append(p.__call__)
279 screensToRun += wizardManager.getWizards()
281 screensToRun.append(Screens.InfoBar.InfoBar)
283 def runNextScreen(session, screensToRun, *result):
285 quitMainloop(*result)
288 screen = screensToRun[0]
290 if len(screensToRun):
291 session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen)
295 runNextScreen(session, screensToRun)
297 CONNECT(keyPressedSignal(), session.keyEvent)
299 vol = VolumeControl(session)
305 from Tools.DreamboxHardware import setFPWakeuptime
306 from time import time
307 nextRecordingTime = session.nav.RecordTimer.getNextRecordingTime()
308 if nextRecordingTime != -1:
309 if (nextRecordingTime < 330): # no time to switch box back on
310 setFPWakeuptime(time() + 30) # so switch back on in 30 seconds
312 setFPWakeuptime(nextRecordingTime - (300))
314 session.nav.shutdown()
319 keymapparser.readKeymap()
321 skin.loadSkin(getDesktop())
323 import Components.InputDevice
324 Components.InputDevice.InitInputDevices()
326 import Components.AVSwitch
327 Components.AVSwitch.InitAVSwitch()
329 import Components.RecordingConfig
330 Components.RecordingConfig.InitRecordingConfig()
332 import Components.UsageConfig
333 Components.UsageConfig.InitUsageConfig()
335 import Components.Network
336 Components.Network.InitNetwork()
338 import Components.Lcd
339 Components.Lcd.InitLcd()
341 import Components.SetupDevices
342 Components.SetupDevices.InitSetupDevices()
344 import Components.RFmod
345 Components.RFmod.InitRFmod()
347 import Components.NimManager
349 # first, setup a screen
355 print 'EXCEPTION IN PYTHON STARTUP CODE:'
357 traceback.print_exc(file=sys.stdout)