Skip to content

Commit

Permalink
Merge Planemo and Galaxy tools.deps changes (and a PEP-8 fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
natefoo committed Oct 29, 2015
1 parent 36eb114 commit a9d79b3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
8 changes: 7 additions & 1 deletion lib/galaxy/tools/deps/commands.py
Expand Up @@ -3,15 +3,21 @@


def shell(cmds, env=None):
p = shell_process(cmds, env)
return p.wait()


def shell_process(cmds, env=None, **kwds):
popen_kwds = dict(
shell=True,
)
popen_kwds.update(**kwds)
if env:
new_env = os.environ.copy()
new_env.update(env)
popen_kwds["env"] = new_env
p = subprocess.Popen(cmds, **popen_kwds)
return p.wait()
return p


def execute(cmds):
Expand Down
12 changes: 12 additions & 0 deletions lib/galaxy/tools/deps/docker_util.py
Expand Up @@ -76,6 +76,15 @@ def build_save_image_command(
return build_command_parts


def build_pull_command(
tag,
**kwds
):
build_command_parts = __docker_prefix(**kwds)
build_command_parts.extend(["pull", tag])
return build_command_parts


def build_docker_cache_command(
image,
**kwds
Expand Down Expand Up @@ -109,6 +118,7 @@ def build_docker_run_command(
container_command,
image,
interactive=False,
terminal=False,
tag=None,
volumes=[],
volumes_from=DEFAULT_VOLUMES_FROM,
Expand All @@ -134,6 +144,8 @@ def build_docker_run_command(
command_parts.append("run")
if interactive:
command_parts.append("-i")
if terminal:
command_parts.append("-t")
for env_directive in env_directives:
command_parts.extend(["-e", env_directive])
for volume in volumes:
Expand Down
17 changes: 11 additions & 6 deletions lib/galaxy/tools/deps/dockerfiles.py
Expand Up @@ -39,11 +39,16 @@ def dockerfile_build(path, dockerfile=None, error=log.error, **kwds):
image_identifier = expected_container_names.pop()

dockerfile = __find_dockerfile(dockerfile, tool_directories)
docker_command_parts = docker_util.build_command(
image_identifier,
dockerfile,
**docker_host_args(**kwds)
)
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:
Expand All @@ -67,4 +72,4 @@ def __find_dockerfile(dockerfile, tool_directories):
potential_dockerfile = os.path.join(directory, "Dockerfile")
if os.path.exists(potential_dockerfile):
return potential_dockerfile
raise Exception("Could not find dockerfile to build.")
return None
4 changes: 2 additions & 2 deletions lib/galaxy/tools/deps/resolvers/modules.py
Expand Up @@ -8,7 +8,7 @@
"""
from os import environ, pathsep
from os.path import exists, isdir, join
from StringIO import StringIO
from six import StringIO
from subprocess import Popen, PIPE

from ..resolvers import DependencyResolver, INDETERMINATE_DEPENDENCY, Dependency
Expand Down Expand Up @@ -112,7 +112,7 @@ def has_module(self, module, version):
return False

def __modules(self):
raw_output = self.__module_avail_output()
raw_output = self.__module_avail_output().decode("utf-8")
for line in StringIO(raw_output):
line = line and line.strip()
if not line or line.startswith("-"):
Expand Down

0 comments on commit a9d79b3

Please sign in to comment.