enigma2 20130831 (master) -> 20130902 (master)
[enigma2.git] / usr / lib / enigma2 / python / mytest.py
1 import eConsoleImpl
2 import eBaseImpl
3 import enigma
4 enigma.eTimer = eBaseImpl.eTimer
5 enigma.eSocketNotifier = eBaseImpl.eSocketNotifier
6 enigma.eConsoleAppContainer = eConsoleImpl.eConsoleAppContainer
7
8 def gPixmapPtr_deref(self):
9         print "gPixmapPtr.__deref__() is deprecated please completely remove the \".__deref__()\" call!"
10         import traceback
11         traceback.print_stack(limit = 2)
12         return self
13
14 enigma.gPixmapPtr.__deref__ = gPixmapPtr_deref
15
16 # allow None as pixmap parameter for setPixmap
17 ePixmap_setPixmap_org = enigma.ePixmap.setPixmap
18 def ePixmap_setPixmap(self, pixmap):
19         if pixmap is None:
20                 print "ePixmap.setPixmap(None) is deprecated please use ePixmap.setPixmap(enigma.gPixmapPtr())!"
21                 import traceback
22                 traceback.print_stack(limit = 2)
23                 pm = enigma.gPixmapPtr()
24                 ePixmap_setPixmap_org(self, pm)
25         else:
26                 ePixmap_setPixmap_org(self, pixmap)
27 enigma.ePixmap.setPixmap = ePixmap_setPixmap
28
29 # allow None as pixmap parameter for setPixmap
30 eSlider_setPixmap_org = enigma.eSlider.setPixmap
31 def eSlider_setPixmap(self, pixmap):
32         if pixmap is None:
33                 print "eSlider.setPixmap(None) is deprecated please use eSlider.setPixmap(enigma.gPixmapPtr())!"
34                 import traceback
35                 traceback.print_stack(limit = 2)
36                 pm = enigma.gPixmapPtr()
37                 eSlider_setPixmap_org(self, pm)
38         else:
39                 eSlider_setPixmap_org(self, pixmap)
40 enigma.eSlider.setPixmap = eSlider_setPixmap
41
42 # allow None as pixmap parameter for setBackgroundPixmap
43 eSlider_setBackgroundPixmap_org = enigma.eSlider.setBackgroundPixmap
44 def eSlider_setBackgroundPixmap(self, pixmap):
45         if pixmap is None:
46                 print "eSlider.setBackgroundPixmap(None) is deprecated please use eSlider.setBackgroundPixmap(enigma.gPixmapPtr())!"
47                 import traceback
48                 traceback.print_stack(limit = 2)
49                 pm = enigma.gPixmapPtr()
50                 eSlider_setBackgroundPixmap_org(self, pm)
51         else:
52                 eSlider_setBackgroundPixmap_org(self, pixmap)
53 enigma.eSlider.setBackgroundPixmap = eSlider_setBackgroundPixmap
54
55 # allow None as pixmap parameter for setPointer
56 ePositionGauge_setPointer_org = enigma.ePositionGauge.setPointer
57 def ePositionGauge_setPointer(self, which, pixmap, center):
58         if pixmap is None:
59                 print "ePositionGauge.setPointer(which, None, center) is deprecated please use ePositionGauge.setPointer(which, enigma.gPixmapPtr(), center)!"
60                 import traceback
61                 traceback.print_stack(limit = 2)
62                 pm = enigma.gPixmapPtr()
63                 ePositionGauge_setPointer_org(self, which, pm, center)
64         else:
65                 ePositionGauge_setPointer_org(self, which, pixmap, center)
66 enigma.ePositionGauge.setPointer = ePositionGauge_setPointer
67
68 from Tools.Profile import profile, profile_final
69
70 profile("PYTHON_START")
71
72 from enigma import runMainloop, eDVBDB, eTimer, quitMainloop, \
73         getDesktop, ePythonConfigQuery, eAVSwitch, eServiceEvent, \
74         eEPGCache
75 from tools import *
76
77 from Components.ResourceManager import resourcemanager
78 from API import api
79
80 profile("ImageDefaults")
81 from Components.DreamInfoHandler import ImageDefaultInstaller
82 ImageDefaultInstaller()
83
84 profile("LANGUAGE")
85
86 from Components.Language import language
87
88 def setEPGLanguage():
89         print "language set to", language.getLanguage()
90         eServiceEvent.setEPGLanguage(language.getLanguage())
91
92 language.addCallback(setEPGLanguage)
93
94 from traceback import print_exc
95
96 profile("LOAD:InfoBar")
97 import Screens.InfoBar
98 from Screens.SimpleSummary import SimpleSummary
99
100 from sys import stdout, exc_info
101
102 profile("Bouquets")
103 eDVBDB.getInstance().reloadBouquets()
104
105 profile("ParentalControl")
106 from Components.ParentalControl import InitParentalControl
107 InitParentalControl()
108
109 profile("LOAD:Navigation")
110 from Navigation import Navigation
111
112 profile("LOAD:skin")
113 from skin import readSkin
114
115 profile("LOAD:Tools")
116 from Tools.Directories import InitFallbackFiles, resolveFilename, SCOPE_PLUGINS, SCOPE_CURRENT_SKIN
117 from Components.config import config, configfile, ConfigText, ConfigYesNo, ConfigInteger, ConfigSelection, NoSave
118 InitFallbackFiles()
119
120 profile("config.misc")
121
122 config.misc.radiopic = ConfigText(default = resolveFilename(SCOPE_CURRENT_SKIN, "radio.mvi"))
123 config.misc.disable_timer_sn_thread_checks = ConfigYesNo(default=False)
124 config.misc.isNextRecordTimerAfterEventActionAuto = ConfigYesNo(default=False)
125 config.misc.useTransponderTime = ConfigYesNo(default=True)
126 config.misc.startCounter = ConfigInteger(default=0) # number of e2 starts...
127 config.misc.standbyCounter = NoSave(ConfigInteger(default=0)) # number of standby
128 config.misc.epgcache_filename = ConfigText(default = "/media/hdd/epg.dat")
129 config.misc.epgcache_timespan = ConfigSelection(default = "28", choices = [("7", _("7 days")), ("14", _("14 days")), ("21", _("21 days")), ("28", _("28 days"))])
130 config.misc.epgcache_outdated_timespan = ConfigInteger(default = 0, limits=(0,96))
131 config.misc.record_io_buffer = ConfigInteger(default=192512*5)
132 config.misc.record_dmx_buffer = ConfigInteger(default=1024*1024)
133 config.misc.prev_wakeup_time = ConfigInteger(default=0)
134 config.misc.use_legacy_virtual_subservices_detection = ConfigYesNo(default=False)
135
136 def setEPGCachePath(configElement):
137         eEPGCache.getInstance().setCacheFile(configElement.value)
138
139 def setEPGCacheTimespan(configElement):
140         eEPGCache.getInstance().setCacheTimespan(int(configElement.value))
141
142 def setOutdatedEPGTimespan(configElement):
143         eEPGCache.getInstance().setOutdatedEPGTimespan(configElement.value)
144
145 #demo code for use of standby enter leave callbacks
146 #def leaveStandby():
147 #       print "!!!!!!!!!!!!!!!!!leave standby"
148
149 #def standbyCountChanged(configElement):
150 #       print "!!!!!!!!!!!!!!!!!enter standby num", configElement.value
151 #       from Screens.Standby import inStandby
152 #       inStandby.onClose.append(leaveStandby)
153
154 #config.misc.standbyCounter.addNotifier(standbyCountChanged, initial_call = False)
155 ####################################################
156
157 def useTransponderTimeChanged(configElement):
158         enigma.eDVBLocalTimeHandler.getInstance().setUseDVBTime(configElement.value)
159 config.misc.useTransponderTime.addNotifier(useTransponderTimeChanged)
160
161 profile("Twisted")
162 try:
163         import twisted.python.runtime
164         twisted.python.runtime.platform.supportsThreads = lambda: False
165
166         import e2reactor
167         e2reactor.install()
168
169         from twisted.internet import reactor
170
171         def runReactor():
172                 reactor.run(installSignalHandlers=False)
173 except ImportError:
174         print "twisted not available"
175         def runReactor():
176                 runMainloop()
177
178 profile("LOAD:API")
179 from API import registerAPIs
180 registerAPIs()
181
182 profile("LOAD:Plugin")
183 # initialize autorun plugins and plugin menu entries
184 from Components.PluginComponent import plugins
185 from Plugins.Plugin import PluginDescriptor
186 plugins.runEarlyPlugins(resolveFilename(SCOPE_PLUGINS))
187
188 profile("LOAD:Wizard")
189 from Screens.Wizard import wizardManager
190 from Screens.DefaultWizard import *
191 from Screens.StartWizard import *
192 from Screens.TutorialWizard import *
193 import Screens.Rc
194 from Tools.BoundFunction import boundFunction
195
196 profile("misc")
197 had = dict()
198
199 def dump(dir, p = ""):
200         if isinstance(dir, dict):
201                 for (entry, val) in dir.items():
202                         dump(val, p + "(dict)/" + entry)
203         if hasattr(dir, "__dict__"):
204                 for name, value in dir.__dict__.items():
205                         if not had.has_key(str(value)):
206                                 had[str(value)] = 1
207                                 dump(value, p + "/" + str(name))
208                         else:
209                                 print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
210         else:
211                 print p + ":" + str(dir)
212
213 # + ":" + str(dir.__class__)
214
215 # display
216
217 profile("LOAD:ScreenGlobals")
218 from Screens.Globals import Globals
219 from Screens.SessionGlobals import SessionGlobals
220 from Screens.Screen import Screen
221
222 profile("Screen")
223 Screen.global_screen = Globals()
224
225 # Session.open:
226 # * push current active dialog ('current_dialog') onto stack
227 # * call execEnd for this dialog
228 #   * clear in_exec flag
229 #   * hide screen
230 # * instantiate new dialog into 'current_dialog'
231 #   * create screens, components
232 #   * read, apply skin
233 #   * create GUI for screen
234 # * call execBegin for new dialog
235 #   * set in_exec
236 #   * show gui screen
237 #   * call components' / screen's onExecBegin
238 # ... screen is active, until it calls 'close'...
239 # Session.close:
240 # * assert in_exec
241 # * save return value
242 # * start deferred close handler ('onClose')
243 # * execEnd
244 #   * clear in_exec
245 #   * hide screen
246 # .. a moment later:
247 # Session.doClose:
248 # * destroy screen
249
250 class Session:
251         def __init__(self, desktop = None, summary_desktop = None, navigation = None):
252                 self.desktop = desktop
253                 self.summary_desktop = summary_desktop
254                 self.nav = navigation
255                 self.delay_timer = eTimer()
256                 self.delay_timer.callback.append(self.processDelay)
257
258                 self.current_dialog = None
259                 self.next_dialog = None
260
261                 self.dialog_stack = [ ]
262                 self.summary_stack = [ ]
263                 self.summary = None
264
265                 self.in_exec = False
266
267                 self.screen = SessionGlobals(self)
268
269                 for p in plugins.getPlugins(PluginDescriptor.WHERE_SESSIONSTART):
270                         p(reason=0, session=self)
271
272         def processDelay(self):
273                 callback = self.current_dialog.callback
274
275                 retval = self.current_dialog.returnValue
276
277                 if self.current_dialog.isTmp:
278                         self.current_dialog.doClose()
279 #                       dump(self.current_dialog)
280                         del self.current_dialog
281                 else:
282                         del self.current_dialog.callback
283
284                 self.popCurrent()
285                 if callback is not None:
286                         callback(*retval)
287
288                 if self.next_dialog:
289                         dlg = self.next_dialog
290                         self.next_dialog = None
291                         self.pushCurrent()
292                         self.current_dialog = dlg
293                         self.execBegin()
294
295         def execBegin(self, first=True, do_show = True):
296                 assert not self.in_exec 
297                 self.in_exec = True
298                 c = self.current_dialog
299
300                 # when this is an execbegin after a execend of a "higher" dialog,
301                 # popSummary already did the right thing.
302                 if first:
303                         self.pushSummary()
304                         summary = c.createSummary() or SimpleSummary
305                         self.summary = self.instantiateSummaryDialog(summary, c)
306                         self.summary.show()
307                         c.addSummary(self.summary)
308
309                 c.saveKeyboardMode()
310                 c.execBegin()
311
312                 # when execBegin opened a new dialog, don't bother showing the old one.
313                 if c == self.current_dialog and do_show:
314                         c.show()
315
316         def execEnd(self, last=True):
317                 assert self.in_exec
318                 self.in_exec = False
319
320                 self.current_dialog.execEnd()
321                 self.current_dialog.restoreKeyboardMode()
322                 self.current_dialog.hide()
323
324                 if last:
325                         self.current_dialog.removeSummary(self.summary)
326                         self.popSummary()
327
328         def create(self, screen, arguments, **kwargs):
329                 # creates an instance of 'screen' (which is a class)
330                 try:
331                         return screen(self, *arguments, **kwargs)
332                 except:
333                         errstr = "Screen %s(%s, %s): %s" % (str(screen), str(arguments), str(kwargs), exc_info()[0])
334                         print errstr
335                         print_exc(file=stdout)
336                         quitMainloop(5)
337
338         def instantiateDialog(self, screen, *arguments, **kwargs):
339                 return self.doInstantiateDialog(screen, arguments, kwargs, self.desktop)
340
341         def deleteDialog(self, screen):
342                 screen.hide()
343                 screen.doClose()
344
345         def instantiateSummaryDialog(self, screen, *arguments, **kwargs):
346                 return self.doInstantiateDialog(screen, arguments, kwargs, self.summary_desktop)
347
348         def doInstantiateDialog(self, screen, arguments, kwargs, desktop):
349                 # create dialog
350
351                 try:
352                         dlg = self.create(screen, arguments, **kwargs)
353                 except:
354                         print 'EXCEPTION IN DIALOG INIT CODE, ABORTING:'
355                         print '-'*60
356                         print_exc(file=stdout)
357                         quitMainloop(5)
358                         print '-'*60
359
360                 if dlg is None:
361                         return
362
363                 # read skin data
364                 readSkin(dlg, None, dlg.skinName, desktop)
365
366                 # create GUI view of this dialog
367                 assert desktop is not None
368
369                 dlg.setDesktop(desktop)
370                 dlg.applySkin()
371
372                 return dlg
373
374         def pushCurrent(self):
375                 if self.current_dialog is not None:
376                         self.dialog_stack.append((self.current_dialog, self.current_dialog.shown))
377                         self.execEnd(last=False)
378
379         def popCurrent(self):
380                 if self.dialog_stack:
381                         (self.current_dialog, do_show) = self.dialog_stack.pop()
382                         self.execBegin(first=False, do_show=do_show)
383                 else:
384                         self.current_dialog = None
385
386         def execDialog(self, dialog):
387                 dialog.isTmp = False
388                 dialog.callback = None # would cause re-entrancy problems.
389
390                 if self.delay_timer.isActive():
391                         assert not self.next_dialog
392                         self.next_dialog = dialog
393                 else:
394                         self.pushCurrent()
395                         self.current_dialog = dialog
396                         self.execBegin()
397
398         def openWithCallback(self, callback, screen, *arguments, **kwargs):
399                 dlg = self.open(screen, *arguments, **kwargs)
400                 dlg.callback = callback
401                 return dlg
402
403         def open(self, screen, *arguments, **kwargs):
404                 if self.dialog_stack and not self.in_exec:
405                         raise RuntimeError("modal open are allowed only from a screen which is modal!")
406                         # ...unless it's the very first screen.
407
408                 self.pushCurrent()
409                 dlg = self.current_dialog = self.instantiateDialog(screen, *arguments, **kwargs)
410                 dlg.isTmp = True
411                 dlg.callback = None
412                 self.execBegin()
413                 return dlg
414
415         def close(self, screen, *retval):
416                 if not self.in_exec:
417                         print "close after exec!"
418                         return
419
420                 # be sure that the close is for the right dialog!
421                 # if it's not, you probably closed after another dialog
422                 # was opened. this can happen if you open a dialog
423                 # onExecBegin, and forget to do this only once.
424                 # after close of the top dialog, the underlying will
425                 # gain focus again (for a short time), thus triggering
426                 # the onExec, which opens the dialog again, closing the loop.
427                 assert screen == self.current_dialog
428
429                 self.current_dialog.returnValue = retval
430                 self.delay_timer.start(0, 1)
431                 self.execEnd()
432
433         def pushSummary(self):
434                 if self.summary is not None:
435                         self.summary.hide()
436                 self.summary_stack.append(self.summary)
437                 self.summary = None
438
439         def popSummary(self):
440                 if self.summary is not None:
441                         self.summary.doClose()
442                 self.summary = self.summary_stack.pop()
443                 if self.summary is not None:
444                         self.summary.show()
445
446 profile("Standby,PowerKey")
447 import Screens.Standby
448 from Screens.Menu import MainMenu, mdom
449 from GlobalActions import globalActionMap
450
451 class PowerKey:
452         """ PowerKey stuff - handles the powerkey press and powerkey release actions"""
453
454         def __init__(self, session):
455                 self.session = session
456                 globalActionMap.actions["power_down"]=self.powerdown
457                 globalActionMap.actions["power_up"]=self.powerup
458                 globalActionMap.actions["power_long"]=self.powerlong
459                 globalActionMap.actions["deepstandby"]=self.shutdown # frontpanel long power button press
460                 self.standbyblocked = 1
461
462         def MenuClosed(self, *val):
463                 self.session.infobar = None
464
465         def shutdown(self):
466                 print "PowerOff - Now!"
467                 if not Screens.Standby.inTryQuitMainloop and self.session.current_dialog and self.session.current_dialog.ALLOW_SUSPEND:
468                         self.session.open(Screens.Standby.TryQuitMainloop, 1)
469
470         def powerlong(self):
471                 if Screens.Standby.inTryQuitMainloop or (self.session.current_dialog and not self.session.current_dialog.ALLOW_SUSPEND):
472                         return
473                 self.doAction(action = config.usage.on_long_powerpress.value)
474
475         def doAction(self, action):
476                 self.standbyblocked = 1
477                 if action == "shutdown":
478                         self.shutdown()
479                 elif action == "show_menu":
480                         print "Show shutdown Menu"
481                         root = mdom.getroot()
482                         for x in root.findall("menu"):
483                                 y = x.find("id")
484                                 if y is not None:
485                                         id = y.get("val")
486                                         if id and id == "shutdown":
487                                                 self.session.infobar = self
488                                                 menu_screen = self.session.openWithCallback(self.MenuClosed, MainMenu, x)
489                                                 menu_screen.setTitle(_("Standby / Restart"))
490                                                 return
491                 elif action == "standby":
492                         self.standby()
493
494         def powerdown(self):
495                 self.standbyblocked = 0
496
497         def powerup(self):
498                 if self.standbyblocked == 0:
499                         self.doAction(action = config.usage.on_short_powerpress.value)
500
501         def standby(self):
502                 if not Screens.Standby.inStandby and self.session.current_dialog and self.session.current_dialog.ALLOW_SUSPEND and self.session.in_exec:
503                         self.session.open(Screens.Standby.Standby)
504
505 profile("Scart")
506 from Screens.Scart import Scart
507
508 class AutoScartControl:
509         def __init__(self, session):
510                 self.force = False
511                 self.current_vcr_sb = eAVSwitch.getInstance().getVCRSlowBlanking()
512                 if self.current_vcr_sb and config.av.vcrswitch.value:
513                         self.scartDialog = session.instantiateDialog(Scart, True)
514                 else:
515                         self.scartDialog = session.instantiateDialog(Scart, False)
516                 config.av.vcrswitch.addNotifier(self.recheckVCRSb)
517                 eAVSwitch.getInstance().vcr_sb_notifier.get().append(self.VCRSbChanged)
518
519         def recheckVCRSb(self, configElement):
520                 self.VCRSbChanged(self.current_vcr_sb)
521
522         def VCRSbChanged(self, value):
523                 #print "vcr sb changed to", value
524                 self.current_vcr_sb = value
525                 if config.av.vcrswitch.value or value > 2:
526                         if value:
527                                 self.scartDialog.showMessageBox()
528                         else:
529                                 self.scartDialog.switchToTV()
530
531 profile("Load:CI")
532 from enigma import eDVBCIInterfaces
533 from Screens.Ci import CiHandler
534
535 profile("Load:VolumeControl")
536 from Components.VolumeControl import VolumeControl
537
538 def runScreenTest():
539         config.misc.startCounter.value += 1
540
541         profile("Init:Session")
542         nav = Navigation(config.misc.isNextRecordTimerAfterEventActionAuto.value)
543         session = Session(desktop = getDesktop(0), summary_desktop = getDesktop(1), navigation = nav)
544
545         CiHandler.setSession(session)
546
547         screensToRun = [ p.__call__ for p in plugins.getPlugins(PluginDescriptor.WHERE_WIZARD) ]
548
549         profile("wizards")
550         screensToRun += wizardManager.getWizards()
551
552         screensToRun.append((100, Screens.InfoBar.InfoBar))
553
554         screensToRun.sort()
555
556         ePythonConfigQuery.setQueryFunc(configfile.getResolvedKey)
557
558 #       eDVBCIInterfaces.getInstance().setDescrambleRules(0 # Slot Number
559 #               ,(      ["1:0:1:24:4:85:C00000:0:0:0:"], #service_list
560 #                       ["PREMIERE"], #provider_list,
561 #                       [] #caid_list
562 #               ));
563
564         def runNextScreen(session, screensToRun, *result):
565                 if result:
566                         quitMainloop(*result)
567                         return
568
569                 if screensToRun:
570                         screen = screensToRun[0][1]
571                         args = screensToRun[0][2:]
572         
573                         if screensToRun:
574                                 session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen, *args)
575                         else:
576                                 session.open(screen, *args)
577
578         config.misc.epgcache_outdated_timespan.addNotifier(setOutdatedEPGTimespan)
579         config.misc.epgcache_timespan.addNotifier(setEPGCacheTimespan)
580         config.misc.epgcache_filename.addNotifier(setEPGCachePath)
581
582         api.setSession(session)
583
584         runNextScreen(session, screensToRun)
585
586         profile("Init:VolumeControl")
587         vol = VolumeControl(session)
588         profile("Init:PowerKey")
589         power = PowerKey(session)
590
591         # we need session.scart to access it from within menu.xml
592         session.scart = AutoScartControl(session)
593
594         profile("RunReactor")
595         profile_final()
596         runReactor()
597
598         while session.current_dialog:
599                 if not isinstance(session.current_dialog, Screens.InfoBar.InfoBar):
600                         session.current_dialog.callback = None
601                 Screen.close(session.current_dialog)
602                 session.processDelay()
603
604         config.misc.startCounter.save()
605
606         profile("wakeup")
607         from time import time, strftime, localtime
608         from Tools.DreamboxHardware import setFPWakeuptime, getFPWakeuptime, setRTCtime
609         #get currentTime
610         nowTime = time()
611         wakeup_on_zaptimers = config.usage.standby_zaptimer_wakeup.value
612         wakeupList = [
613                 x for x in ((session.nav.RecordTimer.getNextRecordingTime(), 0, session.nav.RecordTimer.isNextRecordAfterEventActionAuto()),
614                                         (session.nav.RecordTimer.getNextZapTime(), 1),
615                                         (plugins.getNextWakeupTime(), 2))
616                 if x[0] != -1 and (x[1] != 1 or wakeup_on_zaptimers)
617         ]
618         wakeupList.sort()
619         recordTimerWakeupAuto = False
620         if wakeupList:
621                 from time import strftime
622                 startTime = wakeupList[0]
623                 if (startTime[0] - nowTime) < 270: # no time to switch box back on
624                         wptime = nowTime + 30  # so switch back on in 30 seconds
625                 else:
626                         wptime = startTime[0] - 240
627                 if not config.misc.useTransponderTime.value:
628                         print "dvb time sync disabled... so set RTC now to current linux time!", strftime("%Y/%m/%d %H:%M", localtime(nowTime))
629                         setRTCtime(nowTime)
630                 print "set wakeup time to", strftime("%Y/%m/%d %H:%M", localtime(wptime))
631                 setFPWakeuptime(wptime)
632                 recordTimerWakeupAuto = startTime[1] == 0 and startTime[2]
633                 config.misc.prev_wakeup_time.value = startTime[0]
634         else:
635                 config.misc.prev_wakeup_time.value = 0
636         config.misc.prev_wakeup_time.save()
637         config.misc.isNextRecordTimerAfterEventActionAuto.value = recordTimerWakeupAuto
638         config.misc.isNextRecordTimerAfterEventActionAuto.save()
639
640         profile("stopService")
641         session.nav.stopService()
642         profile("nav shutdown")
643         session.nav.shutdown()
644
645         profile("configfile.save")
646         configfile.save()
647
648         return 0
649
650 profile("Init:skin")
651 import skin
652 skin.loadSkinData(getDesktop(0))
653
654 profile("InputDevice")
655 import Components.InputDevice
656 Components.InputDevice.InitInputDevices()
657
658 profile("AVSwitch")
659 import Components.AVSwitch
660 Components.AVSwitch.InitAVSwitch()
661
662 profile("RecordingConfig")
663 import Components.RecordingConfig
664 Components.RecordingConfig.InitRecordingConfig()
665
666 profile("UsageConfig")
667 import Components.UsageConfig
668 Components.UsageConfig.BaseInitUsageConfig()
669 language.addCallback(Components.UsageConfig.FinalInitUsageConfig)
670
671 profile("keymapparser")
672 import keymapparser
673 keymapparser.readKeymap(config.usage.keymap.value)
674
675 profile("Network")
676 from Components.Network import iNetwork
677
678 profile("LCD")
679 import Components.Lcd
680 Components.Lcd.InitLcd()
681
682 profile("SetupDevices")
683 import Components.SetupDevices
684 Components.SetupDevices.InitSetupDevices()
685
686 profile("RFMod")
687 import Components.RFmod
688 Components.RFmod.InitRFmod()
689
690 profile("Init:CI")
691 import Screens.Ci
692 Screens.Ci.InitCiConfig()
693
694 #from enigma import dump_malloc_stats
695 #t = eTimer()
696 #t.callback.append(dump_malloc_stats)
697 #t.start(1000)
698
699 # first, setup a screen
700 try:
701         runScreenTest()
702
703         plugins.shutdown()
704
705         from Components.ParentalControl import parentalControl
706         parentalControl.save()
707 except:
708         print 'EXCEPTION IN PYTHON STARTUP CODE:'
709         print '-'*60
710         print_exc(file=stdout)
711         quitMainloop(5)
712         print '-'*60