def __init__(self, host, port ): # self.s = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) self.s = timeoutsocket.socket( timeoutsocket.AF_INET, timeoutsocket.SOCK_STREAM ) self.s.connect( (host, port) ) self.fs = os.fdopen( self.s.fileno(), 'r+b' ) self.sess = open( "session.log", "ab" ) print >> self.sess, "==", sys.argv[1], sys.argv[2:] print >> self.sess, "=+", time.strftime( '%Y-%m-%d %H:%M:%S %Z' )
client.close() # del client elif c[0] == 'expected': code, msg = client.response() if len(c) > 1: if ( int(c[1]) != code ): print "Unexpected return code after command", last_command + ":", code, msg print "Line:", count + 1 client.mark_in_log( "Unexpected return code" ) ret_code = -1 elif c[0] == 'send': # notify mail propagation tracker that we sent mail t = time.time() id = 'id=' + str( t ) + '-' + socket.gethostname() #scoll = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) scoll = timeoutsocket.socket( timeoutsocket.AF_INET, timeoutsocket.SOCK_STREAM ) # scoll.connect( ('localhost', 2049) ) # print "connect to", c[1], int(c[2]) scoll.connect( (c[1], int(c[2])) ) # fscoll = os.fdopen( scoll.fileno(), 'r+b' ) fscoll = timeoutsocket.TimeoutFile( scoll ) # s.makefile( "r+b" ) fscoll.write( id + ' ' + 'action=out\n' ) fscoll.flush() send_flag = 1 #scoll.close() elif c[0] == 'wait': # wait responce from mail propagation tracker, that one receive our mail # (try-block work with timeoutsocket python module) try: resp = fscoll.readline()