Merge branch 'bug_615_replace_rawfile' into experimental
[enigma2.git] / lib / python / Screens / ScanSetup.py
index f482808832ad30b60f29ddcb19eb3a2fb28c88a3..f9263d82b523ccd4976d8a9a0c8ef7ff860d0215 100644 (file)
@@ -107,6 +107,7 @@ class CableTransponderSearchSupport:
                        if raw_channel:
                                frontend = raw_channel.getFrontend()
                                if frontend:
+                                       frontend.closeFrontend() # immediate close... 
                                        del frontend
                                        del raw_channel
                                        return True
@@ -114,13 +115,16 @@ class CableTransponderSearchSupport:
 
        def cableTransponderSearchSessionClosed(self, *val):
                print "cableTransponderSearchSessionClosed, val", val
-               self.resetTimeout()
                self.cable_search_container.appClosed.remove(self.cableTransponderSearchClosed)
                self.cable_search_container.dataAvail.remove(self.getCableTransponderData)
+               if val and len(val):
+                       if val[0]:
+                               self.setCableTransponderSearchResult(self.__tlist)
+                       else:
+                               self.cable_search_container.sendCtrlC()
+                               self.setCableTransponderSearchResult(None)
                self.cable_search_container = None
                self.cable_search_session = None
-               if val and len(val) and val[0]:
-                       self.setCableTransponderSearchResult(self.__tlist)
                self.__tlist = None
                self.cableTransponderSearchFinished()
 
@@ -156,25 +160,12 @@ class CableTransponderSearchSupport:
                                parm.modulation = qam[data[4]]
                                parm.inversion = inv[data[5]]
                                self.__tlist.append(parm)
-               tmpstr = _("Try to find used Transponders in cable network.. please wait...")
-               tmpstr += "\n\n"
-               tmpstr += data[1]
-               tmpstr += " kHz "
-               tmpstr += data[0]
-               self.cable_search_session["text"].setText(tmpstr)
-               
-       def setTimeout(self):
-               try:
-                       self.oldtimeoutvalue = open("/sys/module/dvb_core/parameters/dvb_shutdown_timeout", "r").readline()
-                       open("/sys/module/dvb_core/parameters/dvb_shutdown_timeout", "w").write("0")
-               except:
-                       print "[info] no /sys/module/dvb_core/parameters/dvb_shutdown_timeout available"                
-               
-       def resetTimeout(self):
-               try:
-                       open("/sys/module/dvb_core/parameters/dvb_shutdown_timeout", "w").write(self.oldtimeoutvalue)
-               except:
-                       print "[info] no /sys/module/dvb_core/parameters/dvb_shutdown_timeout available"
+                       tmpstr = _("Try to find used Transponders in cable network.. please wait...")
+                       tmpstr += "\n\n"
+                       tmpstr += data[1]
+                       tmpstr += " kHz "
+                       tmpstr += data[0]
+                       self.cable_search_session["text"].setText(tmpstr)
 
        def startCableTransponderSearch(self, nim_idx):
                if not self.tryGetRawFrontend(nim_idx):
@@ -192,21 +183,16 @@ class CableTransponderSearchSupport:
                self.cable_search_container.dataAvail.append(self.getCableTransponderData)
                cableConfig = config.Nims[nim_idx].cable
                tunername = nimmanager.getNimName(nim_idx)
+               bus = nimmanager.getI2CDevice(nim_idx)
+               if bus is None:
+                       print "ERROR: could not get I2C device for nim", nim_idx, "for cable transponder search"
+                       bus = 2
+
                if tunername == "CXD1981":
-                       cmd = "cxd1978 --init --scan --verbose --wakeup --inv 2 --bus "
-               else:
-                       cmd = "tda1002x --init --scan --verbose --wakeup --inv 2 --bus "
-               #FIXMEEEEEE hardcoded i2c devices for dm7025 and dm8000
-               if nim_idx < 2:
-                       if HardwareInfo().get_device_name() == "dm500hd":
-                               cmd += "2"
-                       else:
-                               cmd += str(nim_idx)
+                       cmd = "cxd1978 --init --scan --verbose --wakeup --inv 2 --bus %d" % bus
                else:
-                       if nim_idx == 2:
-                               cmd += "2" # first nim socket on DM8000 use /dev/i2c/2
-                       else:
-                               cmd += "4" # second nim socket on DM8000 use /dev/i2c/4
+                       cmd = "tda1002x --init --scan --verbose --wakeup --inv 2 --bus %d" % bus
+               
                if cableConfig.scan_type.value == "bands":
                        cmd += " --scan-bands "
                        bands = 0
@@ -265,7 +251,6 @@ class CableTransponderSearchSupport:
                self.cable_search_container.execute(cmd)
                tmpstr = _("Try to find used transponders in cable network.. please wait...")
                tmpstr += "\n\n..."
-               self.setTimeout()
                self.cable_search_session = self.session.openWithCallback(self.cableTransponderSearchSessionClosed, MessageBox, tmpstr, MessageBox.TYPE_INFO)
 
 class DefaultSatLists(DefaultWizard):
@@ -850,7 +835,10 @@ class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
                self.tlist = tlist
 
        def cableTransponderSearchFinished(self):
-               self.startScan(self.tlist, self.flags, self.feid)
+               if self.tlist is None:
+                       self.tlist = []
+               else:
+                       self.startScan(self.tlist, self.flags, self.feid)
 
        def startScan(self, tlist, flags, feid):
                if len(tlist):
@@ -1016,7 +1004,8 @@ class ScanSimple(ConfigListScreen, Screen, CableTransponderSearchSupport):
                                self.session.open(MessageBox, _("Nothing to scan!\nPlease setup your tuner settings before you start a service scan."), MessageBox.TYPE_ERROR)
 
        def setCableTransponderSearchResult(self, tlist):
-               self.scanList.append({"transponders": tlist, "feid": self.feid, "flags": self.flags})
+               if tlist is not None:
+                       self.scanList.append({"transponders": tlist, "feid": self.feid, "flags": self.flags})
 
        def cableTransponderSearchFinished(self):
                self.buildTransponderList()