def main(): # create socket object myclient = socket_io() # first read config files err_msg, status = read_config_files() if not status: sys.exit(err_msg) # open socket as client status = myclient.socket_open( header.test_conf[header.str_server_ip], header.test_conf[header.str_server_port], False ) if not status: sys.exit("Error to open socket as client") # show info for this modul print "-- this is the client test unit manager V 0.1 written in python 2 --" # show menue comments if header.test_conf[header.str_menue_on] == "True": for comment in header.menue_com: print comment # ----- # the file menue # ----- # request to the server read dir test files status = myclient.socket_write(header.c_file_rd) if not status: sys.exit("Error to send request") file_list, status = myclient.socket_read() if not status: sys.exit("Error to read file list") print file_list
def main(): cnt_timeout = 200 t_cnt = 0 # the read data vom client data ="" # create socket object myserver = socket_io() #first read config files err_msg, status = read_config_files() if not status: sys.exit(err_msg) # define the key word filter for the communication filter= { (header.c_alive_q) : empty, (header.c_alive_a) : empty, (header.c_break) : empty, (header.c_next) : empty, (header.c_seq) : empty, (header.c_file_rd) : readDir} # show info print "----" print "-- this is the server test unit manager V 0.1 written in python 2 --" print "waiting for client..." # open socket as server status= myserver.socket_open(header.test_conf[header.str_server_ip], header.test_conf[header.str_server_port], True) if not status: sys.exit("Error to open socket as server") else: print "connected" while 1: # read data from client data, status = myserver.socket_read() # use the filter try: status = filter[data](myserver) except: pass # this is shit but if the client dead there come a # empty string back. there count them end bye. # this is only a emergeny resolution if data == "": t_cnt = t_cnt + 1 else: t_cnt = 0 if t_cnt == cnt_timeout: end(myserver) sys.exit() print status