Enigma2 plugin to to play various online streams (mostly Latvian).

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851
  1. import sys
  2. import os
  3. from time import time
  4. if os.path.isfile("/usr/lib/enigma2/python/enigma.zip"):
  5. sys.path.append("/usr/lib/enigma2/python/enigma.zip")
  6. from Tools.Profile import profile, profile_final
  7. profile("PYTHON_START")
  8. import Tools.RedirectOutput
  9. import enigma
  10. from boxbranding import getBoxType, getBrandOEM, getMachineBuild
  11. import eConsoleImpl
  12. import eBaseImpl
  13. enigma.eTimer = eBaseImpl.eTimer
  14. enigma.eSocketNotifier = eBaseImpl.eSocketNotifier
  15. enigma.eConsoleAppContainer = eConsoleImpl.eConsoleAppContainer
  16. boxtype = getBoxType()
  17. if os.path.isfile("/usr/lib/enigma2/python/Plugins/Extensions/MediaPortal/plugin.pyo") and boxtype in ('dm7080','dm820'):
  18. import pyo_patcher
  19. from traceback import print_exc
  20. profile("SimpleSummary")
  21. from Screens import InfoBar
  22. from Screens.SimpleSummary import SimpleSummary
  23. from sys import stdout, exc_info
  24. profile("Bouquets")
  25. from Components.config import config, configfile, ConfigText, ConfigYesNo, ConfigInteger, NoSave
  26. config.misc.load_unlinked_userbouquets = ConfigYesNo(default=False)
  27. def setLoadUnlinkedUserbouquets(configElement):
  28. enigma.eDVBDB.getInstance().setLoadUnlinkedUserbouquets(configElement.value)
  29. config.misc.load_unlinked_userbouquets.addNotifier(setLoadUnlinkedUserbouquets)
  30. enigma.eDVBDB.getInstance().reloadBouquets()
  31. profile("ParentalControl")
  32. import Components.ParentalControl
  33. Components.ParentalControl.InitParentalControl()
  34. profile("LOAD:Navigation")
  35. from Navigation import Navigation
  36. profile("LOAD:skin")
  37. from skin import readSkin
  38. profile("LOAD:Tools")
  39. from Tools.Directories import InitFallbackFiles, resolveFilename, SCOPE_PLUGINS, SCOPE_ACTIVE_SKIN, SCOPE_CURRENT_SKIN, SCOPE_CONFIG
  40. from Components.config import config, configfile, ConfigText, ConfigYesNo, ConfigInteger, ConfigSelection, NoSave
  41. import Components.RecordingConfig
  42. InitFallbackFiles()
  43. profile("config.misc")
  44. config.misc.boxtype = ConfigText(default = boxtype)
  45. config.misc.blackradiopic = ConfigText(default = resolveFilename(SCOPE_ACTIVE_SKIN, "black.mvi"))
  46. radiopic = resolveFilename(SCOPE_ACTIVE_SKIN, "radio.mvi")
  47. if os.path.exists(resolveFilename(SCOPE_CONFIG, "radio.mvi")):
  48. radiopic = resolveFilename(SCOPE_CONFIG, "radio.mvi")
  49. config.misc.radiopic = ConfigText(default = radiopic)
  50. #config.misc.isNextRecordTimerAfterEventActionAuto = ConfigYesNo(default=False)
  51. #config.misc.isNextPowerTimerAfterEventActionAuto = ConfigYesNo(default=False)
  52. config.misc.nextWakeup = ConfigText(default = "-1,-1,0,0,-1,0") #wakeup time, timer begins, set by (0=rectimer,1=zaptimer, 2=powertimer or 3=plugin), go in standby, next rectimer, force rectimer
  53. config.misc.SyncTimeUsing = ConfigSelection(default = "0", choices = [("0", "Transponder Time"), ("1", _("NTP"))])
  54. config.misc.NTPserver = ConfigText(default = 'pool.ntp.org', fixed_size=False)
  55. config.misc.startCounter = ConfigInteger(default=0) # number of e2 starts...
  56. config.misc.standbyCounter = NoSave(ConfigInteger(default=0)) # number of standby
  57. config.misc.DeepStandby = NoSave(ConfigYesNo(default=False)) # detect deepstandby
  58. #demo code for use of standby enter leave callbacks
  59. #def leaveStandby():
  60. # print "!!!!!!!!!!!!!!!!!leave standby"
  61. #def standbyCountChanged(configelement):
  62. # print "!!!!!!!!!!!!!!!!!enter standby num", configelement.value
  63. # from Screens.Standby import inStandby
  64. # inStandby.onClose.append(leaveStandby)
  65. #config.misc.standbyCounter.addNotifier(standbyCountChanged, initial_call = False)
  66. ####################################################
  67. def useSyncUsingChanged(configelement):
  68. if config.misc.SyncTimeUsing.value == "0":
  69. print "[Time By]: Transponder"
  70. enigma.eDVBLocalTimeHandler.getInstance().setUseDVBTime(True)
  71. enigma.eEPGCache.getInstance().timeUpdated()
  72. else:
  73. print "[Time By]: NTP"
  74. enigma.eDVBLocalTimeHandler.getInstance().setUseDVBTime(False)
  75. enigma.eEPGCache.getInstance().timeUpdated()
  76. config.misc.SyncTimeUsing.addNotifier(useSyncUsingChanged)
  77. def NTPserverChanged(configelement):
  78. if config.misc.NTPserver.value == "pool.ntp.org":
  79. return
  80. print "[NTPDATE] save /etc/default/ntpdate"
  81. f = open("/etc/default/ntpdate", "w")
  82. f.write('NTPSERVERS="' + config.misc.NTPserver.value + '"')
  83. f.close()
  84. os.chmod("/etc/default/ntpdate", 0755)
  85. from Components.Console import Console
  86. Console = Console()
  87. Console.ePopen('/usr/bin/ntpdate-sync')
  88. config.misc.NTPserver.addNotifier(NTPserverChanged, immediate_feedback = True)
  89. profile("Twisted")
  90. try:
  91. import e2reactor
  92. e2reactor.install()
  93. from twisted.internet import reactor
  94. def runReactor():
  95. reactor.run(installSignalHandlers=False)
  96. except ImportError:
  97. print "twisted not available"
  98. def runReactor():
  99. enigma.runMainloop()
  100. profile("LOAD:Plugin")
  101. # initialize autorun plugins and plugin menu entries
  102. from Components.PluginComponent import plugins
  103. profile("LOAD:Wizard")
  104. from Screens.StartWizard import *
  105. import Screens.Rc
  106. from Tools.BoundFunction import boundFunction
  107. from Plugins.Plugin import PluginDescriptor
  108. profile("misc")
  109. had = dict()
  110. def dump(dir, p = ""):
  111. if isinstance(dir, dict):
  112. for (entry, val) in dir.items():
  113. dump(val, p + "(dict)/" + entry)
  114. if hasattr(dir, "__dict__"):
  115. for name, value in dir.__dict__.items():
  116. if not had.has_key(str(value)):
  117. had[str(value)] = 1
  118. dump(value, p + "/" + str(name))
  119. else:
  120. print p + "/" + str(name) + ":" + str(dir.__class__) + "(cycle)"
  121. else:
  122. print p + ":" + str(dir)
  123. # + ":" + str(dir.__class__)
  124. # display
  125. profile("LOAD:ScreenGlobals")
  126. from Screens.Globals import Globals
  127. from Screens.SessionGlobals import SessionGlobals
  128. from Screens.Screen import Screen
  129. profile("Screen")
  130. Screen.global_screen = Globals()
  131. # Session.open:
  132. # * push current active dialog ('current_dialog') onto stack
  133. # * call execEnd for this dialog
  134. # * clear in_exec flag
  135. # * hide screen
  136. # * instantiate new dialog into 'current_dialog'
  137. # * create screens, components
  138. # * read, apply skin
  139. # * create GUI for screen
  140. # * call execBegin for new dialog
  141. # * set in_exec
  142. # * show gui screen
  143. # * call components' / screen's onExecBegin
  144. # ... screen is active, until it calls 'close'...
  145. # Session.close:
  146. # * assert in_exec
  147. # * save return value
  148. # * start deferred close handler ('onClose')
  149. # * execEnd
  150. # * clear in_exec
  151. # * hide screen
  152. # .. a moment later:
  153. # Session.doClose:
  154. # * destroy screen
  155. class Session:
  156. def __init__(self, desktop = None, summary_desktop = None, navigation = None):
  157. self.desktop = desktop
  158. self.summary_desktop = summary_desktop
  159. self.nav = navigation
  160. self.delay_timer = enigma.eTimer()
  161. self.delay_timer.callback.append(self.processDelay)
  162. self.current_dialog = None
  163. self.dialog_stack = [ ]
  164. self.summary_stack = [ ]
  165. self.summary = None
  166. self.in_exec = False
  167. self.screen = SessionGlobals(self)
  168. for p in plugins.getPlugins(PluginDescriptor.WHERE_SESSIONSTART):
  169. try:
  170. p(reason=0, session=self)
  171. except:
  172. print "Plugin raised exception at WHERE_SESSIONSTART"
  173. import traceback
  174. traceback.print_exc()
  175. def processDelay(self):
  176. callback = self.current_dialog.callback
  177. retval = self.current_dialog.returnValue
  178. if self.current_dialog.isTmp:
  179. self.current_dialog.doClose()
  180. # dump(self.current_dialog)
  181. del self.current_dialog
  182. else:
  183. del self.current_dialog.callback
  184. self.popCurrent()
  185. if callback is not None:
  186. callback(*retval)
  187. def execBegin(self, first=True, do_show = True):
  188. assert not self.in_exec
  189. self.in_exec = True
  190. c = self.current_dialog
  191. # when this is an execbegin after a execend of a "higher" dialog,
  192. # popSummary already did the right thing.
  193. if first:
  194. self.instantiateSummaryDialog(c)
  195. c.saveKeyboardMode()
  196. c.execBegin()
  197. # when execBegin opened a new dialog, don't bother showing the old one.
  198. if c == self.current_dialog and do_show:
  199. c.show()
  200. def execEnd(self, last=True):
  201. assert self.in_exec
  202. self.in_exec = False
  203. self.current_dialog.execEnd()
  204. self.current_dialog.restoreKeyboardMode()
  205. self.current_dialog.hide()
  206. if last:
  207. self.current_dialog.removeSummary(self.summary)
  208. self.popSummary()
  209. def instantiateDialog(self, screen, *arguments, **kwargs):
  210. return self.doInstantiateDialog(screen, arguments, kwargs, self.desktop)
  211. def deleteDialog(self, screen):
  212. screen.hide()
  213. screen.doClose()
  214. def deleteDialogWithCallback(self, callback, screen, *retval):
  215. screen.hide()
  216. screen.doClose()
  217. if callback is not None:
  218. callback(*retval)
  219. def instantiateSummaryDialog(self, screen, **kwargs):
  220. self.pushSummary()
  221. summary = screen.createSummary() or SimpleSummary
  222. arguments = (screen,)
  223. self.summary = self.doInstantiateDialog(summary, arguments, kwargs, self.summary_desktop)
  224. self.summary.show()
  225. screen.addSummary(self.summary)
  226. def doInstantiateDialog(self, screen, arguments, kwargs, desktop):
  227. # create dialog
  228. dlg = screen(self, *arguments, **kwargs)
  229. if dlg is None:
  230. return
  231. # read skin data
  232. readSkin(dlg, None, dlg.skinName, desktop)
  233. # create GUI view of this dialog
  234. dlg.setDesktop(desktop)
  235. dlg.applySkin()
  236. return dlg
  237. def pushCurrent(self):
  238. if self.current_dialog is not None:
  239. self.dialog_stack.append((self.current_dialog, self.current_dialog.shown))
  240. self.execEnd(last=False)
  241. def popCurrent(self):
  242. if self.dialog_stack:
  243. (self.current_dialog, do_show) = self.dialog_stack.pop()
  244. self.execBegin(first=False, do_show=do_show)
  245. else:
  246. self.current_dialog = None
  247. def execDialog(self, dialog):
  248. self.pushCurrent()
  249. self.current_dialog = dialog
  250. self.current_dialog.isTmp = False
  251. self.current_dialog.callback = None # would cause re-entrancy problems.
  252. self.execBegin()
  253. def openWithCallback(self, callback, screen, *arguments, **kwargs):
  254. dlg = self.open(screen, *arguments, **kwargs)
  255. dlg.callback = callback
  256. return dlg
  257. def open(self, screen, *arguments, **kwargs):
  258. if self.dialog_stack and not self.in_exec:
  259. raise RuntimeError("modal open are allowed only from a screen which is modal!")
  260. # ...unless it's the very first screen.
  261. self.pushCurrent()
  262. dlg = self.current_dialog = self.instantiateDialog(screen, *arguments, **kwargs)
  263. dlg.isTmp = True
  264. dlg.callback = None
  265. self.execBegin()
  266. return dlg
  267. def close(self, screen, *retval):
  268. if not self.in_exec:
  269. print "close after exec!"
  270. return
  271. # be sure that the close is for the right dialog!
  272. # if it's not, you probably closed after another dialog
  273. # was opened. this can happen if you open a dialog
  274. # onExecBegin, and forget to do this only once.
  275. # after close of the top dialog, the underlying will
  276. # gain focus again (for a short time), thus triggering
  277. # the onExec, which opens the dialog again, closing the loop.
  278. assert screen == self.current_dialog
  279. self.current_dialog.returnValue = retval
  280. self.delay_timer.start(0, 1)
  281. self.execEnd()
  282. def pushSummary(self):
  283. if self.summary is not None:
  284. self.summary.hide()
  285. self.summary_stack.append(self.summary)
  286. self.summary = None
  287. def popSummary(self):
  288. if self.summary is not None:
  289. self.summary.doClose()
  290. self.summary = self.summary_stack.pop()
  291. if self.summary is not None:
  292. self.summary.show()
  293. profile("Standby,PowerKey")
  294. import Screens.Standby
  295. from Screens.Menu import MainMenu, mdom
  296. from GlobalActions import globalActionMap
  297. class PowerKey:
  298. """ PowerKey stuff - handles the powerkey press and powerkey release actions"""
  299. def __init__(self, session):
  300. self.session = session
  301. globalActionMap.actions["power_down"]=self.powerdown
  302. globalActionMap.actions["power_up"]=self.powerup
  303. globalActionMap.actions["power_long"]=self.powerlong
  304. globalActionMap.actions["deepstandby"]=self.shutdown # frontpanel long power button press
  305. globalActionMap.actions["discrete_off"]=self.standby
  306. globalActionMap.actions["sleeptimer"]=self.openSleepTimer
  307. globalActionMap.actions["powertimer_standby"]=self.sleepStandby
  308. globalActionMap.actions["powertimer_deepstandby"]=self.sleepDeepStandby
  309. self.standbyblocked = 1
  310. def MenuClosed(self, *val):
  311. self.session.infobar = None
  312. def shutdown(self):
  313. recordings = self.session.nav.getRecordingsCheckBeforeActivateDeepStandby()
  314. if recordings:
  315. from Screens.MessageBox import MessageBox
  316. self.session.openWithCallback(self.gotoStandby,MessageBox,_("Recording(s) are in progress or coming up in few seconds!\nEntering standby, after recording the box will shutdown."), type = MessageBox.TYPE_INFO, close_on_any_key = True, timeout = 10)
  317. elif not Screens.Standby.inTryQuitMainloop and self.session.current_dialog and self.session.current_dialog.ALLOW_SUSPEND:
  318. self.session.open(Screens.Standby.TryQuitMainloop, 1)
  319. def powerlong(self):
  320. if Screens.Standby.inTryQuitMainloop or (self.session.current_dialog and not self.session.current_dialog.ALLOW_SUSPEND):
  321. return
  322. self.doAction(action = config.usage.on_long_powerpress.value)
  323. def doAction(self, action):
  324. self.standbyblocked = 1
  325. if action == "shutdown":
  326. self.shutdown()
  327. elif action == "show_menu":
  328. print "Show shutdown Menu"
  329. root = mdom.getroot()
  330. for x in root.findall("menu"):
  331. y = x.find("id")
  332. if y is not None:
  333. id = y.get("val")
  334. if id and id == "shutdown":
  335. self.session.infobar = self
  336. menu_screen = self.session.openWithCallback(self.MenuClosed, MainMenu, x)
  337. menu_screen.setTitle(_("Standby / restart"))
  338. return
  339. elif action == "standby":
  340. self.standby()
  341. elif action == "powertimerStandby":
  342. val = 3
  343. self.setSleepTimer(val)
  344. elif action == "powertimerDeepStandby":
  345. val = 4
  346. self.setSleepTimer(val)
  347. elif action == "sleeptimer":
  348. self.openSleepTimer()
  349. def powerdown(self):
  350. self.standbyblocked = 0
  351. def powerup(self):
  352. if self.standbyblocked == 0:
  353. self.doAction(action = config.usage.on_short_powerpress.value)
  354. def gotoStandby(self, ret):
  355. self.standby()
  356. def standby(self):
  357. if not Screens.Standby.inStandby and self.session.current_dialog and self.session.current_dialog.ALLOW_SUSPEND and self.session.in_exec:
  358. self.session.open(Screens.Standby.Standby)
  359. def openSleepTimer(self):
  360. from Screens.SleepTimerEdit import SleepTimerEdit
  361. self.session.open(SleepTimerEdit)
  362. def setSleepTimer(self, val):
  363. from PowerTimer import PowerTimerEntry
  364. sleeptime = 15
  365. data = (int(time() + 60), int(time() + 120))
  366. self.addSleepTimer(PowerTimerEntry(checkOldTimers = True, *data, timerType = val, autosleepdelay = sleeptime))
  367. def addSleepTimer(self, timer):
  368. from Screens.PowerTimerEntry import TimerEntry
  369. self.session.openWithCallback(self.finishedAdd, TimerEntry, timer)
  370. def finishedAdd(self, answer):
  371. if answer[0]:
  372. entry = answer[1]
  373. simulTimerList = self.session.nav.PowerTimer.record(entry)
  374. def sleepStandby(self):
  375. self.doAction(action = "powertimerStandby")
  376. def sleepDeepStandby(self):
  377. self.doAction(action = "powertimerDeepStandby")
  378. profile("Scart")
  379. from Screens.Scart import Scart
  380. class AutoScartControl:
  381. def __init__(self, session):
  382. self.force = False
  383. self.current_vcr_sb = enigma.eAVSwitch.getInstance().getVCRSlowBlanking()
  384. if self.current_vcr_sb and config.av.vcrswitch.value:
  385. self.scartDialog = session.instantiateDialog(Scart, True)
  386. else:
  387. self.scartDialog = session.instantiateDialog(Scart, False)
  388. config.av.vcrswitch.addNotifier(self.recheckVCRSb)
  389. enigma.eAVSwitch.getInstance().vcr_sb_notifier.get().append(self.VCRSbChanged)
  390. def recheckVCRSb(self, configelement):
  391. self.VCRSbChanged(self.current_vcr_sb)
  392. def VCRSbChanged(self, value):
  393. #print "vcr sb changed to", value
  394. self.current_vcr_sb = value
  395. if config.av.vcrswitch.value or value > 2:
  396. if value:
  397. self.scartDialog.showMessageBox()
  398. else:
  399. self.scartDialog.switchToTV()
  400. profile("Load:CI")
  401. from Screens.Ci import CiHandler
  402. profile("Load:VolumeControl")
  403. from Components.VolumeControl import VolumeControl
  404. from time import time, localtime, strftime
  405. from Tools.StbHardware import setFPWakeuptime, setRTCtime
  406. def autorestoreLoop():
  407. # Check if auto restore settings fails, just start the wizard (avoid a endless loop)
  408. count = 0
  409. if os.path.exists("/media/hdd/images/config/autorestore"):
  410. f = open("/media/hdd/images/config/autorestore", "r")
  411. try:
  412. count = int(f.read())
  413. except:
  414. count = 0;
  415. f.close()
  416. if count >= 3:
  417. return False
  418. count += 1
  419. f = open("/media/hdd/images/config/autorestore", "w")
  420. f.write(str(count))
  421. f.close()
  422. return True
  423. def runScreenTest():
  424. config.misc.startCounter.value += 1
  425. profile("readPluginList")
  426. plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
  427. profile("Init:Session")
  428. nav = Navigation(config.misc.nextWakeup.value)
  429. session = Session(desktop = enigma.getDesktop(0), summary_desktop = enigma.getDesktop(1), navigation = nav)
  430. CiHandler.setSession(session)
  431. profile("wizards")
  432. screensToRun = []
  433. RestoreSettings = None
  434. if os.path.exists("/media/hdd/images/config/settings") and config.misc.firstrun.value:
  435. if autorestoreLoop():
  436. RestoreSettings = True
  437. from Plugins.SystemPlugins.SoftwareManager.BackupRestore import RestoreScreen
  438. session.open(RestoreScreen, runRestore = True)
  439. else:
  440. screensToRun = [ p.__call__ for p in plugins.getPlugins(PluginDescriptor.WHERE_WIZARD) ]
  441. screensToRun += wizardManager.getWizards()
  442. else:
  443. if os.path.exists("/media/hdd/images/config/autorestore"):
  444. os.system('rm -f /media/hdd/images/config/autorestore')
  445. screensToRun = [ p.__call__ for p in plugins.getPlugins(PluginDescriptor.WHERE_WIZARD) ]
  446. screensToRun += wizardManager.getWizards()
  447. screensToRun.append((100, InfoBar.InfoBar))
  448. screensToRun.sort()
  449. print screensToRun
  450. enigma.ePythonConfigQuery.setQueryFunc(configfile.getResolvedKey)
  451. def runNextScreen(session, screensToRun, *result):
  452. if result:
  453. print "[mytest.py] quitMainloop #3"
  454. enigma.quitMainloop(*result)
  455. return
  456. screen = screensToRun[0][1]
  457. args = screensToRun[0][2:]
  458. if screensToRun:
  459. session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen, *args)
  460. else:
  461. session.open(screen, *args)
  462. if not RestoreSettings:
  463. runNextScreen(session, screensToRun)
  464. profile("Init:VolumeControl")
  465. vol = VolumeControl(session)
  466. profile("Init:PowerKey")
  467. power = PowerKey(session)
  468. if boxtype in ('sf3038', 'spycat', 'e4hd', 'e4hdhybrid', 'mbmicro', 'et7500', 'mixosf5', 'mixosf7', 'mixoslumi', 'gi9196m', 'maram9', 'ixussone', 'ixussone', 'uniboxhd1', 'uniboxhd2', 'uniboxhd3', 'sezam5000hd', 'mbtwin', 'sezam1000hd', 'mbmini', 'atemio5x00', 'beyonwizt3') or getBrandOEM() in ('fulan') or getMachineBuild() in ('dags7362' , 'dags5'):
  469. profile("VFDSYMBOLS")
  470. import Components.VfdSymbols
  471. Components.VfdSymbols.SymbolsCheck(session)
  472. # we need session.scart to access it from within menu.xml
  473. session.scart = AutoScartControl(session)
  474. profile("Init:Trashcan")
  475. import Tools.Trashcan
  476. Tools.Trashcan.init(session)
  477. profile("Init:AutoVideoMode")
  478. import Screens.VideoMode
  479. Screens.VideoMode.autostart(session)
  480. profile("RunReactor")
  481. profile_final()
  482. if boxtype in ('sf8', 'classm', 'axodin', 'axodinc', 'starsatlx', 'genius', 'evo'):
  483. f = open("/dev/dbox/oled0", "w")
  484. f.write('-E2-')
  485. f.close()
  486. print "lastshutdown=%s (True = last shutdown was OK)" % config.usage.shutdownOK.value
  487. print "NOK shutdown action=%s" % config.usage.shutdownNOK_action.value
  488. print "bootup action=%s" % config.usage.boot_action.value
  489. if not config.usage.shutdownOK.value and not config.usage.shutdownNOK_action.value == 'normal' or not config.usage.boot_action.value == 'normal':
  490. print "last shutdown = %s" % config.usage.shutdownOK.value
  491. import Screens.PowerLost
  492. Screens.PowerLost.PowerLost(session)
  493. config.usage.shutdownOK.setValue(False)
  494. config.usage.shutdownOK.save()
  495. if not RestoreSettings:
  496. configfile.save()
  497. runReactor()
  498. print "[mytest.py] normal shutdown"
  499. config.misc.startCounter.save()
  500. config.usage.shutdownOK.setValue(True)
  501. config.usage.shutdownOK.save()
  502. profile("wakeup")
  503. #get currentTime
  504. nowTime = time()
  505. # if not config.misc.SyncTimeUsing.value == "0" or getBrandOEM() == 'gigablue':
  506. if not config.misc.SyncTimeUsing.value == "0" or boxtype.startswith('gb') or getBrandOEM().startswith('ini'):
  507. print "dvb time sync disabled... so set RTC now to current linux time!", strftime("%Y/%m/%d %H:%M", localtime(nowTime))
  508. setRTCtime(nowTime)
  509. #recordtimer
  510. if session.nav.isRecordTimerImageStandard: #check RecordTimer instance
  511. tmp = session.nav.RecordTimer.getNextRecordingTime(getNextStbPowerOn = True)
  512. nextRecordTime = tmp[0]
  513. nextRecordTimeInStandby = tmp[1]
  514. else:
  515. nextRecordTime = session.nav.RecordTimer.getNextRecordingTime()
  516. nextRecordTimeInStandby = session.nav.RecordTimer.isNextRecordAfterEventActionAuto()
  517. #zaptimer
  518. nextZapTime = session.nav.RecordTimer.getNextZapTime()
  519. nextZapTimeInStandby = 0
  520. #powertimer
  521. tmp = session.nav.PowerTimer.getNextPowerManagerTime(getNextStbPowerOn = True)
  522. nextPowerTime = tmp[0]
  523. nextPowerTimeInStandby = tmp[1]
  524. #plugintimer
  525. tmp = plugins.getNextWakeupTime(getPluginIdent = True)
  526. nextPluginTime = tmp[0]
  527. nextPluginIdent = tmp[1] #"pluginname | pluginfolder"
  528. tmp = tmp[1].lower()
  529. #start in standby, depending on plugin type
  530. if "epgrefresh" in tmp:
  531. nextPluginName = "EPGRefresh"
  532. nextPluginTimeInStandby = 1
  533. elif "vps" in tmp:
  534. nextPluginName = "VPS"
  535. nextPluginTimeInStandby = 1
  536. elif "serienrecorder" in tmp:
  537. nextPluginName = "SerienRecorder"
  538. nextPluginTimeInStandby = 0 # plugin function for deep standby from standby not compatible (not available)
  539. elif "elektro" in tmp:
  540. nextPluginName = "Elektro"
  541. nextPluginTimeInStandby = 1
  542. elif "minipowersave" in tmp:
  543. nextPluginName = "MiniPowersave"
  544. nextPluginTimeInStandby = 1
  545. elif "enhancedpowersave" in tmp:
  546. nextPluginName = "EnhancedPowersave"
  547. nextPluginTimeInStandby = 1
  548. else:
  549. #default for plugins
  550. nextPluginName = nextPluginIdent
  551. nextPluginTimeInStandby = 0
  552. wakeupList = [
  553. x for x in ((nextRecordTime, 0, nextRecordTimeInStandby),
  554. (nextZapTime, 1, nextZapTimeInStandby),
  555. (nextPowerTime, 2, nextPowerTimeInStandby),
  556. (nextPluginTime, 3, nextPluginTimeInStandby))
  557. if x[0] != -1
  558. ]
  559. wakeupList.sort()
  560. # individual wakeup time offset
  561. if config.workaround.wakeuptimeoffset.value == "standard":
  562. if boxtype.startswith("gb"):
  563. wpoffset = -120 # Gigaboxes already starts 2 min. before wakeup time
  564. else:
  565. wpoffset = 0
  566. else:
  567. wpoffset = int(config.workaround.wakeuptimeoffset.value)
  568. print "="*100
  569. if wakeupList and wakeupList[0][0] > 0:
  570. startTime = wakeupList[0]
  571. # wakeup time is 5 min before timer starts + offset
  572. wptime = startTime[0] - 300 - wpoffset
  573. if (wptime - nowTime) < 120: # no time to switch box back on
  574. wptime = int(nowTime) + 120 # so switch back on in 120 seconds
  575. #check for plugin-, zap- or power-timer to enable the 'forced' record-timer wakeup
  576. forceNextRecord = 0
  577. setStandby = startTime[2]
  578. if startTime[1] != 0 and nextRecordTime > 0:
  579. #when next record starts in 15 mins
  580. if abs(nextRecordTime - startTime[0]) <= 900:
  581. setStandby = forceNextRecord = 1
  582. #by vps-plugin
  583. elif startTime[1] == 3 and nextPluginName == "VPS":
  584. setStandby = forceNextRecord = 1
  585. if startTime[1] == 3:
  586. nextPluginName = " (%s)" % nextPluginName
  587. else:
  588. nextPluginName = ""
  589. print "[mytest.py] set next wakeup type to '%s'%s %s" % ({0:"record-timer",1:"zap-timer",2:"power-timer",3:"plugin-timer"}[startTime[1]], nextPluginName, {0:"and starts normal",1:"and starts in standby"}[setStandby])
  590. if forceNextRecord:
  591. print "[mytest.py] set from 'vps-plugin' or just before a 'record-timer' starts, set 'record-timer' wakeup flag"
  592. print "[mytest.py] set next wakeup time to", strftime("%a, %Y/%m/%d %H:%M:%S", localtime(wptime))
  593. #set next wakeup
  594. setFPWakeuptime(wptime)
  595. #set next standby only after shutdown in deep standby
  596. if Screens.Standby.quitMainloopCode != 1 and Screens.Standby.quitMainloopCode != 45:
  597. setStandby = 2 # 0=no standby, but get in standby if wakeup to timer start > 60 sec (not for plugin-timer, here is no standby), 1=standby, 2=no standby, when before was not in deep-standby
  598. config.misc.nextWakeup.value = "%d,%d,%d,%d,%d,%d" % (wptime,startTime[0],startTime[1],setStandby,nextRecordTime,forceNextRecord)
  599. else:
  600. config.misc.nextWakeup.value = "-1,-1,0,0,-1,0"
  601. setFPWakeuptime(int(nowTime) - 3600) #minus one hour -> overwrite old wakeup time
  602. print "[mytest.py] no set next wakeup time"
  603. config.misc.nextWakeup.save()
  604. print "="*100
  605. profile("stopService")
  606. session.nav.stopService()
  607. profile("nav shutdown")
  608. session.nav.shutdown()
  609. profile("configfile.save")
  610. configfile.save()
  611. from Screens import InfoBarGenerics
  612. InfoBarGenerics.saveResumePoints()
  613. return 0
  614. profile("Init:skin")
  615. import skin
  616. skin.loadSkinData(enigma.getDesktop(0))
  617. profile("InputDevice")
  618. import Components.InputDevice
  619. Components.InputDevice.InitInputDevices()
  620. import Components.InputHotplug
  621. profile("SetupDevices")
  622. import Components.SetupDevices
  623. Components.SetupDevices.InitSetupDevices()
  624. profile("AVSwitch")
  625. import Components.AVSwitch
  626. Components.AVSwitch.InitAVSwitch()
  627. Components.AVSwitch.InitiVideomodeHotplug()
  628. profile("RecordingConfig")
  629. import Components.RecordingConfig
  630. Components.RecordingConfig.InitRecordingConfig()
  631. profile("UsageConfig")
  632. import Components.UsageConfig
  633. Components.UsageConfig.InitUsageConfig()
  634. profile("Init:DebugLogCheck")
  635. import Screens.LogManager
  636. Screens.LogManager.AutoLogManager()
  637. #profile("Init:OnlineCheckState")
  638. #import Components.OnlineUpdateCheck
  639. #Components.OnlineUpdateCheck.OnlineUpdateCheck()
  640. profile("Init:NTPSync")
  641. import Components.NetworkTime
  642. Components.NetworkTime.AutoNTPSync()
  643. profile("keymapparser")
  644. import keymapparser
  645. keymapparser.readKeymap(config.usage.keymap.value)
  646. profile("Network")
  647. import Components.Network
  648. Components.Network.InitNetwork()
  649. profile("LCD")
  650. import Components.Lcd
  651. Components.Lcd.InitLcd()
  652. Components.Lcd.IconCheck()
  653. # Disable internal clock vfd for ini5000 until we can adjust it for standby
  654. if boxtype in ('uniboxhd1', 'uniboxhd2', 'uniboxhd3', 'sezam5000hd', 'mbtwin', 'beyonwizt3'):
  655. try:
  656. f = open("/proc/stb/fp/enable_clock", "r").readline()[:-1]
  657. if f != '0':
  658. f = open("/proc/stb/fp/enable_clock", "w")
  659. f.write('0')
  660. f.close()
  661. except:
  662. print "Error disable enable_clock for ini5000 boxes"
  663. if boxtype in ('dm7080', 'dm820'):
  664. f=open("/proc/stb/hdmi-rx/0/hdmi_rx_monitor","r")
  665. check=f.read()
  666. f.close()
  667. if check.startswith("on"):
  668. f=open("/proc/stb/hdmi-rx/0/hdmi_rx_monitor","w")
  669. f.write("off")
  670. f.close()
  671. f=open("/proc/stb/audio/hdmi_rx_monitor","r")
  672. check=f.read()
  673. f.close()
  674. if check.startswith("on"):
  675. f=open("/proc/stb/audio/hdmi_rx_monitor","w")
  676. f.write("off")
  677. f.close()
  678. profile("UserInterface")
  679. import Screens.UserInterfacePositioner
  680. Screens.UserInterfacePositioner.InitOsd()
  681. profile("EpgCacheSched")
  682. import Components.EpgLoadSave
  683. Components.EpgLoadSave.EpgCacheSaveCheck()
  684. Components.EpgLoadSave.EpgCacheLoadCheck()
  685. profile("RFMod")
  686. import Components.RFmod
  687. Components.RFmod.InitRFmod()
  688. profile("Init:CI")
  689. import Screens.Ci
  690. Screens.Ci.InitCiConfig()
  691. profile("RcModel")
  692. import Components.RcModel
  693. #from enigma import dump_malloc_stats
  694. #t = eTimer()
  695. #t.callback.append(dump_malloc_stats)
  696. #t.start(1000)
  697. # first, setup a screen
  698. try:
  699. runScreenTest()
  700. plugins.shutdown()
  701. Components.ParentalControl.parentalControl.save()
  702. except:
  703. print 'EXCEPTION IN PYTHON STARTUP CODE:'
  704. print '-'*60
  705. print_exc(file=stdout)
  706. print "[mytest.py] quitMainloop #4"
  707. enigma.quitMainloop(5)
  708. print '-'*60