def load_one_dir(path): tools_in_dir = [] tool_elems = load_tool_elements_from_path(path, load_exception_handler=debug_handler) if tool_elems: for elem in tool_elems: root = elem[1].getroot() if root.tag == 'tool': tool = {} if root.find('help') is not None: tool.update(dict(help=unicodify(root.find('help').text))) if root.find('description') is not None: tool.update(dict(description=unicodify(root.find('description').text))) tool.update(dict(id=unicodify(root.attrib.get('id')), name=unicodify(root.attrib.get('name')), version=unicodify(root.attrib.get('version')))) tools_in_dir.append(tool) return tools_in_dir
def cli(ctx, path, brew=None): """Install tool requirements using brew. An experimental approach to versioning brew recipes will be used. See full discussion on the homebrew-science issues page here - https://github.com/Homebrew/homebrew-science/issues/1191. Information on the implementation can be found at https://github.com/jmchilton/platform-brew until a more permanent project home is setup. """ for (tool_path, tool_xml) in load_tool_elements_from_path(path): ctx.log('Brewing requirements from tool %s', click.format_filename(tool_path)) mock_args = bunch.Bunch(brew=brew) brew_context = brew_exts.BrewContext(mock_args) requirements, containers = parse_requirements_from_xml(tool_xml) for recipe_context in brew_util.requirements_to_recipe_contexts( requirements, brew_context): brew_exts.versioned_install(recipe_context)
def dockerfile_build(path, dockerfile=None, error=log.error, **kwds): expected_container_names = set() tool_directories = set() for (tool_path, tool_xml) in load_tool_elements_from_path(path): requirements, containers = parse_requirements_from_xml(tool_xml) for container in containers: if container.type == "docker": expected_container_names.add(container.identifier) tool_directories.add(os.path.dirname(tool_path)) break if len(expected_container_names) == 0: error("Could not find any docker identifiers to generate.") if len(expected_container_names) > 1: error( "Multiple different docker identifiers found for selected tools [%s]", expected_container_names) image_identifier = expected_container_names.pop() dockerfile = __find_dockerfile(dockerfile, tool_directories) if dockerfile is not None: docker_command_parts = docker_util.build_command( image_identifier, dockerfile, **docker_host_args(**kwds)) else: docker_command_parts = docker_util.build_pull_command( image_identifier, **docker_host_args(**kwds)) commands.execute(docker_command_parts) commands.execute(docker_command_parts) docker_image_cache = kwds['docker_image_cache'] if docker_image_cache: destination = docker_cache_path(docker_image_cache, image_identifier) save_image_command_parts = docker_util.build_save_image_command( image_identifier, destination, **docker_host_args(**kwds)) commands.execute(save_image_command_parts)