From 1c6c579ff6302c3301eb21bd0933d5ede824a384 Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Mon, 2 Jun 2008 12:08:26 +0000 Subject: [PATCH] add DefaultServicesScanner plugin to do automatic services scans and build a lamedb and .info file for every sat (stored in /tmp) --- configure.ac | 1 + .../DefaultServicesScanner/Makefile.am | 6 + .../DefaultServicesScanner/__init__.py | 0 .../DefaultServicesScanner/plugin.py | 129 ++++++++++++++++++ lib/python/Plugins/SystemPlugins/Makefile.am | 2 +- 5 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 lib/python/Plugins/SystemPlugins/DefaultServicesScanner/Makefile.am create mode 100644 lib/python/Plugins/SystemPlugins/DefaultServicesScanner/__init__.py create mode 100644 lib/python/Plugins/SystemPlugins/DefaultServicesScanner/plugin.py diff --git a/configure.ac b/configure.ac index 156f34ec..8cb18fd3 100644 --- a/configure.ac +++ b/configure.ac @@ -109,6 +109,7 @@ lib/python/Plugins/SystemPlugins/FrontprocessorUpgrade/Makefile lib/python/Plugins/SystemPlugins/PositionerSetup/Makefile lib/python/Plugins/SystemPlugins/Hotplug/Makefile lib/python/Plugins/SystemPlugins/ConfigurationBackup/Makefile +lib/python/Plugins/SystemPlugins/DefaultServicesScanner/Makefile lib/python/Plugins/SystemPlugins/Satfinder/Makefile lib/python/Plugins/SystemPlugins/SkinSelector/Makefile lib/python/Plugins/SystemPlugins/SatelliteEquipmentControl/Makefile diff --git a/lib/python/Plugins/SystemPlugins/DefaultServicesScanner/Makefile.am b/lib/python/Plugins/SystemPlugins/DefaultServicesScanner/Makefile.am new file mode 100644 index 00000000..1d3b2f92 --- /dev/null +++ b/lib/python/Plugins/SystemPlugins/DefaultServicesScanner/Makefile.am @@ -0,0 +1,6 @@ +installdir = $(LIBDIR)/enigma2/python/Plugins/SystemPlugins/DefaultServicesScanner + +install_PYTHON = \ + __init__.py \ + plugin.py + diff --git a/lib/python/Plugins/SystemPlugins/DefaultServicesScanner/__init__.py b/lib/python/Plugins/SystemPlugins/DefaultServicesScanner/__init__.py new file mode 100644 index 00000000..e69de29b 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) diff --git a/lib/python/Plugins/SystemPlugins/Makefile.am b/lib/python/Plugins/SystemPlugins/Makefile.am index a82601f6..a4de55e6 100644 --- a/lib/python/Plugins/SystemPlugins/Makefile.am +++ b/lib/python/Plugins/SystemPlugins/Makefile.am @@ -1 +1 @@ -SUBDIRS = SoftwareUpdate FrontprocessorUpgrade PositionerSetup ConfigurationBackup Satfinder SkinSelector SatelliteEquipmentControl Videomode VideoTune Hotplug +SUBDIRS = SoftwareUpdate FrontprocessorUpgrade PositionerSetup ConfigurationBackup Satfinder SkinSelector SatelliteEquipmentControl Videomode VideoTune Hotplug DefaultServicesScanner -- 2.30.2