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()