#!/usr/bin/python

import pickle
import socket
import os
import cli
import globaldefines
from netutils import *

HOST, PORT = "localhost", globaldefines.REQUEST_PORT


try:
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.connect((HOST,PORT))
except socket.error, (value,message):
    print "Could not open socket: " + message
    if sock:
        sock.close()
    os._exit(1)

try:
    sock.send(pickle.dumps(cli.parseargs()))
    while True:
        line = receive(sock,"No reply from taskd")
        sock.send("Received")
        if line == "Done": break
        print line
except TimeoutError, (message):
    print message
finally:
    sock.close()




