morphbr@466: import os morphbr@470: import sys morphbr@466: import time morphbr@466: import socket morphbr@466: morphbr@466: morphbr@470: if len(sys.argv) < 2: morphbr@470: HOST = 'localhost' morphbr@470: PORT = 5000 morphbr@470: elif len(sys.argv) == 2: morphbr@470: HOST = sys.argv[1] morphbr@470: PORT = 5000 morphbr@470: else: morphbr@470: HOST = sys.argv[1] morphbr@470: PORT = int(sys.argv[2]) morphbr@466: morphbr@470: socket = socket.socket(socket.AF_INET,socket.SOCK_STREAM) morphbr@470: socket.settimeout(10) morphbr@470: morphbr@470: try: morphbr@470: socket.connect( (HOST,PORT) ) morphbr@470: except: morphbr@470: print "\n--> Could not connect to ('%s':'%d')\n" % (HOST,PORT) morphbr@470: sys.exit(-1) morphbr@470: morphbr@466: morphbr@466: mplayer = os.popen("which mplayer").read().strip() morphbr@470: mplayer += " - 1> /dev/null" morphbr@466: pin, pout = os.popen2(mplayer) morphbr@466: morphbr@470: data = socket.recv(1024) morphbr@466: while (data != ""): morphbr@466: pin.write(data) morphbr@470: data = socket.recv(1024) morphbr@466: morphbr@470: pin.close() morphbr@474: #pout.close() morphbr@471: socket.close() morphbr@470: morphbr@474: morphbr@470: # from select import select morphbr@470: # r, w, x = select([pout], []. [], 0) morphbr@470: # if pout in r: morphbr@470: # pout.read(32)