[svn r714] version increased to 0.3. test binary removed from debian package
5 import lib.utils as utils
6 import lib.server as server
8 from select import select
10 def _setup_mythfilename(self):
11 # mythtv:mythtv@192.168.3.110:6543/1002_20070426230000.nuv
13 _mysql = self.args["input"].split("@")[0].split(":")
15 _mysql = ["mythtv", "mythtv"]
18 _args = self.args["input"].split("@")[1].split(":")
20 _args = self.args["input"].split(":")
23 gmyth_dict["mysql"] = _mysql
24 gmyth_dict["backend"] = _args[0]
25 gmyth_dict["port"] = _args[1].split("/", 1)[0]
27 _tmp_file = _args[1].split("/", 1)[1]
29 if _tmp_file.find("channel") >= 0:
30 gmyth_dict["kind"] = "c"
31 gmyth_dict["cfile"] = _tmp_file.split("=")[1]
33 gmyth_dict["kind"] = "f"
34 gmyth_dict["cfile"] = _tmp_file
36 self.args["input"] = "-"
40 def _setup_mythfile(err):
41 size = err.readline().split("Size:")[1]
42 flags = fcntl.fcntl (err, fcntl.F_GETFL, 0) | os.O_NONBLOCK
43 fcntl.fcntl(err, fcntl.F_SETFL, flags)
47 def _setup_gmythcat(self):
48 gmyth_cat = utils.which("gmyth-cat")
49 return [ utils.which("gmyth-cat"),
50 "-h", self.args["gmyth-cat"]["backend"],
51 "-p", self.args["gmyth-cat"]["port"],
52 "-" + self.args["gmyth-cat"]["kind"],
53 self.args["gmyth-cat"]["cfile"]
57 def start_myth(self, outfd):
58 opts = _setup_gmythcat(self)
60 self.gmyth = subprocess.Popen(opts, stdout=subprocess.PIPE,
61 stderr=subprocess.PIPE,
64 self.log.error("Error executing gmyth-cat: %s" % e)
67 if not self._run_mencoder(input=self.gmyth.stdout,
68 output=subprocess.PIPE):
71 if self.args["gmyth-cat"]["kind"] == "f":
73 size = _setup_mythfile(self.gmyth.stderr)
74 self.log.debug("Size of file: %s" % size)
76 self.log.error("Problems getting size of file: %s" % e)
80 while self.proc and self.proc.poll() == None:
81 r, w, x = select([self.gmyth.stderr, self.proc.stdout],
83 if self.proc.stdout in r:
84 d = self.proc.stdout.read(4096)
87 if self.gmyth.stderr in r:
88 partial = self.gmyth.stderr.read(50).split("\n")[-2]
90 self.status = utils.progress_bar(self.log,
97 self.log.error("Problems handling data: %s" % e)
100 self.log.info("Finished sending data")