Exemple #1
0
    def execute(self, config, 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, 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))
Exemple #2
0
def load_main(options_common):
    config = {}

    config_file = options_common.get('config_file')
    if config_file:
        try:
            c = load_config(expand_path(config_file))
            if not isinstance(c, dict):
                c = {}
            config.update(c)
        except:
            pass

    # The final verbose value: config['verbose'] || verbose
    if ('verbose' not in config) or (not config['verbose']):
        config['verbose'] = options_common.get('verbose', False)

    return config
Exemple #3
0
    def __init__(self, info_file='~/.cepcenv.info'):
        self.__info_file = expand_path(info_file)

        self.__load_info()
Exemple #4
0
 def __expand_path(self):
     for k in _PATH_ITEMS:
         if k in self.__config_version:
             self.__config_version[k] = expand_path(
                 self.__config_version[k])