[svn r503] GMyth-Streamer: Chenca's bug fix trunk
authormorphbr
Wed Apr 04 18:05:44 2007 +0100 (2007-04-04)
branchtrunk
changeset 4987a0c3906dce2
parent 497 08a2d7d67ae5
child 499 9900800a8dd6
[svn r503] GMyth-Streamer: Chenca's bug fix
gmyth-stream/server/main.py
gmyth-stream/server/plugins/media/mencoder.py
     1.1 --- a/gmyth-stream/server/main.py	Wed Apr 04 17:08:11 2007 +0100
     1.2 +++ b/gmyth-stream/server/main.py	Wed Apr 04 18:05:44 2007 +0100
     1.3 @@ -21,7 +21,7 @@
     1.4  
     1.5  lib.log("Starting GMyth-Stream server")
     1.6  
     1.7 -while (server.finish is 0):
     1.8 +while (server.finish == 0):
     1.9      con, client = server.getRequest()
    1.10  
    1.11      while True:
    1.12 @@ -31,7 +31,7 @@
    1.13  
    1.14          lib.log("Received %s from: %s" % (msg, client) )
    1.15  
    1.16 -        if msg is "SETUP":
    1.17 +        if msg == "SETUP":
    1.18              setup = server.getMsg(1024).strip().split(" ")
    1.19              size = len(setup)
    1.20              options = []
    1.21 @@ -52,21 +52,21 @@
    1.22                                    setup[6], setup[7], setup[8],
    1.23                                    setup[9], options)
    1.24  
    1.25 -                if ret is 0:
    1.26 +                if ret == 0:
    1.27                      server.Ack("SETUP")
    1.28                  else:
    1.29                      server.sendMsg(lib.log(ret))
    1.30  
    1.31  
    1.32 -        elif msg is "PLAY":
    1.33 +        elif msg == "PLAY":
    1.34              media.play()
    1.35              server.Ack("PLAY")
    1.36  
    1.37 -        elif msg is "STOP":
    1.38 +        elif msg == "STOP":
    1.39              media.stop()
    1.40              server.Ack("STOP")
    1.41  
    1.42 -        elif msg is "CLOSE":
    1.43 +        elif msg == "CLOSE":
    1.44              server.finish = 1
    1.45              media.stop()
    1.46              server.Ack("CLOSE")
     2.1 --- a/gmyth-stream/server/plugins/media/mencoder.py	Wed Apr 04 17:08:11 2007 +0100
     2.2 +++ b/gmyth-stream/server/plugins/media/mencoder.py	Wed Apr 04 18:05:44 2007 +0100
     2.3 @@ -33,16 +33,16 @@
     2.4  
     2.5          for opt in options:
     2.6  
     2.7 -            if opt is "file" or opt is "dvd":
     2.8 +            if opt == "file" or opt == "dvd":
     2.9  
    2.10 -                if self.acodec is "mp3lame":
    2.11 +                if self.acodec == "mp3lame":
    2.12                      audio = "-oac mp3lame -lameopts cbr:br=%s vol=5" % self.abitrate
    2.13                  else:
    2.14                      audio = "-oac lavc -lavcopts acodec=%s:abitrate=%s" % (\
    2.15                          self.acodec, self.abitrate)
    2.16  
    2.17  
    2.18 -            if opt is "file":
    2.19 +            if opt == "file":
    2.20                  self.kind = "file"
    2.21                  self.args += " %s -mf fps=%s -of %s %s"\
    2.22                               " -ovc lavc -lavcopts vcodec=%s:vbitrate=%s -vf scale=%s:%s"\
    2.23 @@ -50,7 +50,7 @@
    2.24                      self.filename, self.fps, self.mux, audio, self.vcodec,
    2.25                      self.vbitrate, self.width, self.height, self.fifo)
    2.26  
    2.27 -            elif opt is "dvd":
    2.28 +            elif opt == "dvd":
    2.29                  self.kind = "dvd"
    2.30                  self.args += " dvd://%s -alang %s -vf scale=%s:%s %s"\
    2.31                               " -of %s -ovc lavc -lavcopts vcodec=%s:vbitrate=%s -o %s"\
    2.32 @@ -58,7 +58,7 @@
    2.33                      self.filename, self.language, self.width, self.height, audio,
    2.34                      self.mux, self.vcodec, self.vbitrate, self.fifo, self.fps)
    2.35  
    2.36 -            elif opt is "local":
    2.37 +            elif opt == "local":
    2.38                  self.mplayer = os.popen("which mplayer").read().strip()
    2.39  
    2.40              elif opt.find("language=") >= 0:
    2.41 @@ -77,7 +77,7 @@
    2.42      def run_mplayer(self):
    2.43          msg = "%s 1>/dev/null 2>/dev/null" % self.filename
    2.44  
    2.45 -        if self.kind is "dvd":
    2.46 +        if self.kind == "dvd":
    2.47              msg = "dvd://" + msg
    2.48  
    2.49          self.mplayer += " " + msg
    2.50 @@ -103,16 +103,16 @@
    2.51          self.kind = ""
    2.52          self.set_args(options)
    2.53  
    2.54 -        if self.kind is "file" and not os.path.exists(self.filename):
    2.55 +        if self.kind == "file" and not os.path.exists(self.filename):
    2.56              msg = "File requested does not exist. SETUP failed."
    2.57              lib.log(msg)
    2.58              return msg
    2.59  
    2.60 -        # good one: /tmp/dvb.mpg avi mpeg4 400 25 mp3lame 192 320 240 5000
    2.61 +        # good one: /tmp/dvb.mpg avi mpeg4 400 25 mp3lame 192 320 240 5000 file
    2.62          #4 mpeg mpeg1video 400 25 mp3lame 192 400 240 5000 language=en local dvd
    2.63          self.path = self.config.get("Mencoder", "path")
    2.64  
    2.65 -        if self.socket is not None:
    2.66 +        if self.socket != None:
    2.67              del(self.socket)
    2.68  
    2.69          self.socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    2.70 @@ -138,7 +138,7 @@
    2.71  
    2.72          self.child_pid = os.fork()
    2.73  
    2.74 -        if self.child_pid is 0:
    2.75 +        if self.child_pid == 0:
    2.76              conn,addr= self.socket.accept()
    2.77              lib.log("Sending Data to client: %s" % addr[0])
    2.78  
    2.79 @@ -146,13 +146,13 @@
    2.80              conn.settimeout(5)
    2.81              retry = 0
    2.82  
    2.83 -            while data is not "" and retry < 5:
    2.84 +            while data != "" and retry < 5:
    2.85                  try:
    2.86                      conn.send(data)
    2.87                      r, w, x = select([conn], [], [], 0)
    2.88                      if conn in r:
    2.89                          back = conn.recv(1024)
    2.90 -                        if back is "OK" and self.mplayer and not self.mplayer_pid:
    2.91 +                        if back == "OK" and self.mplayer and not self.mplayer_pid:
    2.92                              self.run_mplayer()
    2.93  
    2.94                  except socket.error:
    2.95 @@ -176,10 +176,10 @@
    2.96          except:
    2.97              lib.log("Trying to stop before playing...")
    2.98  
    2.99 -        if self.socket is not None:
   2.100 +        if self.socket != None:
   2.101              lib.log("Closing socket")
   2.102              self.socket.close()
   2.103  
   2.104              lib.log("Trying to stop Mencoder process")
   2.105 -            if self.child_pid is not None:
   2.106 +            if self.child_pid != None:
   2.107                  os.kill(self.child_pid, signal.SIGABRT)