From 1c6c579ff6302c3301eb21bd0933d5ede824a384 Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Mon, 2 Jun 2008 12:08:26 +0000 Subject: add DefaultServicesScanner plugin to do automatic services scans and build a lamedb and .info file for every sat (stored in /tmp) --- .../SystemPlugins/DefaultServicesScanner/plugin.py | 129 +++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 lib/python/Plugins/SystemPlugins/DefaultServicesScanner/plugin.py (limited to 'lib/python/Plugins/SystemPlugins/DefaultServicesScanner/plugin.py') diff --git a/lib/python/Plugins/SystemPlugins/DefaultServicesScanner/plugin.py b/lib/python/Plugins/SystemPlugins/DefaultServicesScanner/plugin.py new file mode 100644 index 00000000..96ff43a0 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/DefaultServicesScanner/plugin.py @@ -0,0 +1,129 @@ +#from Components.ActionMap import ActionMap, NumberActionMap +#from Components.Input import Input +#from Components.Ipkg import IpkgComponent +#from Components.Label import Label +#from Components.MenuList import MenuList +#from Components.Slider import Slider +from Components.NimManager import nimmanager +from Plugins.Plugin import PluginDescriptor +from Screens.ScanSetup import ScanSetup +from Screens.ServiceScan import ServiceScan +from Screens.MessageBox import MessageBox +from Tools.Directories import resolveFilename, SCOPE_CONFIG +#from Screens.Screen import Screen +from enigma import eTimer, eDVBDB +import os + +class DefaultServiceScan(ServiceScan): + skin = """ + + + TYPE + 0,0 + + + + TYPE + 1,1 + + + + TYPE + 2,2 + + + + + + + + + """ + + def __init__(self, session, scanList): + os.system("rm " + resolveFilename(SCOPE_CONFIG) + "/lamedb") + db = eDVBDB.getInstance() + db.reloadServicelist() + ServiceScan.__init__(self, session, scanList) + self.timer = eTimer() + self.timer.callback.append(self.ok) + self.timer.start(1000) + +class DefaultServicesScannerPlugin(ScanSetup): + skin = """ + + + + """ + + def __init__(self, session, args = None): + ScanSetup.__init__(self, session) + # backup lamedb + os.system("cp " + resolveFilename(SCOPE_CONFIG) + "/lamedb " + resolveFilename(SCOPE_CONFIG) + "/lamedb.backup") + self.scan_type.value = "multisat" + self.createSetup() + self.scanIndex = 0 + self.selectSat(0) + self.onFirstExecBegin.append(self.runScan) + + def selectSat(self, index): + for satindex in range(len(self.multiscanlist)): + if satindex != index: + self.multiscanlist[satindex][1].value = False + else: + self.multiscanlist[satindex][1].value = True + + def runScan(self): + print "runScan" + self.keyGo() + + def startScan(self, tlist, flags, feid): + print "startScan" + if len(tlist): + # flags |= eComponentScan.scanSearchBAT + self.session.openWithCallback(self.scanFinished, DefaultServiceScan, [{"transponders": tlist, "feid": feid, "flags": flags}]) + else: + self.session.openWithCallback(self.scanFinished, MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR) + + def scanFinished(self, value = None): + print "finished" + db = eDVBDB.getInstance() + satint = self.multiscanlist[self.scanIndex][0] + print "scanned sat:", satint + db.saveServicelist("/tmp/lamedb." + str(satint)) + file = open("/tmp/sat" + str(satint) + ".info", "w") + xml = """ + + + + + + + + %s + %s + + + + + + +""" % (satint, "Dream", nimmanager.getSatDescription(satint), satint) + file.write(xml) + file.close() + + self.scanIndex += 1 + if self.scanIndex + 1 >= len(self.multiscanlist): + print "no more sats to scan" + os.system("cp " + resolveFilename(SCOPE_CONFIG) + "/lamedb.backup " + resolveFilename(SCOPE_CONFIG) + "/lamedb") + db.reloadServicelist() + self.close() + else: + self.selectSat(self.scanIndex) + self.keyGo() + +def DefaultServicesScannerMain(session, **kwargs): + session.open(DefaultServicesScannerPlugin) + +def Plugins(**kwargs): + return PluginDescriptor(name="Default Services Scanner", description=_("Scans default lamedbs sorted by satellite with a connected dish positioner"), where = PluginDescriptor.WHERE_PLUGINMENU, fnc=DefaultServicesScannerMain) -- cgit v1.2.3