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()
24 from twisted.internet import e2reactor
27 from twisted.internet import reactor
35 # initialize autorun plugins and plugin menu entries
36 from Components.PluginComponent import plugins
37 plugins.getPluginList(runAutostartPlugins=True)
38 from Screens.Wizard import wizardManager
39 from Screens.StartWizard import *
40 from Screens.TutorialWizard import *
41 from Tools.BoundFunction import boundFunction
45 def dump(dir, p = ""):
46 if isinstance(dir, dict):
47 for (entry, val) in dir.items():
48 dump(val, p + "(dict)/" + entry)
49 if hasattr(dir, "__dict__"):
50 for name, value in dir.__dict__.items():
51 if not had.has_key(str(value)):
53 dump(value, p + "/" + str(name))
55 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
57 print p + ":" + str(dir)
59 # + ":" + str(dir.__class__)
64 def create(self, screen): pass
68 class HTMLOutputDevice(OutputDevice):
69 def create(self, comp):
70 print comp.produceHTML()
72 html = HTMLOutputDevice()
74 class GUIOutputDevice(OutputDevice):
76 def create(self, comp, desktop):
77 comp.createGUIScreen(self.parent, desktop)
82 self.delayTimer = eTimer()
83 self.delayTimer.timeout.get().append(self.processDelay)
85 self.currentDialog = None
87 self.dialogStack = [ ]
89 def processDelay(self):
92 callback = self.currentDialog.callback
94 retval = self.currentDialog.returnValue
96 if self.currentDialog.isTmp:
97 self.currentDialog.doClose()
98 # dump(self.currentDialog)
99 del self.currentDialog
101 del self.currentDialog.callback
104 if callback is not None:
108 c = self.currentDialog
111 # when execBegin opened a new dialog, don't bother showing the old one.
112 if c == self.currentDialog:
116 self.currentDialog.execEnd()
117 self.currentDialog.instance.hide()
119 def create(self, screen, arguments):
120 # creates an instance of 'screen' (which is a class)
122 return screen(self, *arguments)
124 errstr = "Screen %s(%s): %s" % (str(screen), str(arguments), sys.exc_info()[0])
126 traceback.print_exc(file=sys.stdout)
130 def instantiateDialog(self, screen, *arguments):
134 dlg = self.create(screen, arguments)
136 print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
138 traceback.print_exc(file=sys.stdout)
146 readSkin(dlg, None, dlg.skinName, self.desktop)
148 # create GUI view of this dialog
149 assert self.desktop != None
152 for (key, value) in dlg.skinAttributes:
153 if key == "zPosition":
156 dlg.instance = eWindow(self.desktop, z)
157 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
158 gui = GUIOutputDevice()
159 gui.parent = dlg.instance
160 gui.create(dlg, self.desktop)
164 def pushCurrent(self):
165 if self.currentDialog:
166 self.dialogStack.append(self.currentDialog)
169 def popCurrent(self):
170 if len(self.dialogStack):
171 self.currentDialog = self.dialogStack.pop()
174 self.currentDialog = None
176 def execDialog(self, dialog):
178 self.currentDialog = dialog
179 self.currentDialog.isTmp = False
180 self.currentDialog.callback = None # would cause re-entrancy problems.
183 def openWithCallback(self, callback, screen, *arguments):
184 dlg = self.open(screen, *arguments)
185 dlg.callback = callback
187 def open(self, screen, *arguments):
189 dlg = self.currentDialog = self.instantiateDialog(screen, *arguments)
195 def keyEvent(self, code):
196 print "code " + str(code)
198 def close(self, *retval):
199 self.currentDialog.returnValue = retval
200 self.delayTimer.start(0, 1)
204 session.desktop = getDesktop()
206 session.nav = Navigation()
208 screensToRun = wizardManager.getWizards()
209 screensToRun.append(Screens.InfoBar.InfoBar)
211 def runNextScreen(session, screensToRun, *result):
215 screen = screensToRun[0]
217 if len(screensToRun):
218 session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen)
222 runNextScreen(session, screensToRun)
224 CONNECT(keyPressedSignal(), session.keyEvent)
230 session.nav.shutdown()
235 keymapparser.readKeymap()
237 skin.loadSkin(getDesktop())
239 import Components.InputDevice
240 Components.InputDevice.InitInputDevices()
242 import Components.AVSwitch
243 Components.AVSwitch.InitAVSwitch()
245 import Components.RecordingConfig
246 Components.RecordingConfig.InitRecordingConfig()
248 import Components.UsageConfig
249 Components.UsageConfig.InitUsageConfig()
251 import Components.Network
252 Components.Network.InitNetwork()
254 import Components.Lcd
255 Components.Lcd.InitLcd()
257 import Components.SetupDevices
258 Components.SetupDevices.InitSetupDevices()
260 import Components.RFmod
261 Components.RFmod.InitRFmod()
263 import Components.NimManager
265 # first, setup a screen
268 plugins.getPluginList(runAutoendPlugins=True)
270 print 'EXCEPTION IN PYTHON STARTUP CODE:'
272 traceback.print_exc(file=sys.stdout)