author | rosfran |
Fri Mar 30 23:09:39 2007 +0100 (2007-03-30) | |
branch | trunk |
changeset 472 | e5618b012121 |
parent 470 | 57833200a415 |
child 474 | 07c12d2ceddf |
permissions | -rw-r--r-- |
morphbr@466 | 1 |
import os |
morphbr@470 | 2 |
import sys |
morphbr@466 | 3 |
import time |
morphbr@466 | 4 |
import socket |
morphbr@466 | 5 |
|
morphbr@466 | 6 |
|
morphbr@470 | 7 |
if len(sys.argv) < 2: |
morphbr@470 | 8 |
HOST = 'localhost' |
morphbr@470 | 9 |
PORT = 5000 |
morphbr@470 | 10 |
elif len(sys.argv) == 2: |
morphbr@470 | 11 |
HOST = sys.argv[1] |
morphbr@470 | 12 |
PORT = 5000 |
morphbr@470 | 13 |
else: |
morphbr@470 | 14 |
HOST = sys.argv[1] |
morphbr@470 | 15 |
PORT = int(sys.argv[2]) |
morphbr@466 | 16 |
|
morphbr@470 | 17 |
socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) |
morphbr@470 | 18 |
socket.settimeout(10) |
morphbr@470 | 19 |
|
morphbr@470 | 20 |
try: |
morphbr@470 | 21 |
socket.connect( (HOST,PORT) ) |
morphbr@470 | 22 |
except: |
morphbr@470 | 23 |
print "\n--> Could not connect to ('%s':'%d')\n" % (HOST,PORT) |
morphbr@470 | 24 |
sys.exit(-1) |
morphbr@470 | 25 |
|
morphbr@466 | 26 |
|
morphbr@466 | 27 |
mplayer = os.popen("which mplayer").read().strip() |
morphbr@470 | 28 |
mplayer += " - 1> /dev/null" |
morphbr@466 | 29 |
pin, pout = os.popen2(mplayer) |
morphbr@466 | 30 |
|
morphbr@470 | 31 |
data = socket.recv(1024) |
morphbr@466 | 32 |
while (data != ""): |
morphbr@466 | 33 |
pin.write(data) |
morphbr@470 | 34 |
data = socket.recv(1024) |
morphbr@466 | 35 |
|
morphbr@470 | 36 |
pin.close() |
morphbr@470 | 37 |
pout.close() |
morphbr@471 | 38 |
socket.close() |
morphbr@470 | 39 |
|
morphbr@470 | 40 |
# from select import select |
morphbr@470 | 41 |
# r, w, x = select([pout], []. [], 0) |
morphbr@470 | 42 |
# if pout in r: |
morphbr@470 | 43 |
# pout.read(32) |