# HG changeset patch # User morphbr # Date 1181043163 -3600 # Node ID ef4fb30176ddeab00b7a0f95ebbb2b80d7967e06 # Parent f92cd43fea7d579bd25e4526514f50cce87369c1 [svn r750] * GMyth-Streamer - Download's status capability diff -r f92cd43fea7d -r ef4fb30176dd gmyth-stream/server/0.3/lib/request_handler.py --- a/gmyth-stream/server/0.3/lib/request_handler.py Mon Jun 04 19:05:36 2007 +0100 +++ b/gmyth-stream/server/0.3/lib/request_handler.py Tue Jun 05 12:32:43 2007 +0100 @@ -70,14 +70,17 @@ try: url[self.path](body) except KeyError, e: - action = self.query.get("action", None) - if action and "stream.do" in action: - self.serve_stream(body) - elif os.path.exists("html/%s" % self.path): - data = open("html/%s" % self.path) - self.wfile.write(data.read()) - else: - self.send_error(404, "File not found") + try: + action = self.query.get("action", None) + if action and "stream.do" in action: + self.serve_stream(body) + elif os.path.exists("html/%s" % self.path): + data = open("html/%s" % self.path) + self.wfile.write(data.read()) + else: + self.send_error(404, "File not found") + except Exception, e: + self.log.error(e) # do_dispatch() @@ -338,11 +341,11 @@ if body: + test_tid = int(self.query.get("tid", "0")[0]) + if test_tid == 0 or test_tid not in self.tid_queue: + test_tid = self._get_new_id(self.server.last_tid) + if self.query.get("transcoder", None): - test_tid = int(self.query.get("tid", "0")[0]) - if test_tid == 0 or test_tid not in self.tid_queue: - test_tid = self._get_new_id(self.server.last_tid) - self.transcoders_log.insert(test_tid, "gms.%s" % obj.name) obj.tid = test_tid obj.log = self.transcoders_log @@ -355,8 +358,23 @@ elif self.query.get("type", "")[0] == "file" and \ self.query.get("uri", None): try: - media = open(self.query.get("uri", None)[0]) - self.wfile.write(media.read()) + filename = self.query.get("uri", None)[0] + self.transcoders_log.insert(test_tid, "gms.%s" % filename) + + media = open(filename) + data_in = " " + total_read = 0 + size = int(os.path.getsize(filename)) + + while data_in != "": + data_in = media.read(4096) + total_read += 4096 + self.wfile.write(data_in) + status = utils.progress_bar(total_read, size, 50) + msg_status = "Status:%s:%s%%" % (test_tid, status) + self.transcoders_log._update_status(test_tid, + msg_status) + except Exception, e: self.log.error("Stream error: %s" %e) # serve_stream() diff -r f92cd43fea7d -r ef4fb30176dd gmyth-stream/server/0.3/plugins/transcoders/mencoder.py --- a/gmyth-stream/server/0.3/plugins/transcoders/mencoder.py Mon Jun 04 19:05:36 2007 +0100 +++ b/gmyth-stream/server/0.3/plugins/transcoders/mencoder.py Tue Jun 05 12:32:43 2007 +0100 @@ -236,8 +236,8 @@ os.write(stdw, data_in) total_read += 4096 d = stdout.read(4096) - self.status = utils.progress_bar(int(total_read), - int(size), 50) + self.status = utils.progress_bar(total_read, + size, 50) else: finished = True os.close(stdw)