def __load_category(self, ctg, ctg_cfg, config_app, config_scenario, config_attribute): self[ctg] = {} result = self[ctg] result['name'] = ctg result['pre_check'] = ctg_cfg.get('pre_check', False) result['install'] = ctg_cfg.get('install', False) result['auto_env'] = ctg_cfg.get('auto_env', False) result['version_dir'] = ctg_cfg.get('version_dir', False) result['shared'] = ctg_cfg.get('shared', False) if 'root' not in ctg_cfg: result['install'] = False result['auto_env'] = False result['shared'] = False return format_dict = {} format_dict.update(config_attribute) format_dict.update(config_scenario) result['root'] = expand_path(ctg_cfg['root'].format(**format_dict)) result['work_dir'] = os.path.join(result['root'], config_app['category_work_dir']) if result['shared']: result['config_package_dir'] = os.path.join( result['work_dir'], 'shared') else: result['config_package_dir'] = os.path.join( result['work_dir'], 'release', config_scenario['version']) result['install_dir'] = os.path.join(result['work_dir'], 'install')
def __init__(self, app_root): super(App, self).__init__() if app_root: self.__load_app_root(expand_path(app_root)) self.__load_bsm_default() self.__set_default()
def __load_user(self): cfg = ConfigCommonDict() config_user_file = self['app']['config_user_file'] if 'config_user_file' in self['entry']: config_user_file = self['entry']['config_user_file'] cfg.load_from_file(expand_path(config_user_file)) return cfg
def run(param): release_version = param['config_scenario']['version'] if len(param['command']) > 1: destination = param['command'][1] else: destination = os.getcwd() destination = expand_path(destination) pack_dir = os.path.join(destination, 'pack_' + release_version) for category in param['config_package_install']: for subdir in param['config_package_install'][category]: for package in param['config_package_install'][category][subdir]: for version, value in param['config_package_install'][ category][subdir][package].items(): pkg_cfg = value['config_origin'] download = pkg_cfg.get('install', {}).get('download') if not download: continue url = pkg_cfg.get('source', {}).get('url') if not url: continue pkg_dir = os.path.join(pack_dir, package, version) safe_mkdir(pkg_dir) _logger.info('Packing {0}...'.format(package)) if download == 'http': url = url.format(version=version) pkg_file = _download_http(url, pkg_dir) elif download == 'svn': url = url.format(version=version) pkg_file = _download_svn(url, pkg_dir, package, version) elif download == 'git': tag = pkg_cfg.get('source', {}).get('tag', 'master') tag = tag.format(version=version) pkg_file = _download_git(url, tag, pkg_dir, package, version) else: _logger.warn('Package {0} not packed'.format(package)) continue with open(os.path.join(pkg_dir, 'md5sum.txt'), 'w') as f: call(['md5sum', pkg_file], cwd=pkg_dir, stdout=f) with open(os.path.join(pkg_dir, 'sha1sum.txt'), 'w') as f: call(['sha1sum', pkg_file], cwd=pkg_dir, stdout=f) with open(os.path.join(pkg_dir, 'url.txt'), 'w') as f: f.write(url + '\n') _logger.info('Package {0} packed'.format(package)) _logger.info('All packages in version {0} packed in {1}'.format( release_version, pack_dir))
def __load_user(self): self.__config['user'] = ConfigCommon() config_user_file = self['app']['config_user_file'] if 'config_user_file' in self['entry']: config_user_file = self['entry']['config_user_file'] self['user'].load_from_file(expand_path(config_user_file)) if 'config_user' in self['entry']: self['user'] = copy.deepcopy(self['entry']['config_user'])
def execute(self): self._config['info']['default'] = {} self._config['info']['default']['scenario'] = self._config[ 'entry'].get('scenario') self._config['info']['default']['software_root'] = self._config[ 'entry'].get('software_root') self._config['info']['default']['option'] = self._config['entry'].get( 'option', {}) self._config['info'].save_to_file( expand_path(self._config['app']['config_info_file']))
def execute(self, config_user, config_version, destination): release_version = config_version.get('version') try: config_release = ConfigRelease(config_version) except ConfigReleaseError: _logger.debug( 'Install release definition: {0}'.format(release_version)) install = Install(config_user, config_version) config_release = install.config_release() self.__pkg_mgr = PackageManager(config_version, config_release) if not destination: destination = os.getcwd() destination = expand_path(destination) pack_dir = os.path.join(destination, 'pack_' + release_version) for pkg, pkg_info in self.__pkg_mgr.package_all().items(): version = pkg_info.get('package', {}).get('version') if not version: continue download = pkg_info.get('install', {}).get('download') if not download: continue url = download.get('param', {}).get('url') if not url: continue url = url.format(version=version) pkg_dir = os.path.join(pack_dir, pkg, version) safe_mkdir(pkg_dir) _logger.info('Packing {0}...'.format(pkg)) if download.get('handler') == 'http': pkg_file = _download_http(url, pkg_dir) elif download.get('handler') == 'svn': pkg_file = _download_svn(url, pkg_dir, pkg, version) with open(os.path.join(pkg_dir, 'md5sum.txt'), 'w') as f: call(['md5sum', pkg_file], cwd=pkg_dir, stdout=f) with open(os.path.join(pkg_dir, 'sha1sum.txt'), 'w') as f: call(['sha1sum', pkg_file], cwd=pkg_dir, stdout=f) with open(os.path.join(pkg_dir, 'url.txt'), 'w') as f: f.write(url + '\n') _logger.info('Package {0} packed'.format(pkg)) _logger.info('All packages in version {0} packed in {1}'.format( release_version, pack_dir))
def detect_category(config_category, directory): dir_expand = expand_path(directory) root_found = None category_found = None for ctg, cfg in config_category.items(): if 'root' in cfg and dir_expand.startswith(cfg['root']): root_found = cfg['root'] category_found = ctg break if category_found is None: return None, None rest_dir = dir_expand[len(root_found):].strip(os.sep) return category_found, rest_dir
def _find_git(git_temp=None): try: _git_cmd(None, 'git', 'version') _logger.debug('Use system git') return 'git' except Exception as e: pass if git_temp is not None: try: _git_cmd(None, expand_path(git_temp), 'version') _logger.debug('Use temporary git from {0}'.format(git_temp)) return git_temp except Exception as e: pass _logger.error('Git command not found') raise GitNotFoundError('Can not find git command')
def __load_info(self): self.__config['info'] = ConfigCommon() self['info'].load_from_file(expand_path(self['app']['config_info_file']))
def __load_info(self): cfg = ConfigCommonDict() cfg.load_from_file(expand_path(self['app']['config_info_file'])) return cfg
def __expand_path(self): for k in _SCENARIO_PATH_ITEMS: if k in self: self[k] = expand_path(self[k])
def load(self, app_root): if app_root: self.__load_app_root(expand_path(app_root)) self.__load_bsm_default() self.__set_default()