コード例 #1
0
def repository_spec_from_find_results(find_results, requirement_spec):
    '''Create a new RepositorySpec with updated info from fetch_results.

    Evolves repository_spec to match fetch results.'''

    # TODO: do we still need to check the fetched version against the spec version?
    #       We do, since the unspecific version is None, so fetched versions wont match
    #       so we need a new repository_spec for install.
    # TODO: this is more or less a verify/validate step or state transition
    content_data = find_results.get('content', {})
    resolved_version = content_data.get('version')

    log.debug(
        'version_spec "%s" for %s was requested and was resolved to version "%s"',
        requirement_spec.version_spec, requirement_spec.label,
        resolved_version)

    # In theory, a fetch can return a different namespace/name than the one request. This
    # is for things like server side aliases.
    resolved_name = content_data.get('fetched_name', requirement_spec.name)
    resolved_namespace = content_data.get('content_namespace',
                                          requirement_spec.namespace)

    # Build a RepositorySpec based on RequirementSpec and the extra info resolved in find()
    spec_data = attr.asdict(requirement_spec)

    del spec_data['version_spec']

    spec_data['version'] = resolved_version
    spec_data['namespace'] = resolved_namespace
    spec_data['name'] = resolved_name

    repository_spec = RepositorySpec.from_dict(spec_data)
    return repository_spec
コード例 #2
0
def load(data_or_file_object, repository_spec=None):
    log.debug('START of load of requirements %s', data_or_file_object.name)

    requirements_data = yaml.safe_load(data_or_file_object)

    # log.debug('requirements_data: %s', pprint.pformat(requirements_data))

    requirements_list = []

    for req_data_item in requirements_data:
        # log.debug('req_data_item: %s', req_data_item)
        # log.debug('type(req_data_item): %s', type(req_data_item))

        req_spec_data = yaml_parse.yaml_parse(req_data_item)
        # log.debug('req_spec_data: %s', req_spec_data)

        # name_info = content_name.parse_content_name(data_name)
        # log.debug('data_name (after): %s', data_name)
        # log.debug('name_info: %s', name_info)

        req_spec = RepositorySpec.from_dict(req_spec_data)

        # log.debug('req_spec: %s', req_spec)

        req = Requirement(repository_spec=repository_spec,
                          op=RequirementOps.EQ,
                          requirement_spec=req_spec)

        # log.debug('req: %s', req)

        requirements_list.append(req)

    log.debug('FINISH of load of requirements: %s: %s',
              data_or_file_object.name, requirements_list)
    return requirements_list
コード例 #3
0
ファイル: dependencies.py プロジェクト: trishnaguha/mazer
def from_dependency_spec_strings(dependency_spec_strings, namespace_override=None, editable=False):
    deps = []
    for dep_spec_string in dependency_spec_strings:
        dep_spec_data = spec_data_from_string(dep_spec_string)

        log.debug('dep_spec_data: %s', dep_spec_data)

        dep_spec = RepositorySpec.from_dict(dep_spec_data)

        log.debug('dep_spec: %s', dep_spec)

        # Add a requirement, but with the 'RUNTIME' scope
        requirement = Requirement(repository_spec=None, op=RequirementOps.EQ,
                                  scope=RequirementScopes.RUNTIME,
                                  requirement_spec=dep_spec)
        deps.append(requirement)

    return deps
コード例 #4
0
def from_requirement_spec_strings(requirement_spec_strings,
                                  namespace_override=None,
                                  editable=False,
                                  repository_spec=None):
    reqs = []
    for requirement_spec_string in requirement_spec_strings:
        req_spec_data = spec_data_from_string(
            requirement_spec_string,
            namespace_override=namespace_override,
            editable=editable)

        req_spec = RepositorySpec.from_dict(req_spec_data)

        req = Requirement(repository_spec=repository_spec,
                          op=RequirementOps.EQ,
                          requirement_spec=req_spec)

        reqs.append(req)

    return reqs
コード例 #5
0
ファイル: install.py プロジェクト: trishnaguha/mazer
def install_repository_specs_loop(
        galaxy_context,
        repository_spec_strings=None,
        requirements_list=None,
        editable=False,
        namespace_override=None,
        display_callback=None,
        # TODO: error handling callback ?
        ignore_errors=False,
        no_deps=False,
        force_overwrite=False):

    requirements_list = requirements_list or []

    for repository_spec_string in repository_spec_strings:
        fetch_method = \
            repository_spec.choose_repository_fetch_method(repository_spec_string,
                                                           editable=editable)
        log.debug('fetch_method: %s', fetch_method)

        if fetch_method == FetchMethods.LOCAL_FILE:
            # Since only know this is a local file we vaguely recognize, we have to
            # open it up to get any more details. We _could_ attempt to parse the file
            # name, but that rarely ends well...
            spec_data = collection_artifact.load_data_from_collection_artifact(
                repository_spec_string)
            spec_data['fetch_method'] = fetch_method
        else:
            spec_data = repository_spec.spec_data_from_string(
                repository_spec_string,
                namespace_override=namespace_override,
                editable=editable)

            spec_data['fetch_method'] = fetch_method

        log.debug('spec_data: %s', spec_data)

        req_spec = RepositorySpec.from_dict(spec_data)

        req = Requirement(repository_spec=None,
                          op=RequirementOps.EQ,
                          requirement_spec=req_spec)

        requirements_list.append(req)

    log.debug('requirements_list: %s', requirements_list)
    for req in requirements_list:
        display_callback('Installing %s' % req.requirement_spec.label,
                         level='info')

    while True:
        if not requirements_list:
            break

        just_installed_repositories = \
            install_repositories_matching_repository_specs(galaxy_context,
                                                           requirements_list,
                                                           editable=editable,
                                                           namespace_override=namespace_override,
                                                           display_callback=display_callback,
                                                           ignore_errors=ignore_errors,
                                                           no_deps=no_deps,
                                                           force_overwrite=force_overwrite)

        # set the repository_specs to search for to whatever the install reported as being needed yet
        # requirements_list = new_requirements_list
        requirements_list = find_new_deps_from_installed(
            galaxy_context, just_installed_repositories, no_deps=no_deps)

        for req in requirements_list:
            if req.repository_spec:
                msg = 'Installing requirement %s (required by %s)' % (
                    req.requirement_spec.label, req.repository_spec.label)
            else:
                msg = 'Installing requirement %s' % req.requirement_spec.label
            display_callback(msg, level='info')

    # FIXME: what results to return?
    return 0