def merge_properties(): global new_dir download_properties() path = get_module_code_path() + '/WebContent/WEB-INF/classes' properties = [x for x in os.listdir(path) if x.endswith('.properties')] for prop in properties: d = {} # User remote `current` as default with open(os.path.join(config.get_local_download_path(), prop), 'r') as f: for line in f: segs = line.strip().split('=') if len(segs) > 1 and not segs[0].startswith('#'): key = segs[0] value = ''.join(segs[1:]) d[key] = value with open(os.path.join(path, prop), 'r') as f: for line in f: segs = line.strip().split('=') if len(segs) > 1 and not segs[0].startswith('#'): key = segs[0] if not d.has_key(key) : value = ''.join(segs[1:]) d[key] = value with open(os.path.join(config.get_local_download_path(), prop), 'w') as f: for key in d: line = key + '=' + d[key] + '\n' f.write(line) upload_properties(properties) move_properties(properties) print '@@@@@@@@@@@@ Merge properties Successful #############'
def merge_properties(): global new_dir download_properties() path = get_module_code_path() + '/WebContent/WEB-INF/classes' properties = [x for x in os.listdir(path) if x.endswith('.properties')] for prop in properties: d = {} # User remote `current` as default with open(os.path.join(config.get_local_download_path(), prop), 'r') as f: for line in f: segs = line.strip().split('=') if len(segs) > 1 and not segs[0].startswith('#'): key = segs[0] value = ''.join(segs[1:]) d[key] = value with open(os.path.join(path, prop), 'r') as f: for line in f: segs = line.strip().split('=') if len(segs) > 1 and not segs[0].startswith('#'): key = segs[0] if not d.has_key(key): value = ''.join(segs[1:]) d[key] = value with open(os.path.join(config.get_local_download_path(), prop), 'w') as f: for key in d: line = key + '=' + d[key] + '\n' f.write(line) upload_properties(properties) move_properties(properties) print '@@@@@@@@@@@@ Merge properties 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 download_properties(): cmd_scp = 'expect expect/scp_download.exp "%s" "%s" "%s" "%s" "%s"' % ( config.get_dest_username(), config.get_dest_ip(), config.get_dest_password(), config.get_local_download_path(), config.get_dest_war_path() + '/' + module + '/current/WEB-INF/classes/*.properties') assert os.system(cmd_scp) == 0 print '@@@@@@@@@@@@ Download properties 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 download_properties(): cmd_scp = 'expect expect/scp_download.exp "%s" "%s" "%s" "%s" "%s"' % (config.get_dest_username(), config.get_dest_ip(), config.get_dest_password(), config.get_local_download_path(), config.get_dest_war_path() + '/' + module + '/current/WEB-INF/classes/*.properties') assert os.system(cmd_scp) == 0 print '@@@@@@@@@@@@ Download properties Successful #############'