def prepare(): global new_dir #1) enter the directory cmds = [] cmd_cd_module_path = 'cd %s' % os.path.join(config.get_dest_war_path(), module) cmds.append(cmd_cd_module_path) #2) make new directory import datetime new_dir = datetime.datetime.now().strftime('%m%d_%H%M') cmd_make_new_dir = 'mkdir %s' % new_dir cmds.append(cmd_make_new_dir) #3) decompress cmd_decompress_war = 'cd %s; %s xvf %s' % ( new_dir, config.get_dest_java_home() + '/bin/jar', os.path.join(config.get_dest_scp_path(), module + '.war')) cmds.append(cmd_decompress_war) cmd_ssh = 'expect expect/ssh.exp "%s" "%s" "%s" "%s"' % ( config.get_dest_username(), config.get_dest_password(), config.get_dest_ip(), '\n'.join(cmds)) assert os.system(cmd_ssh) == 0 merge_properties() print '@@@@@@@@@@@@ Prepare Successful #############'
def move_properties(properties): global new_dir cmds = [] for prop in properties: cmds.append('mv %s %s' % (os.path.join(config.get_dest_scp_path(), prop), config.get_dest_war_path() + '/' + module + '/' + new_dir + '/WEB-INF/classes')) cmd_move = '\n'.join(cmds) cmd_ssh = 'expect expect/ssh.exp "%s" "%s" "%s" "%s"' % (config.get_dest_username(), config.get_dest_password(), config.get_dest_ip(), cmd_move) assert os.system(cmd_ssh) == 0
def upload(): assert os.path.exists(get_module_target_file()) cmd_scp = 'expect expect/scp_upload.exp "%s" "%s" "%s" "%s" "%s"' % ( config.get_dest_username(), config.get_dest_ip(), config.get_dest_password(), get_module_target_file(), config.get_dest_scp_path()) os.chdir(get_current_root_path()) assert os.system(cmd_scp) == 0 print '@@@@@@@@@@@@ Upload Successful #############'
def upload_properties(properties): files = [] for prop in properties: files.append(os.path.join(config.get_local_download_path(), prop)) cmd_scp = 'expect expect/scp_upload.exp "%s" "%s" "%s" "%s" "%s"' % ( config.get_dest_username(), config.get_dest_ip(), config.get_dest_password(), ' '.join(files), config.get_dest_scp_path()) assert os.system(cmd_scp) == 0 print '@@@@@@@@@@@@ Upload properties Successful #############'
def move_properties(properties): global new_dir cmds = [] for prop in properties: cmds.append('mv %s %s' % (os.path.join(config.get_dest_scp_path(), prop), config.get_dest_war_path() + '/' + module + '/' + new_dir + '/WEB-INF/classes')) cmd_move = '\n'.join(cmds) cmd_ssh = 'expect expect/ssh.exp "%s" "%s" "%s" "%s"' % ( config.get_dest_username(), config.get_dest_password(), config.get_dest_ip(), cmd_move) assert os.system(cmd_ssh) == 0
def prepare(): global new_dir #1) enter the directory cmds = [] cmd_cd_module_path='cd %s' % os.path.join(config.get_dest_war_path(), module) cmds.append(cmd_cd_module_path) #2) make new directory import datetime new_dir=datetime.datetime.now().strftime('%m%d_%H%M') cmd_make_new_dir='mkdir %s' % new_dir cmds.append(cmd_make_new_dir) #3) decompress cmd_decompress_war='cd %s; %s xvf %s' % (new_dir, config.get_dest_java_home() + '/bin/jar', os.path.join(config.get_dest_scp_path(), module + '.war')) cmds.append(cmd_decompress_war) cmd_ssh='expect expect/ssh.exp "%s" "%s" "%s" "%s"' % (config.get_dest_username(), config.get_dest_password(), config.get_dest_ip(), '\n'.join(cmds)) assert os.system(cmd_ssh) == 0 merge_properties() print '@@@@@@@@@@@@ Prepare Successful #############'
def upload_properties(properties): files = [] for prop in properties: files.append(os.path.join(config.get_local_download_path(), prop)) cmd_scp = 'expect expect/scp_upload.exp "%s" "%s" "%s" "%s" "%s"' % (config.get_dest_username(), config.get_dest_ip(), config.get_dest_password(), ' '.join(files), config.get_dest_scp_path()) assert os.system(cmd_scp) == 0 print '@@@@@@@@@@@@ Upload properties Successful #############'
def upload(): assert os.path.exists(get_module_target_file()) cmd_scp = 'expect expect/scp_upload.exp "%s" "%s" "%s" "%s" "%s"' % (config.get_dest_username(), config.get_dest_ip(), config.get_dest_password(), get_module_target_file(), config.get_dest_scp_path()) os.chdir(get_current_root_path()) assert os.system(cmd_scp) == 0 print '@@@@@@@@@@@@ Upload Successful #############'