add Input 1 .. 16 to committed diseqc command selection in advanced sat config
[enigma2.git] / lib / python / Components / ServiceScan.py
1 from enigma import eComponentScan, eDVBFrontendParametersSatellite, eDVBFrontendParametersCable, eDVBFrontendParametersTerrestrial
2
3 class ServiceScan:
4         
5         Idle = 1
6         Running = 2
7         Done = 3
8         Error = 4
9         
10         Errors = { 
11                 0: "error starting scanning",
12                 1: "error while scanning",
13                 2: "no resource manager",
14                 3: "no channel list"
15                 }
16         
17         def scanStatusChanged(self):
18                 if self.state == self.Running:
19                         self.progressbar.setValue(self.scan.getProgress())
20                         if self.scan.isDone():
21                                 errcode = self.scan.getError()
22                                 
23                                 if errcode == 0:
24                                         self.state = self.Done
25                                 else:
26                                         self.state = self.Error
27                                         self.errorcode = errcode
28                         else:
29                                 self.text.setText(_("scan in progress - %d %% done!\n%d services found!") % (self.scan.getProgress(), self.scan.getNumServices()))
30                 
31                 if self.state == self.Done:
32                         if self.scan.getNumServices() == 1:
33                                 self.text.setText(_("scan done!\nOne service found!"))
34                         elif self.scan.getNumServices() == 0:
35                                 self.text.setText(_("scan done!\nNo service found!"))
36                         else:
37                                 self.text.setText(_("scan done!\n%d services found!") % (self.scan.getNumServices()))
38                 
39                 if self.state == self.Error:
40                         self.text.setText(_("ERROR - failed to scan (%s)!") % (self.Errors[self.errorcode]) )
41         
42         def __init__(self, progressbar, text, servicelist, transponders, feid, flags):
43                 self.progressbar = progressbar
44                 self.text = text
45                 self.scan = eComponentScan()
46                 self.state = self.Idle
47                 self.feid = feid
48                 self.flags = flags
49                 self.servicelist = servicelist
50                 self.scanStatusChanged()
51                 
52                 for x in transponders:
53                         self.scan.addInitial(x)
54                 
55                 #self.scan.addInitial(parm)
56                 
57         def execBegin(self):
58                 self.scan.statusChanged.get().append(self.scanStatusChanged)
59                 self.scan.newService.get().append(self.newService)
60                 self.state = self.Running
61                 err = self.scan.start(self.feid, self.flags)
62                 if err:
63                         self.state = self.Error
64                         self.errorcode = 0
65
66                 self.scanStatusChanged()
67         
68         def execEnd(self):
69                 self.scan.statusChanged.get().remove(self.scanStatusChanged)
70                 self.scan.newService.get().remove(self.newService)
71                 if not self.isDone():
72                         print "*** warning *** scan was not finished!"
73                 
74                 del self.scan
75
76         def isDone(self):
77                 return self.state == self.Done or self.state == self.Error
78
79         def newService(self):
80                 newServiceName = self.scan.getLastServiceName()
81                 self.servicelist.addItem(newServiceName)