author | rosfran |
Mon Apr 09 15:20:37 2007 +0100 (2007-04-09) | |
branch | trunk |
changeset 513 | 12a61040588d |
child 516 | f353f0da6f07 |
permissions | -rw-r--r-- |
morphbr@496 | 1 |
import os |
morphbr@496 | 2 |
import sys |
morphbr@496 | 3 |
import time |
morphbr@496 | 4 |
import socket |
morphbr@496 | 5 |
|
morphbr@496 | 6 |
|
morphbr@496 | 7 |
if len(sys.argv) < 2: |
morphbr@496 | 8 |
HOST = 'localhost' |
morphbr@496 | 9 |
PORT = 5000 |
morphbr@496 | 10 |
elif len(sys.argv) == 2: |
morphbr@496 | 11 |
HOST = sys.argv[1] |
morphbr@496 | 12 |
PORT = 5000 |
morphbr@496 | 13 |
else: |
morphbr@496 | 14 |
HOST = sys.argv[1] |
morphbr@496 | 15 |
PORT = int(sys.argv[2]) |
morphbr@496 | 16 |
|
morphbr@496 | 17 |
socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) |
morphbr@496 | 18 |
socket.settimeout(10) |
morphbr@496 | 19 |
|
morphbr@496 | 20 |
try: |
morphbr@496 | 21 |
socket.connect( (HOST,PORT) ) |
morphbr@496 | 22 |
except: |
morphbr@496 | 23 |
print "\n--> Could not connect to ('%s':'%d')\n" % (HOST,PORT) |
morphbr@496 | 24 |
sys.exit(-1) |
morphbr@496 | 25 |
|
morphbr@496 | 26 |
|
morphbr@496 | 27 |
mplayer = os.popen("which mplayer").read().strip() |
morphbr@496 | 28 |
mplayer += " - 1> /dev/null" |
morphbr@496 | 29 |
pin, pout = os.popen2(mplayer) |
morphbr@496 | 30 |
|
morphbr@496 | 31 |
#teste = open("/tmp/teste2", "w") |
morphbr@496 | 32 |
|
morphbr@496 | 33 |
data = socket.recv(1024) |
morphbr@496 | 34 |
i = 0 |
morphbr@496 | 35 |
|
morphbr@496 | 36 |
while (data != ""): |
morphbr@496 | 37 |
pin.write(data) |
morphbr@496 | 38 |
#teste.write(data) |
morphbr@496 | 39 |
data = socket.recv(1024) |
morphbr@496 | 40 |
if (i == 500): |
morphbr@496 | 41 |
socket.send("OK") |
morphbr@496 | 42 |
i += 1 |
morphbr@496 | 43 |
|
morphbr@496 | 44 |
pin.close() |
morphbr@496 | 45 |
socket.close() |
morphbr@496 | 46 |
|
morphbr@496 | 47 |
|
morphbr@496 | 48 |
# from select import select |
morphbr@496 | 49 |
# r, w, x = select([pout], []. [], 0) |
morphbr@496 | 50 |
# if pout in r: |
morphbr@496 | 51 |
# pout.read(32) |