def _get_install_path_with_no_package(self): """ Get version info from version file with relative path :return: """ version_file = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname( os.path.dirname(os.path.realpath(__file__))))), Constant.VERSION_FILE) version = CommonTools.get_version_info_from_file(version_file) g.logger.info('Got version info:%s' % version) base_dir = Constant.PACK_PATH_PREFIX + version install_path = os.path.join(self.project_path, base_dir) g.logger.info('Got install path:%s.' % install_path) CommonTools.check_path_valid(install_path) g.logger.info('Successfully to get install path.') return install_path, version
def _get_install_info(): """ Get installed information from record file. install time | install version | install path """ install_time, install_version, install_path = '', '', '' if not os.path.isfile(VERSION_RECORD_FILE_INDEX_ADVISOR): raise Exception( Errors.FILE_DIR_PATH['gauss_0102'] % VERSION_RECORD_FILE_INDEX_ADVISOR) install_info = CommonTools.read_last_line_from_file( VERSION_RECORD_FILE_INDEX_ADVISOR).strip() if install_info: install_time, install_version, install_path = install_info.split('|') # check path valid CommonTools.check_path_valid(install_path) if not os.path.isdir(install_path): raise Exception(Errors.FILE_DIR_PATH['gauss_0103'] % install_path) else: g.logger.info('Successfully got index advisor install path[%s].' % install_path) return install_time, install_version, install_path
def _get_install_path(self, pack_path): """ Extract version info and assembling install path. """ g.logger.info('Start getting install path.') # mk temp extract dir if not exist CommonTools.mkdir_with_mode(EXTRACT_DIR, Constant.AUTH_COMMON_DIR_STR) # clean extract dir CommonTools.clean_dir(EXTRACT_DIR) # extract package file to temp dir CommonTools.extract_file_to_dir(pack_path, EXTRACT_DIR) g.logger.info('Success extract files to temp dir.') # get version info from version file version_file = os.path.realpath(os.path.join(EXTRACT_DIR, Constant.VERSION_FILE)) version = CommonTools.get_version_info_from_file(version_file) g.logger.info('Got version info:%s' % version) base_dir = Constant.PACK_PATH_PREFIX + version install_path = os.path.join(self.project_path, base_dir) g.logger.info('Got install path:%s.' % install_path) CommonTools.check_path_valid(install_path) g.logger.info('Successfully to get install path.') return install_path, version