1.1 --- a/gmyth-stream/server/0.3/lib/request_handler.py Mon Jun 04 19:05:36 2007 +0100
1.2 +++ b/gmyth-stream/server/0.3/lib/request_handler.py Tue Jun 05 12:32:43 2007 +0100
1.3 @@ -70,14 +70,17 @@
1.4 try:
1.5 url[self.path](body)
1.6 except KeyError, e:
1.7 - action = self.query.get("action", None)
1.8 - if action and "stream.do" in action:
1.9 - self.serve_stream(body)
1.10 - elif os.path.exists("html/%s" % self.path):
1.11 - data = open("html/%s" % self.path)
1.12 - self.wfile.write(data.read())
1.13 - else:
1.14 - self.send_error(404, "File not found")
1.15 + try:
1.16 + action = self.query.get("action", None)
1.17 + if action and "stream.do" in action:
1.18 + self.serve_stream(body)
1.19 + elif os.path.exists("html/%s" % self.path):
1.20 + data = open("html/%s" % self.path)
1.21 + self.wfile.write(data.read())
1.22 + else:
1.23 + self.send_error(404, "File not found")
1.24 + except Exception, e:
1.25 + self.log.error(e)
1.26
1.27 # do_dispatch()
1.28
1.29 @@ -338,11 +341,11 @@
1.30
1.31 if body:
1.32
1.33 + test_tid = int(self.query.get("tid", "0")[0])
1.34 + if test_tid == 0 or test_tid not in self.tid_queue:
1.35 + test_tid = self._get_new_id(self.server.last_tid)
1.36 +
1.37 if self.query.get("transcoder", None):
1.38 - test_tid = int(self.query.get("tid", "0")[0])
1.39 - if test_tid == 0 or test_tid not in self.tid_queue:
1.40 - test_tid = self._get_new_id(self.server.last_tid)
1.41 -
1.42 self.transcoders_log.insert(test_tid, "gms.%s" % obj.name)
1.43 obj.tid = test_tid
1.44 obj.log = self.transcoders_log
1.45 @@ -355,8 +358,23 @@
1.46 elif self.query.get("type", "")[0] == "file" and \
1.47 self.query.get("uri", None):
1.48 try:
1.49 - media = open(self.query.get("uri", None)[0])
1.50 - self.wfile.write(media.read())
1.51 + filename = self.query.get("uri", None)[0]
1.52 + self.transcoders_log.insert(test_tid, "gms.%s" % filename)
1.53 +
1.54 + media = open(filename)
1.55 + data_in = " "
1.56 + total_read = 0
1.57 + size = int(os.path.getsize(filename))
1.58 +
1.59 + while data_in != "":
1.60 + data_in = media.read(4096)
1.61 + total_read += 4096
1.62 + self.wfile.write(data_in)
1.63 + status = utils.progress_bar(total_read, size, 50)
1.64 + msg_status = "Status:%s:%s%%" % (test_tid, status)
1.65 + self.transcoders_log._update_status(test_tid,
1.66 + msg_status)
1.67 +
1.68 except Exception, e:
1.69 self.log.error("Stream error: %s" %e)
1.70 # serve_stream()