gmyth-stream/server/0.1/tests/client.py
branchtrunk
changeset 633 65eaca328e22
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gmyth-stream/server/0.1/tests/client.py	Tue May 08 14:54:37 2007 +0100
     1.3 @@ -0,0 +1,51 @@
     1.4 +import os
     1.5 +import sys
     1.6 +import time
     1.7 +import socket
     1.8 +
     1.9 +
    1.10 +if len(sys.argv) < 2:
    1.11 +    HOST = 'localhost'
    1.12 +    PORT = 50000
    1.13 +elif len(sys.argv) == 2:
    1.14 +    HOST = sys.argv[1]
    1.15 +    PORT = 50000
    1.16 +else:
    1.17 +    HOST = sys.argv[1]
    1.18 +    PORT = int(sys.argv[2])
    1.19 +
    1.20 +socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    1.21 +socket.settimeout(10)
    1.22 +
    1.23 +try:
    1.24 +    socket.connect( (HOST,PORT) )
    1.25 +except:
    1.26 +    print "\n--> Could not connect to ('%s':'%d')\n" % (HOST,PORT)
    1.27 +    sys.exit(-1)
    1.28 +
    1.29 +
    1.30 +mplayer = os.popen("which mplayer").read().strip()
    1.31 +mplayer += " -idx - -vo x11 1> /dev/null"
    1.32 +pin, pout = os.popen2(mplayer)
    1.33 +
    1.34 +#teste = open("teste.avi", "w")
    1.35 +
    1.36 +data = socket.recv(4096)
    1.37 +i = 0
    1.38 +
    1.39 +while (data != ""):
    1.40 +    pin.write(data)
    1.41 +    #teste.write(data)
    1.42 +    data = socket.recv(4096)
    1.43 +    #if (i == 500):
    1.44 +    #    socket.send("OK")
    1.45 +    i += 1
    1.46 +
    1.47 +pin.close()
    1.48 +socket.close()
    1.49 +#teste.close()
    1.50 +
    1.51 +# from select import select
    1.52 +# r, w, x = select([pout], []. [], 0)
    1.53 +# if pout in r:
    1.54 +#     pout.read(32)