Example #1
0
def __externalize_commands(job_wrapper, shell, commands_builder, remote_command_params, script_name="tool_script.sh"):
    local_container_script = join( job_wrapper.working_directory, script_name )
    tool_commands = commands_builder.build()
    config = job_wrapper.app.config
    integrity_injection = ""
    # Setting shell to none in job_conf.xml disables creating a tool command script,
    # set -e doesn't work for composite commands but this is necessary for Windows jobs
    # for instance.
    if shell and shell.lower() == 'none':
        return tool_commands
    if check_script_integrity(config):
        integrity_injection = INTEGRITY_INJECTION
    set_e = ""
    if job_wrapper.strict_shell:
        set_e = "set -e\n"
    script_contents = u"#!%s\n%s%s%s" % (
        shell,
        integrity_injection,
        set_e,
        tool_commands
    )
    write_script(local_container_script, script_contents, config)
    commands = local_container_script
    if 'working_directory' in remote_command_params:
        commands = "%s %s" % (shell, join(remote_command_params['working_directory'], script_name))
    log.info("Built script [%s] for tool command[%s]" % (local_container_script, tool_commands))
    return commands
Example #2
0
def __externalize_commands(job_wrapper,
                           shell,
                           commands_builder,
                           remote_command_params,
                           script_name="tool_script.sh"):
    local_container_script = join(job_wrapper.working_directory, script_name)
    tool_commands = commands_builder.build()
    config = job_wrapper.app.config
    integrity_injection = ""
    # Setting shell to none in job_conf.xml disables creating a tool command script,
    # set -e doesn't work for composite commands but this is necessary for Windows jobs
    # for instance.
    if shell and shell.lower() == 'none':
        return tool_commands
    if check_script_integrity(config):
        integrity_injection = INTEGRITY_INJECTION
    set_e = ""
    if job_wrapper.strict_shell:
        set_e = "set -e\n"
    script_contents = u"#!%s\n%s%s%s" % (shell, integrity_injection, set_e,
                                         tool_commands)
    write_script(local_container_script, script_contents, config)
    commands = local_container_script
    if 'working_directory' in remote_command_params:
        commands = "%s %s" % (shell,
                              join(remote_command_params['working_directory'],
                                   script_name))
    log.info("Built script [%s] for tool command [%s]" %
             (local_container_script, tool_commands))
    return commands
Example #3
0
def __externalize_commands(job_wrapper,
                           shell,
                           commands_builder,
                           remote_command_params,
                           script_name="tool_script.sh"):
    local_container_script = join(job_wrapper.working_directory, script_name)
    tool_commands = commands_builder.build()
    config = job_wrapper.app.config
    integrity_injection = ""
    if check_script_integrity(config):
        integrity_injection = INTEGRITY_INJECTION
    set_e = ""
    if job_wrapper.strict_shell:
        set_e = "set -e\n"
    script_contents = u"#!%s\n%s%s%s" % (shell, integrity_injection, set_e,
                                         tool_commands)
    write_script(local_container_script, script_contents, config)
    commands = local_container_script
    if 'working_directory' in remote_command_params:
        commands = "%s %s" % (shell,
                              join(remote_command_params['working_directory'],
                                   script_name))
    log.info("Built script [%s] for tool command[%s]" %
             (local_container_script, tool_commands))
    return commands
Example #4
0
def __externalize_commands(job_wrapper,
                           shell,
                           commands_builder,
                           remote_command_params,
                           script_name="tool_script.sh",
                           container=None):
    local_container_script = join(job_wrapper.working_directory, script_name)
    tool_commands = commands_builder.build()
    config = job_wrapper.app.config
    integrity_injection = ""
    # Setting shell to none in job_conf.xml disables creating a tool command script,
    # set -e doesn't work for composite commands but this is necessary for Windows jobs
    # for instance.
    if shell and shell.lower() == 'none':
        return tool_commands
    if check_script_integrity(config):
        integrity_injection = INTEGRITY_INJECTION
    set_e = ""
    if job_wrapper.strict_shell:
        set_e = "set -e\n"
    source_command = ""
    if container:
        source_command = container.source_environment
    script_contents = "#!{}\n{}{}{}{}".format(
        shell,
        integrity_injection,
        set_e,
        source_command,
        tool_commands,
    )
    write_script(local_container_script, script_contents, config)
    commands = "{} {}".format(shell, local_container_script)
    # TODO: Cleanup for_pulsar hack.
    # - Integrate Pulsar sending tool_stdout/tool_stderr back
    #   https://github.com/galaxyproject/pulsar/pull/202
    # *and*
    # - Get Galaxy to write these files to an output directory so the container itself
    #   doesn't need to mount the job directory (rw) and then eliminate this hack
    #   (or restrict to older Pulsar versions).
    #   https://github.com/galaxyproject/galaxy/pull/8449
    for_pulsar = False
    if 'script_directory' in remote_command_params:
        commands = "{} {}".format(
            shell, join(remote_command_params['script_directory'],
                        script_name))
        for_pulsar = True
    if not for_pulsar:
        commands += " > ../outputs/tool_stdout 2> ../outputs/tool_stderr"
    log.info("Built script [{}] for tool command [{}]".format(
        local_container_script, tool_commands))
    return commands
Example #5
0
def __externalize_commands(job_wrapper, passwordIS, shell, commands_builder, remote_command_params, script_name="tool_script.sh"):
    local_container_script = join( job_wrapper.working_directory, script_name )
    tool_commands = commands_builder.build()
    config = job_wrapper.app.config
    integrity_injection = ""
    # Setting shell to none in job_conf.xml disables creating a tool command script,
    # set -e doesn't work for composite commands but this is necessary for Windows jobs
    # for instance.
    if shell and shell.lower() == 'none':
        return tool_commands
    if check_script_integrity(config):
        integrity_injection = INTEGRITY_INJECTION
    set_e = ""
    if job_wrapper.strict_shell:
        set_e = "set -e\n"
	
    ####
#    tool_commands = str(tool_commands)
    envVar = ''
    envVar = "PASS="******"PASS="******"'+passVar + '"'
#        indexSoFar = end +1
#	tool_commands = tool_commands.replace(passVar, '$PASS')
#        tool_commands = tool_commands.replace('JPCNn681vcGV4KuvuT16 ', '')

	####

    script_contents = u"#!%s\n%s%s%s\n%s" % (
        shell,
        integrity_injection,
        set_e,
	envVar,
        tool_commands
    )
    write_script(local_container_script, script_contents, config)
    #print local_container_script
    commands = local_container_script
    #print "From command factory, commands: " + commands
    if 'working_directory' in remote_command_params:
        commands = "%s %s" % (shell, join(remote_command_params['working_directory'], script_name))
    log.info("Built script [%s] for tool command[%s]" % (local_container_script, tool_commands))
    return commands
Example #6
0
def __externalize_commands(job_wrapper, shell, commands_builder, remote_command_params, script_name="tool_script.sh"):
    local_container_script = join( job_wrapper.working_directory, script_name )
    tool_commands = commands_builder.build()
    config = job_wrapper.app.config
    integrity_injection = ""
    if check_script_integrity(config):
        integrity_injection = INTEGRITY_INJECTION
    script_contents = u"#!%s\n%s%s" % (shell, integrity_injection, tool_commands)
    write_script(local_container_script, script_contents, config)
    commands = local_container_script
    if 'working_directory' in remote_command_params:
        commands = "%s %s" % (shell, join(remote_command_params['working_directory'], script_name))
    log.info("Built script [%s] for tool command[%s]" % (local_container_script, tool_commands))
    return commands