Permalink
Browse files

Allow conda_install to take in --conda_auto_init.

  • Loading branch information...
jmchilton committed Aug 31, 2016
1 parent 07d94bd commit ca19910c64298611e351e9ea36104117eee6c3c2
Showing with 23 additions and 1 deletion.
  1. +20 −1 planemo/commands/cmd_conda_install.py
  2. +3 −0 planemo/exit_codes.py
@@ -6,16 +6,35 @@
from planemo import options
from planemo.cli import command_function
from planemo.conda import build_conda_context, collect_conda_targets
from planemo.io import coalesce_return_codes
from planemo.exit_codes import EXIT_CODE_FAILED_DEPENDENCIES, ExitCodeException
from planemo.io import coalesce_return_codes, error


@click.command('conda_install')
@options.optional_tools_arg()
@options.conda_target_options()
@options.conda_auto_init_option()
@command_function
def cli(ctx, path, **kwds):
"""Install conda packages for tool requirements."""
conda_context = build_conda_context(ctx, **kwds)
if not conda_context.is_conda_installed():
auto_init = kwds.get("conda_auto_init", False)
failed = True
if auto_init:
if conda_context.can_install_conda():
if conda_util.install_conda(conda_context):
error("Attempted to install conda and failed.")
else:
failed = False
else:
error("Cannot install conda, failing conda_install.")
else:
error("Conda not configured - run planemo conda_init' or pass --conda_auto_init to continue.")

if failed:
raise ExitCodeException(EXIT_CODE_FAILED_DEPENDENCIES)

return_codes = []
for conda_target in collect_conda_targets(path):
ctx.log("Install conda target %s" % conda_target)
@@ -15,6 +15,9 @@
# An unsupported file type was supplied for a given operation.
EXIT_CODE_UNSUPPORTED_FILE_TYPE = 5

# A dependency of this operation was unavailable (e.g. conda).
EXIT_CODE_FAILED_DEPENDENCIES = 6


class ExitCodeException(Exception):
"""Exception used by planemo framework to track exit codes for CLI."""

0 comments on commit ca19910

Please sign in to comment.