1 diff --git a/lib/python/Plugins/SystemPlugins/TransCodingSetup/plugin.py b/lib/python/Plugins/SystemPlugins/TransCodingSetup/plugin.py
2 index 09ec093..f73da01 100755
3 --- a/lib/python/Plugins/SystemPlugins/TransCodingSetup/plugin.py
4 +++ b/lib/python/Plugins/SystemPlugins/TransCodingSetup/plugin.py
5 @@ -7,7 +7,7 @@ from Components.Sources.StaticText import StaticText
6 from Plugins.Plugin import PluginDescriptor
7 from Tools.Directories import fileExists
8 from enigma import eTimer
9 -from os import system as os_system
10 +from os import system as os_system, popen as os_popen
11 from __init__ import _
13 config.plugins.transcodingsetup = ConfigSubsection()
14 @@ -15,13 +15,17 @@ config.plugins.transcodingsetup.transcoding = ConfigSelection(default = "disable
15 config.plugins.transcodingsetup.port = ConfigSelection(default = "8002", choices = [ ("8001", "8001"), ("8002", "8002")] )
18 - -1 : "File not exist - /proc/stb/encoder/enable.",
19 - -2 : "File not exist - /etc/inetd.conf.",
20 - -3 : "File open error - /proc/stb/encoder/enable.",
21 - -4 : "File open error - /etc/inetd.conf.",
22 - -5 : "Set encoder error.",
23 - -6 : "Set port error.",
24 - -7 : "Setting value is incorrect."
25 + -1 : "File not exist - /proc/stb/encoder/enable",
26 + -2 : "File not exist - /etc/inetd.conf",
27 + -3 : "File open error - /proc/stb/encoder/enable",
28 + -4 : "File open error - /etc/inetd.conf",
29 + -5 : "Set encoder error",
30 + -6 : "Set port error",
31 + -7 : "Setting value is incorrect",
32 + -8 : "File not exist - /etc/xinetd.d/streamproxy",
33 + -9 : "File not exist - /etc/xinetd.d/transtreamproxy",
34 + -10 : "File open error - /etc/xinetd.d/streamproxy",
35 + -11 : "File open error - /etc/xinetd.d/transtreamproxy",
37 class TranscodingSetupInit:
39 @@ -44,8 +48,6 @@ class TranscodingSetupInit:
41 if not fileExists("/proc/stb/encoder/enable"):
43 - elif not fileExists("/etc/inetd.conf"):
45 if self.setEncoder(transcoding) < 0:
47 res = self.setPort(port)
48 @@ -53,11 +55,11 @@ class TranscodingSetupInit:
49 self.setEncoder(self.transcoding_old)
53 + self.restartDaemon()
56 def setEncoder(self,mode = "disabled"):
57 - print "<TranscodingSetup> set encoder : %s" % mode
58 +# print "<TranscodingSetup> set encoder : %s" % mode
59 mode = mode.strip(' ').strip('\n')
61 fd = open("/proc/stb/encoder/enable",'r')
62 @@ -78,14 +80,29 @@ class TranscodingSetupInit:
63 # print "setEncoder exception error"
67 + ps_xinetd = os_popen('ps -ef | grep xinetd | grep -v grep').read()
68 + if ps_xinetd.strip() == '':
73 def setPort(self, port = "8001"):
74 - print "<TranscodingSetup> set port : %s" % port
75 +# print "<TranscodingSetup> set port : %s" % port
77 + res = self.setPort_xinetd(port)
79 + res = self.setPort_inetd(port)
82 + def setPort_inetd(self, port = "8001"):
83 + if not fileExists("/etc/inetd.conf"):
86 fp = file('/etc/inetd.conf', 'r')
87 datas = fp.readlines()
90 -# print "file open error, inetd.conf!"
94 @@ -112,9 +129,65 @@ class TranscodingSetupInit:
98 - def inetdRestart(self):
99 - if fileExists("/etc/init.d/inetd"):
100 - os_system("/etc/init.d/inetd restart")
101 + def setPort_xinetd(self, port = "8001"):
102 + if not fileExists("/etc/xinetd.d/streamproxy") :
104 + if not fileExists("/etc/xinetd.d/transtreamproxy"):
108 + fp_s = file('/etc/xinetd.d/streamproxy')
109 + data_s = fp_s.readlines()
115 + fp_t = file('/etc/xinetd.d/transtreamproxy')
116 + data_t = fp_t.readlines()
130 + for line in data_s:
131 + if line.find("port") != -1:
132 + line = "\tport = %s\n"%port_s
136 + for line in data_t:
137 + if line.find("port") != -1:
138 + line = "\tport = %s\n"%port_t
141 + fd = file("/etc/xinetd.d/streamproxy",'w')
142 + fd.write(newdata_s)
145 + fd = file("/etc/xinetd.d/transtreamproxy",'w')
146 + fd.write(newdata_t)
153 + def restartDaemon(self):
154 + if self.isXinetd():
155 + if fileExists("/etc/init.d/xinetd"):
156 + os_system("/etc/init.d/xinetd restart")
158 + if fileExists("/etc/init.d/inetd"):
159 + os_system("/etc/init.d/inetd restart")
162 if fileExists("/proc/stb/info/vumodel"):
163 @@ -182,12 +255,12 @@ class TranscodingSetup(Screen,ConfigListScreen, TranscodingSetupInit):
165 transcoding = config.plugins.transcodingsetup.transcoding.value
166 port = config.plugins.transcodingsetup.port.value
167 - print "<TranscodingSetup> Transcoding %s(port : %s)"%(transcoding, port)
168 +# print "<TranscodingSetup> Transcoding %s(port : %s)"%(transcoding, port)
169 ret = self.setupTranscoding(transcoding, port)
170 if ret is not None and ret <0 :
173 - self.session.openWithCallback(self.close, MessageBox, _("Failed, Encoder %s\n(%s).")%(transcoding, error_msg[ret]), MessageBox.TYPE_ERROR)
174 + self.session.openWithCallback(self.close, MessageBox, _("Failed, Encoder %s.\n(%s)")%(transcoding, error_msg[ret]), MessageBox.TYPE_ERROR)
177 if transcoding == "enabled" and port == "8001" :