def update_git_file(git_root, relative_file_path, new_file, msg, zip_password=None): # 先判断git目录状态是否正常 if not git.is_repository(git_root): raise Exception( '{} is not a valid git source directory!'.format(git_root)) target_file = file_util.normalpath( os.path.join(git_root, relative_file_path)) if not is_same_config(new_file, target_file, zip_password=zip_password): if platform.system() == 'Darwin' and zip_password: UNZIP_CMD = 'unzip -o {}'.format(new_file) exec_cmd.run_cmd_with_system_in_specified_dir( os.path.dirname(new_file), UNZIP_CMD, print_flag=True) os.remove(new_file) ZIP_CMD = 'zip -m -r -P {} {} {}'.format(zip_password, 'config_file.zip', 'config_file') exec_cmd.run_cmd_with_system_in_specified_dir( os.path.dirname(new_file), ZIP_CMD, print_flag=True) file_util.replace_file(new_file, target_file) paths = [] paths.append(relative_file_path) git.push_to_remote(paths, msg, repository=None, refspecs=None, _dir=git_root) else: print('{} and {} is the same!'.format(new_file, target_file))
def checkout_or_update(prj_root, static_config_path, code_svn_path, revision=None): # 先获取目录列表,然后对单个目录进行处理 if not os.path.exists(prj_root) or not os.path.isdir(prj_root): get_code(prj_root, static_config_path, code_svn_path, revision) else: svn_url_info = get_svn_url_info(code_svn_path) # pprint.pprint(svn_url_info) build_file_name = 'local.properties' local_build_file = static_config_path + os.sep + build_file_name child_dirs = [] for item in svn_url_info: child_dir = prj_root + os.sep + item child_dirs.append(child_dir) if not os.path.exists(child_dir) or not os.path.isdir(child_dir): os.makedirs(child_dir) svn.checkout(svn_url_info[item][SourceConfigParser.URL_FLAG], child_dir, revision) else: child_svn_status = svn.status(child_dir) if child_svn_status: svn.revert(child_dir) svn.update(child_dir, revision) else: svn.checkout(item, child_dir, revision) if SourceConfigParser.PRJ_FLAG == svn_url_info[item][SourceConfigParser.TYPE_FLAG]: myfile.replace_file(local_build_file, child_dir + os.sep + build_file_name)
def copy_item(self, src_path): pre_butt = len(self.src) if not self.src.endswith(os.sep): pre_butt += 1 dst_path = os.path.join(self.dst, src_path[pre_butt:]) myfile.replace_file(src_path, dst_path)
def process(self): if self.to_compile: build_cmd = 'go build' exec_cmd.run_cmd_for_code_in_specified_dir(self.src_path, build_cmd, print_flag=True) # 如果有需要则先停止服务 if self.type == _PACK_TYPE_REINSTALL: # stop_cmd = os.path.join(self.bin_path, self.stop_bin_name) # exec_cmd.run_cmd_for_code_in_specified_dir(self.work_path, stop_cmd, print_flag=True) stop_cmd = 'kill -9 $(pgrep {}) > /dev/null 2>&1'.format( self.main_bin_name) exec_cmd.run_cmd_with_system_in_specified_dir(self.work_path, stop_cmd, print_flag=True) # 更新可执行文件 src_path = os.path.join(self.src_path, self.main_bin_name) dst_path = os.path.join(self.bin_path, self.main_bin_name) myfile.replace_file(src_path, dst_path) # 增加可执行权限 add_permission_cmd = 'chmod a+x {}'.format(self.main_bin_name) exec_cmd.run_cmd_with_system_in_specified_dir(self.bin_path, add_permission_cmd, print_flag=True) # 启动服务 start_cmd = os.path.join(os.path.join('.', self.bin_dir_name), self.main_bin_name) exec_cmd.run_cmd_with_system_in_specified_dir(self.work_path, start_cmd, print_flag=True)
def _update_local_build_file(self): # 更新android sdk本地配置 local_file_name = 'local.properties' static_config_path = os.path.join(self.work_path, self.ori_build_config[BuildConfigLabel.ROOT_FLAG][BuildConfigLabel.STATIC_FLAG]) static_config_path = file_util.normalpath(static_config_path) local_build_file = os.path.join(static_config_path, local_file_name) target_build_file = os.path.join(self.prj_root, local_file_name) file_util.replace_file(local_build_file, target_build_file)
def update_gradle_setting(prj_path, src_path): setting_name = 'settings.gradle' local_setting_file = prj_path + os.sep + setting_name if os.path.exists(src_path) and os.path.isfile(src_path): if os.path.exists(local_setting_file): if not filecmp.cmp(src_path, local_setting_file, shallow=False): myfile.replace_file(src_path, local_setting_file) else: myfile.replace_file(src_path, local_setting_file) else: raise Exception('not exists ' + src_path)
def get_code(prj_root, static_config_path, code_svn_path, revision=None): build_file_name = 'local.properties' local_build_file = static_config_path + os.sep + build_file_name svn_url_info = get_svn_url_info(code_svn_path) for item in svn_url_info: path = prj_root + os.sep + item if not os.path.exists(path): os.makedirs(path) svn.checkout(svn_url_info[item][SourceConfigParser.URL_FLAG], path, revision) if SourceConfigParser.PRJ_FLAG == svn_url_info[item][SourceConfigParser.TYPE_FLAG]: myfile.replace_file(local_build_file, path + os.sep + build_file_name)
def switch_commit_with_file(self, name, status): hooks_root = os.path.join(self.svn_root, name, 'hooks') normal_path = os.path.join(hooks_root, self.normal) refuse_path = os.path.join(hooks_root, self.refuse) target_path = os.path.join(hooks_root, self.target) if status: source_path = normal_path else: source_path = refuse_path rtn = filecmp.cmp(source_path, target_path) if not rtn: file_util.replace_file(source_path, target_path)
def update_svn_file(target_file, new_file, msg): base_dir = os.path.dirname(target_file) # 先判断svn目录状态是否正常 if not svn.status(base_dir): raise Exception( '{} is not a valid svn source directory!'.format(base_dir)) # if not filecmp.cmp(new_svn_file, svn_target_file, shallow=False): if not is_same_config(new_file, target_file, zip_password=None): file_util.replace_file(new_file, target_file) svn_paths = [] svn_paths.append(target_file) svn.commit(msg, svn_paths) else: print('{} and {} is the same!'.format(new_file, target_file))
def update_file(target_file, new_file, msg): base_dir = os.path.dirname(target_file) # 先判断svn目录状态是否正常 if not status(base_dir): info = '{} is not a valid svn source directory!'.format(base_dir) raise Exception(info) if not filecmp.cmp(new_file, target_file, shallow=False): myfile.replace_file(new_file, target_file) svn_paths = [] svn_paths.append(target_file) commit(msg, svn_paths) else: print('{} and {} is the same!'.format(new_file, target_file))
def build(self): print('building apk begin ...') # 获取apk名称 apk_name = os.path.basename(self.main_prj_path) apk_out_path = self.main_prj_path + '/build/outputs/apk/' # build_type = self.info[BuilderLabel.TYPE_FLAG] # 默认名称形式 # apk_path = '{}{}-{}.apk'.format(apk_out_path, apk_name, build_type) # 自定义名称形式 apk_path = os.path.join(apk_out_path, self._get_output_relative_path(), self.info[BuilderLabel.OUTPUT_NAME_FLAG]) apk_path = os.path.normpath(apk_path) # 先把现有的apk文件直接删除 if os.path.exists(apk_path) and os.path.isfile(apk_path): os.remove(apk_path) cmd_str = self.get_build_cmd() make_apk_with_gradle(self.main_prj_path, cmd_str) src_file = apk_path print('source apk path: {}'.format(src_file)) if os.path.exists(src_file): apk_items = apk_util.get_apk_info(src_file) actual_ver_name = self.get_main_ver_name(apk_items['versionName']) if actual_ver_name != self.info[BuilderLabel.VER_NAME_FLAG]: info = 'set version name is {}, but actual is {}!'.format(self.info[BuilderLabel.VER_NAME_FLAG], actual_ver_name) raise Exception(info) if apk_items['versionCode'] != str(self.info[BuilderLabel.VER_CODE_FLAG]): info = 'set version code is {}, but actual is {}!'.format(self.info[BuilderLabel.VER_CODE_FLAG], apk_items['versionCode']) raise Exception(info) dst_file = self.info[BuilderLabel.OUTPUT_DIRECTORY_FLAG] + os.sep + self.info[ BuilderLabel.OUTPUT_NAME_FLAG] file_util.replace_file(src_file, dst_file) print('built the apk {}.'.format(dst_file)) else: print('build {} failed!'.format(apk_name))
def checkout_or_update_single_item(prj_root, static_config_path, code_svn_url, revision=None): path = prj_root # 先获取目录列表,然后对单个目录进行处理 if not os.path.exists(path) or not os.path.isdir(path): os.makedirs(path) svn.checkout(code_svn_url, path, revision) else: svn_status = svn.status(path) if svn_status: svn.revert(path) svn.update(path, revision) else: svn.checkout(code_svn_url, path, revision) build_file_name = 'local.properties' local_build_file = static_config_path + os.sep + build_file_name target_build_file = path + os.sep + build_file_name myfile.replace_file(local_build_file, target_build_file)
def build(self, chan_id, mode=apk_builder.RELEASE_MODE): self._update_chan_info(chan_id) # update_str = 'updated version info with chan_id "{0}".'.format(chan_id) # print(update_str) print('building apk begin ...') # 获取apk名称 apk_name = os.path.basename(self.prj_path) apk_out_path = self.prj_path + '/build/outputs/apk/' apk_path = '{}{}-{}.apk'.format(apk_out_path, apk_name, apk_builder.MODE_MAP[mode]) apk_path = os.sep.join(re.split('[\\\/]+', apk_path)) # 先把现有的apk文件直接删除 if os.path.exists(apk_path) and os.path.isfile(apk_path): os.remove(apk_path) apk_builder.make_apk(self.prj_path, mode) # mode_flag = apk_builder.MODE_MAP[mode] # src_file = self.prj_path + os.sep + 'bin' + os.sep + apk_name + '-' + mode_flag + '.apk' src_file = apk_path if os.path.exists(src_file): apk_items = apk.get_apk_info(src_file) if apk_items['versionName'] != self.info[ProjectBuilder.VER_NAME_FLAG]: info = 'set version name is {}, but actual is {}!'.format(self.info[ProjectBuilder.VER_NAME_FLAG], apk_items['versionName']) raise Exception(info) if apk_items['versionCode'] != self.info[ProjectBuilder.VER_CODE_FLAG]: info = 'set version code is {}, but actual is {}!'.format(self.info[ProjectBuilder.VER_CODE_FLAG], apk_items['versionCode']) raise Exception(info) dst_file = self.info[ProjectBuilder.OUTPUT_DIRECTORY_FLAG] + os.sep + self.info[ProjectBuilder.OUTPUT_NAME_FLAG] myfile.replace_file(src_file, dst_file) print('built the apk {}.'.format(dst_file)) else: print('build {} failed!'.format(apk_name))
def copy_specified_item(src_dir, dst_dir, file_list_path): if not os.path.exists(src_dir): raise Exception('{} not exists!'.format(src_dir)) if not os.path.exists(file_list_path): raise Exception('{} not exists!'.format(file_list_path)) file_list = myfile.read_valid_string_list_from_file(file_list_path) # print(file_list) src_itmes = os.listdir(src_dir) if src_itmes: for item in src_itmes: curr_path = os.path.join(src_dir, item) if os.path.exists(curr_path) and os.path.isfile(curr_path): root, ext = os.path.splitext(item) if root in file_list: src_path = os.path.join(src_dir, item) dst_path = os.path.join(dst_dir, item) myfile.replace_file(src_path, dst_path) str_info = 'copy {} to {}.'.format(src_path, dst_path) print(str_info)
def __call__(self, filepath): dst_path = self.map_func(filepath) if dst_path: file_util.replace_file(filepath, dst_path)
def process_func(self, src_file, dst_file): if os.path.splitext(src_file)[1] != '.ipa': myfile.replace_file(src_file, dst_file) os.remove(src_file)
def _res_process_func(self, src_path, dst_path): if not filecmp.cmp(src_path, dst_path): myfile.replace_file(src_path, dst_path)
def build(self): print('building apk begin ...') # 获取apk名称 apk_name = os.path.basename(self.main_prj_path) apk_out_path = self.main_prj_path + '/build/outputs/apk/' # 自定义名称形式 apk_path = os.path.join(apk_out_path, self._get_output_relative_path(), self.info[BuilderLabel.OUTPUT_NAME_FLAG]) apk_path = os.path.normpath(apk_path) # 先把现有的apk文件直接删除 if os.path.exists(apk_path) and os.path.isfile(apk_path): os.remove(apk_path) cmd_str = self.get_build_cmd() make_apk_with_gradle(self.main_prj_path, cmd_str) src_file = apk_path print('source apk path: {}'.format(src_file)) if os.path.exists(src_file): apk_items = apk.get_apk_info(src_file) actual_ver_name = self.get_main_ver_name(apk_items['versionName']) if actual_ver_name != self.info[BuilderLabel.VER_NAME_FLAG]: info = 'set version name is {}, but actual is {}!'.format( self.info[BuilderLabel.VER_NAME_FLAG], actual_ver_name) raise Exception(info) if apk_items['versionCode'] != str( self.info[BuilderLabel.VER_CODE_FLAG]): info = 'set version code is {}, but actual is {}!'.format( self.info[BuilderLabel.VER_CODE_FLAG], apk_items['versionCode']) raise Exception(info) dst_file = self.info[ BuilderLabel.OUTPUT_DIRECTORY_FLAG] + os.sep + self.info[ BuilderLabel.OUTPUT_NAME_FLAG] file_util.replace_file(src_file, dst_file) # 拷贝编译生成的class文件,便于服务器生成代码覆盖率文件 if BuilderLabel.BUILD_CLASS_FLAG in self.info and len( self.info[BuilderLabel.BUILD_CLASS_FLAG]) >= 2: src_class_path = self.main_prj_path + os.sep + self.info[ BuilderLabel.BUILD_CLASS_FLAG][BuilderLabel.SRC_PATH_FLAG] src_class_path = file_util.normalpath(src_class_path) dst_class_relative_path = self.info[ BuilderLabel.BUILD_CLASS_FLAG][BuilderLabel.DST_PATH_FLAG] dst_class_zip_path = self.info[ BuilderLabel. OUTPUT_DIRECTORY_FLAG] + os.sep + 'classes.zip' if os.path.isdir(src_class_path): # shutil.copytree(src_class_path, dst_class_path) rev_index = -len(dst_class_relative_path) zip_src_root = src_class_path[:rev_index] zip_util.zip_dir(src_class_path, dst_class_zip_path, zip_src_root) print('success zip {} to {}.'.format( dst_class_relative_path, dst_class_zip_path)) print('built the apk {}.'.format(dst_file)) else: print('build {} failed!'.format(apk_name))
def build(self, chan_id, mode=apk_builder.RELEASE_MODE): self._update_chan_info(chan_id) # update_str = 'updated version info with chan_id "{0}".'.format(chan_id) # print(update_str) print('building apk begin ...') # 获取apk名称 apk_name = os.path.basename(self.prj_path) apk_out_path = self.prj_path + '/build/outputs/apk/' apk_path = '{}{}-{}.apk'.format(apk_out_path, apk_name, apk_builder.MODE_MAP[mode]) apk_path = os.sep.join(re.split('[\\\/]+', apk_path)) # 先把现有的apk文件直接删除 if os.path.exists(apk_path) and os.path.isfile(apk_path): os.remove(apk_path) cmd_str = self.get_build_cmd() make_apk_with_gradle(self.prj_path, cmd_str) src_file = apk_path if os.path.exists(src_file): apk_items = apk_util.get_apk_info(src_file) if apk_items['versionName'] != self.info[ ProjectBuilder.VER_NAME_FLAG]: info = 'set version name is {}, but actual is {}!'.format( self.info[ProjectBuilder.VER_NAME_FLAG], apk_items['versionName']) raise Exception(info) if apk_items['versionCode'] != self.info[ ProjectBuilder.VER_CODE_FLAG]: info = 'set version code is {}, but actual is {}!'.format( self.info[ProjectBuilder.VER_CODE_FLAG], apk_items['versionCode']) raise Exception(info) dst_file = self.info[ ProjectBuilder.OUTPUT_DIRECTORY_FLAG] + os.sep + self.info[ ProjectBuilder.OUTPUT_NAME_FLAG] file_util.replace_file(src_file, dst_file) # 拷贝编译生成的class文件,便于服务器生成代码覆盖率文件 if ProjectBuilder.BUILD_CLASS_FLAG in self.info and len( self.info[ProjectBuilder.BUILD_CLASS_FLAG]) >= 2: src_class_path = self.prj_path + os.sep + self.info[ ProjectBuilder.BUILD_CLASS_FLAG][ ProjectBuilder.SRC_PATH_FLAG] src_class_path = file_util.normalpath(src_class_path) dst_class_relative_path = self.info[ ProjectBuilder.BUILD_CLASS_FLAG][ ProjectBuilder.DST_PATH_FLAG] dst_class_zip_path = self.info[ ProjectBuilder. OUTPUT_DIRECTORY_FLAG] + os.sep + 'classes.zip' # dst_class_path = self.info[ProjectBuilder.OUTPUT_DIRECTORY_FLAG] + os.sep + dst_class_relative_path # dst_class_path = file_util.normalize_path(dst_class_path) # # if os.path.isdir(dst_class_path): # shutil.rmtree(dst_class_path) if os.path.isdir(src_class_path): # shutil.copytree(src_class_path, dst_class_path) rev_index = -len(dst_class_relative_path) zip_src_root = src_class_path[:rev_index] zip_util.zip_dir(src_class_path, dst_class_zip_path, zip_src_root) print('success zip {} to {}.'.format( dst_class_relative_path, dst_class_zip_path)) print('built the apk {}.'.format(dst_file)) else: print('build {} failed!'.format(apk_name))
def process(self): git_flag = 'use_git' if not hasattr(self, git_flag): self.use_git = False code_url = self.ori_build_config[BuildConfigParser.ROOT_FLAG][ BuildConfigParser.CODE_URL_FLAG] static_config_path = self.work_path + os.sep + self.ori_build_config[ BuildConfigParser.ROOT_FLAG][BuildConfigParser.STATIC_FLAG] static_config_path = file_util.normalpath(static_config_path) main_prj_name = self.ori_build_config[ BuildConfigParser.WORKSPACE_FLAG][BuildConfigParser.MAIN_FLAG] if self.use_git: self.project_code_path = os.path.join(self.project_path, self.branch) else: self.project_code_path = self.project_path # 进行代码更新操作 if self.to_update: if self.use_git: git.checkout_or_update(self.project_code_path, code_url, self.code_ver, self.branch) else: # 根据参数配置svn用户名和密码 username_flag = 'svn_user' password_flag = 'svn_pwd' if hasattr(self, username_flag) and hasattr( self, password_flag): # print('{}: {}'.format(username_flag, self.svn_user)) # print('{}: {}'.format(password_flag, self.svn_pwd)) svn.set_user_info(getattr(self, username_flag), getattr(self, password_flag)) # 先checkout svn库上代码,再更新和本地相关的配置文件 checkout_or_update_single_item(self.project_code_path, code_url, revision=self.code_ver) # 更新gradle编译配置配置,新框架不再需要该步骤(20161110 17:39) # gradle_setting_name = 'settings.gradle' # gradle_setting_path = static_config_path + os.sep + gradle_setting_name # update_gradle_setting(main_prj_path, gradle_setting_path) # 设置配置信息并获取当前代码版本号 if self.use_git: self.prj_root = git.get_git_root(self.project_code_path) main_prj_path = os.path.join(self.prj_root, main_prj_name) self.code_ver = git.get_revision(self.prj_root) else: self.prj_root = self.project_code_path main_prj_path = os.path.join(self.project_code_path, main_prj_name) self.code_ver = svn.get_revision(self.project_code_path) print('current code version is ' + str(self.code_ver)) if self.to_update: # 更新android sdk本地配置 local_file_name = 'local.properties' local_build_file = os.path.join(static_config_path, local_file_name) target_build_file = os.path.join(self.prj_root, local_file_name) file_util.replace_file(local_build_file, target_build_file) # 进行版本编译操作 if self.to_build: to_check_vals = ['ver_name', 'ver_code', 'ver_env'] for name in to_check_vals: value = getattr(self, name) if not value: info = 'Please specify the {}.'.format(name) print(info) exit(1) # 参数非空判断验证通过开始进行正式业务逻辑 self.pro_build_config = self._get_pro_build_config() self.pre_build() if self.is_debug: mode_flag = apk_builder.DEBUG_FLAG else: mode_flag = apk_builder.RELEASE_FLAG mode = apk_builder.FLAG_MODE_MAP[mode_flag] workspace_map = self.ori_build_config[ BuildConfigParser.WORKSPACE_FLAG] if BuildConfigParser.CHANNEL_INFO_FLAG in workspace_map: res_path = self.work_path + os.sep + workspace_map[ BuildConfigParser.CHANNEL_INFO_FLAG] else: res_path = None if hasattr(self, 'channel_file') and hasattr(self, 'channel'): if self.channel_file: if not os.path.exists(self.channel_file): print('not exist {}'.format(self.channel_file)) exit(1) self.build_app(main_prj_path, self.channel_file, res_path, self.pro_build_config) else: if self.channel: chan_id = self.channel else: chan_id = ProjectBuilder.DEFAULT_CHAN self.build_app(main_prj_path, None, res_path, self.pro_build_config, chan_id, mode) else: chan_id = ProjectBuilder.DEFAULT_CHAN self.build_app(main_prj_path, None, res_path, self.pro_build_config, chan_id, mode) if os.path.exists(self.apk_output_path) and os.path.isfile( self.apk_output_path): # 将编译信息写文件 build_info_format = self.ori_build_config[ BuildConfigParser.BUILD_INFO_TEMPLET_FLAG] build_info = build_info_format.format(ver_name=self.ver_name, code_ver=self.code_ver, ver_code=self.ver_code) build_info_path = self.output_directory + os.sep + 'readme-{}-{}.txt'.format( self.ver_name, self.ver_code) file_util.write_to_file(build_info_path, build_info, encoding='utf-8') target_name = os.path.basename(self.apk_output_path) to_upload_path = os.path.dirname(self.apk_output_path) source_name = os.path.basename(self.apk_output_path) # 有需要则先加固,再签名 if ProjectBuilder.PROTECT_FLAG in self.pro_build_config and ProjectBuilder.SIGNER_FLAG in self.pro_build_config: env_mode = self.pro_build_config[ ProjectBuilder.ENV_MODE_FLAG] if self.pro_build_config[ProjectBuilder.PROTECT_FLAG][ ProjectBuilder.IS_NEED_FLAG][env_mode]: ip = self.pro_build_config[ ProjectBuilder.PROTECT_FLAG][ ProjectBuilder.IP_FLAG] user_name = self.pro_build_config[ ProjectBuilder.PROTECT_FLAG][ ProjectBuilder.USER_FLAG] api_key = self.pro_build_config[ ProjectBuilder.PROTECT_FLAG][ ProjectBuilder.API_KEY_FLAG] api_secret = self.pro_build_config[ ProjectBuilder.PROTECT_FLAG][ ProjectBuilder.API_SECRET_FLAG] protected_path = protect_app.protect( ip, user_name, api_key, api_secret, self.apk_output_path) if hasattr(self, 'to_align') and self.to_align: aligned_path = file_util.get_middle_path( protected_path) apk_util.zipalign(protected_path, aligned_path) to_sign_path = aligned_path else: to_sign_path = protected_path keystore = os.path.join( main_prj_path, self.pro_build_config[ProjectBuilder.SIGNER_FLAG][ ProjectBuilder.KEYSTORE_FLAG]) storepass = self.pro_build_config[ ProjectBuilder.SIGNER_FLAG][ ProjectBuilder.STOREPASS_FLAG] storealias = self.pro_build_config[ ProjectBuilder.SIGNER_FLAG][ ProjectBuilder.STOREALIAS_FLAG] signed_path = apk_util.get_default_signed_path( protected_path) rtn = apk_util.sign_apk(keystore, storepass, storealias, to_sign_path, signed_path) if rtn: str_info = 'Protect {} and sign success.'.format( self.apk_output_path) source_name = os.path.basename(signed_path) else: str_info = 'Protect {} and sign failed!'.format( self.apk_output_path) raise Exception(str_info) print(str_info) str_info = 'Build success, code version is {}.'.format( self.code_ver) print(str_info) # 进行编译好的版本提交操作 if hasattr(self, 'to_upload') and self.to_upload: result = re.match(BuildManager.__APK_OUTPUT_PATH_PATTERN, target_name) if result: ver_name_info = result.group(1) else: str_info = 'The output file name {} is invalid!'.format( target_name) raise Exception(str_info) # ftp_config_path = os.path.join(self.work_path, 'config') ftp_config_path = self.work_path print('ver_name_info:', ver_name_info) print('target_name: ', target_name) print('source_name:', source_name) ftp_upload.upload_to_sftp(ftp_config_path, ver_name_info, self.ver_env, self.code_ver, to_upload_path, 'Android', target_name, source_name) else: str_info = 'Build failed, code version is {}.'.format( self.code_ver) print(str_info)