author | renatofilho |
Tue Apr 03 16:43:11 2007 +0100 (2007-04-03) | |
branch | trunk |
changeset 485 | 00a5cf92ec21 |
child 492 | 63d9475228ac |
permissions | -rw-r--r-- |
1 import os
2 import sys
3 import time
4 import socket
7 if len(sys.argv) < 2:
8 HOST = 'localhost'
9 PORT = 5000
10 elif len(sys.argv) == 2:
11 HOST = sys.argv[1]
12 PORT = 5000
13 else:
14 HOST = sys.argv[1]
15 PORT = int(sys.argv[2])
17 socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
18 socket.settimeout(10)
20 try:
21 socket.connect( (HOST,PORT) )
22 except:
23 print "\n--> Could not connect to ('%s':'%d')\n" % (HOST,PORT)
24 sys.exit(-1)
27 mplayer = os.popen("which mplayer").read().strip()
28 mplayer += " - 1> /dev/null"
29 pin, pout = os.popen2(mplayer)
31 data = socket.recv(1024)
32 i = 0
34 while (data != ""):
35 pin.write(data)
36 data = socket.recv(1024)
37 if (i == 500):
38 socket.send("OK")
39 i += 1
41 pin.close()
42 socket.close()
45 # from select import select
46 # r, w, x = select([pout], []. [], 0)
47 # if pout in r:
48 # pout.read(32)