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 Screens.Wizard import wizardManager
20 from Screens.StartWizard import *
21 from Screens.TutorialWizard import *
22 from Tools.BoundFunction import boundFunction
23 from Tools.Directories import InitFallbackFiles
25 eDVBDB.getInstance().reloadBouquets()
27 # initialize autorun plugins and plugin menu entries
28 from Components.PluginComponent import plugins
29 plugins.getPluginList()
33 def dump(dir, p = ""):
34 if isinstance(dir, dict):
35 for (entry, val) in dir.items():
36 dump(val, p + "(dict)/" + entry)
37 if hasattr(dir, "__dict__"):
38 for name, value in dir.__dict__.items():
39 if not had.has_key(str(value)):
41 dump(value, p + "/" + str(name))
43 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
45 print p + ":" + str(dir)
47 # + ":" + str(dir.__class__)
52 def create(self, screen): pass
56 class HTMLOutputDevice(OutputDevice):
57 def create(self, comp):
58 print comp.produceHTML()
60 html = HTMLOutputDevice()
62 class GUIOutputDevice(OutputDevice):
64 def create(self, comp, desktop):
65 comp.createGUIScreen(self.parent, desktop)
70 self.delayTimer = eTimer()
71 self.delayTimer.timeout.get().append(self.processDelay)
73 self.currentDialog = None
75 self.dialogStack = [ ]
77 def processDelay(self):
80 callback = self.currentDialog.callback
82 retval = self.currentDialog.returnValue
84 if self.currentDialog.isTmp:
85 self.currentDialog.doClose()
86 # dump(self.currentDialog)
87 del self.currentDialog
89 del self.currentDialog.callback
92 if callback is not None:
96 c = self.currentDialog
99 # when execBegin opened a new dialog, don't bother showing the old one.
100 if c == self.currentDialog:
104 self.currentDialog.execEnd()
105 self.currentDialog.instance.hide()
107 def create(self, screen, arguments):
108 # creates an instance of 'screen' (which is a class)
110 return screen(self, *arguments)
112 errstr = "Screen %s(%s): %s" % (str(screen), str(arguments), sys.exc_info()[0])
114 traceback.print_exc(file=sys.stdout)
118 def instantiateDialog(self, screen, *arguments):
122 dlg = self.create(screen, arguments)
124 print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
126 traceback.print_exc(file=sys.stdout)
134 readSkin(dlg, None, dlg.skinName, self.desktop)
136 # create GUI view of this dialog
137 assert self.desktop != None
138 dlg.instance = eWindow(self.desktop)
139 applyAllAttributes(dlg.instance, self.desktop, dlg.skinAttributes)
140 gui = GUIOutputDevice()
141 gui.parent = dlg.instance
142 gui.create(dlg, self.desktop)
146 def pushCurrent(self):
147 if self.currentDialog:
148 self.dialogStack.append(self.currentDialog)
151 def popCurrent(self):
152 if len(self.dialogStack):
153 self.currentDialog = self.dialogStack.pop()
156 self.currentDialog = None
158 def execDialog(self, dialog):
160 self.currentDialog = dialog
161 self.currentDialog.isTmp = False
162 self.currentDialog.callback = None # would cause re-entrancy problems.
165 def openWithCallback(self, callback, screen, *arguments):
166 dlg = self.open(screen, *arguments)
167 dlg.callback = callback
169 def open(self, screen, *arguments):
171 dlg = self.currentDialog = self.instantiateDialog(screen, *arguments)
177 def keyEvent(self, code):
178 print "code " + str(code)
180 def close(self, *retval):
181 self.currentDialog.returnValue = retval
182 self.delayTimer.start(0, 1)
186 session.desktop = getDesktop()
188 session.nav = Navigation()
190 screensToRun = wizardManager.getWizards()
191 screensToRun.append(Screens.InfoBar.InfoBar)
193 def runNextScreen(session, screensToRun, *result):
197 screen = screensToRun[0]
199 if len(screensToRun):
200 session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen)
204 runNextScreen(session, screensToRun)
206 CONNECT(keyPressedSignal(), session.keyEvent)
212 session.nav.shutdown()
217 keymapparser.readKeymap()
219 skin.loadSkin(getDesktop())
221 import Components.InputDevice
222 Components.InputDevice.InitInputDevices()
224 import Components.AVSwitch
225 Components.AVSwitch.InitAVSwitch()
227 import Components.RecordingConfig
228 Components.RecordingConfig.InitRecordingConfig()
230 import Components.UsageConfig
231 Components.UsageConfig.InitUsageConfig()
233 import Components.Network
234 Components.Network.InitNetwork()
236 import Components.Lcd
237 Components.Lcd.InitLcd()
239 import Components.SetupDevices
240 Components.SetupDevices.InitSetupDevices()
242 import Components.RFmod
243 Components.RFmod.InitRFmod()
245 import Components.NimManager
247 # first, setup a screen
251 print 'EXCEPTION IN PYTHON STARTUP CODE:'
253 traceback.print_exc(file=sys.stdout)