def create_boardcast(addr,port): global mesag,hostname,hostip,defaultdest,c_socket,mesag,tempmsg mesag='' tempmsg='' defaultassembly='K:\\GC\\assembly\\' defaultoldsurce='K:\\GC\\build\\' #default_current=project_init+'_'+'ALL' try: print('begin create socket') c_socket=socket.socket(socket.AF_INET, socket.SOCK_DGRAM) c_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) c_socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) print('begin bind ip and port ') c_socket.bind((addr,port)) print('waiting connect') except (OSError) as connecterror: print(connecterror) try: while 1: try: mesag, send_addr=c_socket.recvfrom(8192) except (OSError) as socket_error: print('recvice_error',socke_error) print('server recevied %r from %r' % (str(mesag), send_addr) ) parsernetwork(mesag,addr) hostname=socket.gethostname() localipaddr = socket.gethostbyname(hostname) ipinfo=hostname+','+localipaddr try: print('project_init len:',project_init,len(project_init)) print('zipfilename len:',zipfilename,len(zipfilename)) print('buildsource len:',buildsource,len(buildsource)) print('version len:',version,len(version)) if Statflag==('init') and len(project_init) > 1 and len(zipfilename)>1 and len(buildsource) >1 and len(version) >1: hostname=socket.gethostname() localipaddr = socket.gethostbyname(hostname) mesg=hostname+','+localipaddr msg=bytes(mesg,'utf-8') project=project_init+'-'+'assembly-all' destdir='K:\\GC\\'+project if os.path.isdir('K:\\')== True and os.path.isdir('K:\\GC\\') == False: allow_encryptdisk() os.makedirs('K:\\GC') os.makedirs(destdir) os.makedirs(defaultoldsurce) os.makedirs(defaultassembly) tempmsg='create GC,build,assembly directy' filename='K:\\'+project+'\\assembly-version' print(filename,',',project) sourcezip=buildsource+zipfilename if os.path.isfile(sourcezip)== True: shutil.copy(sourcezip,defaultassembly) else: msg='SOURCE file is not exist' c_socket.sendto(msg,send_addr) pass local_zip=defaultassembly+zipfilename print('zipfile',local_zip) extract_new_build(local_zip,destdir) disallow_encryptdisk() call_gps_agent(destdir) reply_info=tempmsg+','+zipextractmsg+','+allowdiskmsg msg=bytes(reply_info,'utf-8') c_socket.sendto(msg,send_addr) elif Statflag==('change_build') and len(zipfilename) >1 and len(project_init) >1 and len(buildsource) >1: print("begin change build") project=project_init+'-'+'assembly-all' currentbuild='K:\\GC\\'+project+'\\assembly-version' currentdir='K:\\GC\\'+project zipdest='K:\\GC\\'+project print(currentbuild,',',project) sourcezip=buildsource+zipfilename allow_encryptdisk() open_file_get_version(currentbuild) print('Version number',version) #move previous build to g:\\gc\\build with project arch_dest=defaultoldsurce+project+'-'+version new_build_dest='G:\\'+project print('new_build_dest:',new_build_dest) print('arch_dest:',arch_dest) #kill java wrap process kill_exist_agentp() #first stop Agent #then move previous build to G:\\GC\\BUILD\\ print("move old build to G:\\GC\\BUILD\\") move_prev_build(currentdir,arch_dest) #copy newbuild from nas to G:\\GC\assembly print("move",sourcezip,"to",defaultassembly) shutil.copy(sourcezip,defaultassembly) #find local assembly local_zip=defaultassembly+zipfilename print('zipfile',local_zip) print('dest_dir:',zipdest) print('unzip agent.zip') extract_new_build(local_zip,zipdest) print('call agent start ') call_gps_agent(zipdest) reply_infoa=ipinfo+'changed build version and execute'+',zipfile info'+zipextractmsg reply_info=reply_infoa+",close G:\\ write permission,"+allowdiskmsg msg=bytes(reply_info,'utf-8') c_socket.sendto(msg,send_addr) elif Statflag==('Upload_Game') and len(game_source) > 4 and len(game_build): if shutil.isdir(game_source): try: shutil.copy(game_source,game_dest) except OSError as gamecopyerr: errmsg=ipinfo+',Error:'+str(gamecopyerr) msg=bytes(errmsg) c_socket.sendto(msg,send_addr) else: msg=bytes('GameSource is wrong') c_socket.sendto(msg,send_addr) elif Statflag==('start_agernt'): print('start agent by remote command') #call Agent wake up to work project=project_init+'-'+'assembly-all' destdir='G:\\GC\\'+project call_gps_agent(destdir) elif Statflag==('stop_agent') else: reply_info='you send wrong paramater' msg=bytes(reply_info,'utf-8') c_socket.sendto(msg,send_addr) except (IOError, os.error) as why2: print(why2) except (KeyboardInterrupt,SystemExit): print('finished the program?') choice = sys.stdin.readline().rstrip() if((choice=='yes') or (choice == 'y')): sys.exit(1) else: raise