4 from Components.Language import language
12 import ServiceReference
14 from Navigation import Navigation
16 from skin import readSkin, applyAllAttributes
18 from Components.config import configfile
19 from Tools.Directories import InitFallbackFiles
21 eDVBDB.getInstance().reloadBouquets()
22 # initialize autorun plugins and plugin menu entries
23 from Components.PluginComponent import plugins
24 plugins.getPluginList(runAutostartPlugins=True)
25 from Screens.Wizard import wizardManager
26 from Screens.StartWizard import *
27 from Screens.TutorialWizard import *
28 from Tools.BoundFunction import boundFunction
32 def dump(dir, p = ""):
33 if isinstance(dir, dict):
34 for (entry, val) in dir.items():
35 dump(val, p + "(dict)/" + entry)
36 if hasattr(dir, "__dict__"):
37 for name, value in dir.__dict__.items():
38 if not had.has_key(str(value)):
40 dump(value, p + "/" + str(name))
42 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
44 print p + ":" + str(dir)
46 # + ":" + str(dir.__class__)
51 def create(self, screen): pass
55 class HTMLOutputDevice(OutputDevice):
56 def create(self, comp):
57 print comp.produceHTML()
59 html = HTMLOutputDevice()
61 class GUIOutputDevice(OutputDevice):
63 def create(self, comp, desktop):
64 comp.createGUIScreen(self.parent, desktop)
69 self.delayTimer = eTimer()
70 self.delayTimer.timeout.get().append(self.processDelay)
72 self.currentDialog = None
74 self.dialogStack = [ ]
76 def processDelay(self):
79 callback = self.currentDialog.callback
81 retval = self.currentDialog.returnValue
83 if self.currentDialog.isTmp:
84 self.currentDialog.doClose()
85 # dump(self.currentDialog)
86 del self.currentDialog
88 del self.currentDialog.callback
91 if callback is not None:
95 c = self.currentDialog
98 # when execBegin opened a new dialog, don't bother showing the old one.
99 if c == self.currentDialog:
103 self.currentDialog.execEnd()
104 self.currentDialog.instance.hide()
106 def create(self, screen, arguments):
107 # creates an instance of 'screen' (which is a class)
109 return screen(self, *arguments)
111 errstr = "Screen %s(%s): %s" % (str(screen), str(arguments), sys.exc_info()[0])
113 traceback.print_exc(file=sys.stdout)
117 def instantiateDialog(self, screen, *arguments):
121 dlg = self.create(screen, arguments)
123 print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
125 traceback.print_exc(file=sys.stdout)
133 readSkin(dlg, None, dlg.skinName, self.desktop)
135 # create GUI view of this dialog
136 assert self.desktop != None
137 dlg.instance = eWindow(self.desktop)
138 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
139 gui = GUIOutputDevice()
140 gui.parent = dlg.instance
141 gui.create(dlg, self.desktop)
145 def pushCurrent(self):
146 if self.currentDialog:
147 self.dialogStack.append(self.currentDialog)
150 def popCurrent(self):
151 if len(self.dialogStack):
152 self.currentDialog = self.dialogStack.pop()
155 self.currentDialog = None
157 def execDialog(self, dialog):
159 self.currentDialog = dialog
160 self.currentDialog.isTmp = False
161 self.currentDialog.callback = None # would cause re-entrancy problems.
164 def openWithCallback(self, callback, screen, *arguments):
165 dlg = self.open(screen, *arguments)
166 dlg.callback = callback
168 def open(self, screen, *arguments):
170 dlg = self.currentDialog = self.instantiateDialog(screen, *arguments)
176 def keyEvent(self, code):
177 print "code " + str(code)
179 def close(self, *retval):
180 self.currentDialog.returnValue = retval
181 self.delayTimer.start(0, 1)
185 session.desktop = getDesktop()
187 session.nav = Navigation()
189 screensToRun = wizardManager.getWizards()
190 screensToRun.append(Screens.InfoBar.InfoBar)
192 def runNextScreen(session, screensToRun, *result):
196 screen = screensToRun[0]
198 if len(screensToRun):
199 session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen)
203 runNextScreen(session, screensToRun)
205 CONNECT(keyPressedSignal(), session.keyEvent)
211 session.nav.shutdown()
216 keymapparser.readKeymap()
218 skin.loadSkin(getDesktop())
220 import Components.InputDevice
221 Components.InputDevice.InitInputDevices()
223 import Components.AVSwitch
224 Components.AVSwitch.InitAVSwitch()
226 import Components.RecordingConfig
227 Components.RecordingConfig.InitRecordingConfig()
229 import Components.UsageConfig
230 Components.UsageConfig.InitUsageConfig()
232 import Components.Network
233 Components.Network.InitNetwork()
235 import Components.Lcd
236 Components.Lcd.InitLcd()
238 import Components.SetupDevices
239 Components.SetupDevices.InitSetupDevices()
241 import Components.RFmod
242 Components.RFmod.InitRFmod()
244 import Components.NimManager
246 # first, setup a screen
249 plugins.getPluginList(runAutoendPlugins=True)
251 print 'EXCEPTION IN PYTHON STARTUP CODE:'
253 traceback.print_exc(file=sys.stdout)