gmyth-stream/server/0.3/lib/request_handler.py
branchtrunk
changeset 724 64b061775d06
parent 723 f5f7abc760aa
child 726 6431b16e18fb
     1.1 --- a/gmyth-stream/server/0.3/lib/request_handler.py	Wed May 30 23:14:38 2007 +0100
     1.2 +++ b/gmyth-stream/server/0.3/lib/request_handler.py	Thu May 31 14:31:24 2007 +0100
     1.3 @@ -133,15 +133,13 @@
     1.4          self.send_header("Content-Type", "text/html")
     1.5          self.send_header('Connection', 'close')
     1.6          self.end_headers()
     1.7 -        directories = self.query.get("directory", None)
     1.8 -        if body and directories:
     1.9 +
    1.10 +        if body:
    1.11              file_list = []
    1.12 -            for directory in directories[0].split(";"):
    1.13 -                files.list_media_files(directory, file_list)
    1.14 -
    1.15 +            files.list_media_files(".transcoded", file_list)
    1.16              output = files.FileList(map(lambda x, y: x+y, file_list,
    1.17                                          ["<br>"]*len(file_list)))
    1.18 -            self.wfile.write(utils.getHTML("file_list", {"file_list": output}))
    1.19 +            self.wfile.write(output)
    1.20  
    1.21      # serve_list()
    1.22  
    1.23 @@ -212,18 +210,18 @@
    1.24                  stopone = ""
    1.25  
    1.26              elif self.query.get("tid", None) and not tl:
    1.27 -                tid = int(self.query.get("tid")[0])
    1.28 -                stat = self.transcoders_log.get_status(tid)
    1.29 -                self.wfile.write("Running: %s" % stat)
    1.30 +                tids = self.query.get("tid")
    1.31 +                for tid in tids:
    1.32 +                    stat = self.transcoders_log.get_status(int(tid))
    1.33 +                    self.wfile.write("Running: %s<br>" % stat)
    1.34  
    1.35              elif self.query.get("tid", None):
    1.36 -                req_tid = int(self.query.get("tid")[0])
    1.37 +                req_tid = self.query.get("tid")
    1.38                  for transcoder, request in tl:
    1.39 -                    if transcoder.tid == req_tid:
    1.40 -                        self.wfile.write("Status: %s %%" % transcoder.status)
    1.41 -                        return True
    1.42 -
    1.43 -                return False
    1.44 +                    if str(transcoder.tid) in req_tid:
    1.45 +                        self.wfile.write("%s:Status: %s %%" % (\
    1.46 +                            transcoder.tid, transcoder.status))
    1.47 +                return True
    1.48  
    1.49              else:
    1.50                  running = "<p>Running transcoders:</p>\n"
    1.51 @@ -327,17 +325,23 @@
    1.52          self.end_headers()
    1.53  
    1.54          if body:
    1.55 -            test_tid = int(self.query.get("tid", "0")[0])
    1.56 -            if test_tid == 0 or test_tid not in self.tid_queue:
    1.57 -                test_tid = self._get_new_id(self.server.last_tid)
    1.58 +            if self.query.get("transcoder", None):
    1.59 +                test_tid = int(self.query.get("tid", "0")[0])
    1.60 +                if test_tid == 0 or test_tid not in self.tid_queue:
    1.61 +                    test_tid = self._get_new_id(self.server.last_tid)
    1.62  
    1.63 -            self.transcoders_log.insert(test_tid, "gms.%s" % obj.name)
    1.64 -            obj.tid = test_tid
    1.65 -            obj.log = self.transcoders_log
    1.66 +                self.transcoders_log.insert(test_tid, "gms.%s" % obj.name)
    1.67 +                obj.tid = test_tid
    1.68 +                obj.log = self.transcoders_log
    1.69  
    1.70 -            self.server.add_transcoders(self, obj)
    1.71 -            obj.start(self.wfile)
    1.72 -            self.server.del_transcoders(self, obj)
    1.73 +                self.server.add_transcoders(self, obj)
    1.74 +                obj.start(self.wfile)
    1.75 +                self.server.del_transcoders(self, obj)
    1.76 +
    1.77 +            elif self.query.get("type", "")[0] == "file" and \
    1.78 +                     self.query.get("uri", None):
    1.79 +                media = open(self.query.get("uri", None)[0])
    1.80 +                self.wfile.write(media.read())
    1.81      # serve_stream()
    1.82  
    1.83  
    1.84 @@ -354,4 +358,5 @@
    1.85      def log_message(self, format, *args):
    1.86          self.log.info("%s: %s" % (self.address_string(), format % args))
    1.87      # log_message()
    1.88 +
    1.89  # RequestHandler