How to use the planemo.io.shell function in planemo

To help you get started, we’ve selected a few planemo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github galaxyproject / planemo / tests / test_shed_upload.py View on Github external
def test_tar_from_git(self):
        with self._isolate() as f:
            with self._git_configured():
                dest = join(f, "single_tool")
                self._copy_repo("single_tool", dest)
                shell(" && ".join([
                    "cd %s" % dest,
                    "git init",
                    "git add .",
                    "git commit -m 'initial commit'"
                ]))
                upload_command = [
                    "shed_update", "--force_repository_creation",
                    "git+single_tool/.git"
                ]
                upload_command.extend(self._shed_args())
                self._check_exit_code(upload_command)
                self._verify_single_uploaded(f, ["single_tool"])
github galaxyproject / planemo / planemo / shed / __init__.py View on Github external
new_kwds = kwds.copy()
        new_kwds["shed_target"] = shed_target_source
        shed_context = get_shed_context(ctx, read_only=True, **new_kwds)
        download_tarball(
            ctx,
            shed_context,
            realized_repository,
            destination=mine,
            clean=True,
            destination_is_pattern=False,
            **new_kwds
        )
    else:
        tar_path = build_tarball(path)
        os.mkdir(mine)
        shell(['tar', '-xzf', tar_path, '-C', mine])
        shutil.rmtree(tar_path, ignore_errors=True)

    output = kwds.get("output")
    raw = kwds.get("raw", False)
    xml_diff = 0
    if not raw:
        if output:
            with open(output, "w") as f:
                xml_diff = diff_and_remove(working, label_a, label_b, f)
        else:
            xml_diff = diff_and_remove(working, label_a, label_b, sys.stdout)

    cmd = 'cd "%s"; diff -r %s %s' % (working, label_a, label_b)
    if output:
        cmd += " >> '%s'" % output
    raw_diff = shell(cmd)
github galaxyproject / planemo / planemo / galaxy / config.py View on Github external
def _ensure_galaxy_repository_available(ctx, kwds):
    workspace = ctx.workspace
    cwl = kwds.get("cwl", False)
    galaxy_source = kwds.get('galaxy_source')
    if galaxy_source and galaxy_source != DEFAULT_GALAXY_SOURCE:
        sanitized_repo_name = "".join(c if c.isalnum() else '_' for c in kwds['galaxy_source']).rstrip()[:255]
        gx_repo = os.path.join(workspace, "gx_repo_%s" % sanitized_repo_name)
    else:
        gx_repo = os.path.join(workspace, "gx_repo")
    if cwl:
        gx_repo += "_cwl"
    if os.path.exists(gx_repo):
        # Convert the git repository from bare to mirror, if needed
        shell(['git', '--git-dir', gx_repo, 'config', 'remote.origin.fetch', '+refs/*:refs/*'])
        shell(['git', '--git-dir', gx_repo, 'config', 'remote.origin.mirror', 'true'])
        # Attempt remote update - but don't fail if not interweb, etc...
        shell("git --git-dir %s remote update >/dev/null 2>&1" % gx_repo)
    else:
        remote_repo = _galaxy_source(kwds)
        command = git.command_clone(ctx, remote_repo, gx_repo, mirror=True)
        shell(command)
    return gx_repo
github galaxyproject / planemo / planemo / git.py View on Github external
def is_rev_dirty(ctx, directory):
    """Check if specified git repository has uncommitted changes."""
    # TODO: Use ENV instead of cd.
    cmd = "cd '%s' && git diff --quiet" % directory
    return io.shell(cmd) != 0
github galaxyproject / planemo / planemo / conda.py View on Github external
def build_conda_context(ctx, **kwds):
    """Build a galaxy-lib CondaContext tailored to planemo use.

    Using planemo's common command-line/global config options.
    """
    condarc_override_default = os.path.join(ctx.workspace, "condarc")
    conda_prefix = kwds.get("conda_prefix", None)
    use_planemo_shell = kwds.get("use_planemo_shell_exec", True)
    ensure_channels = kwds.get("conda_ensure_channels", "")
    condarc_override = kwds.get("condarc", condarc_override_default)
    use_local = kwds.get("conda_use_local", False)
    shell_exec = shell if use_planemo_shell else None
    conda_context = conda_util.CondaContext(conda_prefix=conda_prefix,
                                            ensure_channels=ensure_channels,
                                            condarc_override=condarc_override,
                                            use_local=use_local,
                                            shell_exec=shell_exec)
    handle_auto_init = kwds.get("handle_auto_init", False)
    if handle_auto_init and not conda_context.is_installed():
        auto_init = kwds.get("conda_auto_init", True)
        failed = True
        if auto_init:
            if conda_context.can_install_conda():
                if conda_util.install_conda(conda_context):
                    error(MESSAGE_ERROR_FAILED_INSTALL)
                else:
                    failed = False
            else:
github galaxyproject / planemo / planemo / commands / cmd_travis_before_install.py View on Github external
build_env = string.Template(BUILD_ENVIRONMENT_TEMPLATE).safe_substitute(
        **template_vars
    )
    open(build_env_path, "a").write(build_env)

    eggs_dir = os.path.join(os.getenv('HOME'), '.python-eggs')
    if not os.path.exists(eggs_dir):
        os.makedirs(eggs_dir, 0o700)
    else:
        os.chmod(eggs_dir, 0o700)
    # samtools essentially required by Galaxy
    shell(['wget', SAMTOOLS_URL])
    shell(['sudo', 'dpkg', '-i', SAMTOOLS_DEB])
    setup_file = os.path.join(build_travis_dir, SETUP_FILE_NAME)
    if os.path.exists(setup_file):
        shell(
            ". %s && bash -x %s" % (build_env_path, setup_file),
            env=template_vars
        )
github galaxyproject / planemo / planemo / galaxy / config.py View on Github external
def _install_with_command(ctx, command, galaxy_root, env, kwds):
    setup_venv_command = setup_venv(ctx, kwds)
    env['__PYVENV_LAUNCHER__'] = ''
    install_cmd = shell_join(
        command,
        ['cd', galaxy_root],
        setup_venv_command,
        setup_common_startup_args(),
        COMMAND_STARTUP_COMMAND,
    )
    shell(install_cmd, env=env)