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