Пример #1
0
def test_help():
    returncode, stdout, stderr = exec_command(
        ['dcos-cassandra', 'cassandra', '--help'])

    assert returncode == 0
    assert stdout.startswith(b"Usage:")
    assert stderr == b''
Пример #2
0
def test_help():
    returncode, stdout, stderr = exec_command(
        ['dcos-kubectl', 'kubectl', '--help'])

    assert returncode == 0

    expected_first_line = b'kubectl controls the Kubernetes cluster manager'
    assert stdout.startswith(expected_first_line)
    assert stderr == b''
Пример #3
0
def _exec_shark(msg, cmdline):
    logger.info('%s with command line: %s', msg,
                subprocess.list2cmdline(cmdline))
    out, err, code = common.exec_command(cmdline)
    if code != 0:
        logger.error(
            'Error while executing %s (exit code %d):\n' +
            'stdout:\n%s\nstderr:\n%s', cmdline[0], code, b2s(out), b2s(err))
        raise RuntimeError('%s error' % cmdline[0])
Пример #4
0
def uploadBinary(logger):
    cmd = "st-flash write {}/kernel.bin 0x8000000 2>&1 | tee -a {}/logs/buildLog"
    output = common.exec_command(cmd.format(path, dname))
    if "Flash written and verified! jolly good!" not in output:
        msg = "ERROR: exec_command() - build all faild.\n\nOutput msg:\n{}"
        msgf = msg.format(output)
        logger.info(msgf)
        raise AssertionError(msgf)
    else:
        logger.info("Binary successfully written to flash.\n")
Пример #5
0
def uploadBinary(logger):
    cmd = "st-flash write {}/kernel.bin 0x8000000 2>&1 | tee -a {}/logs/buildLog"
    output = common.exec_command(cmd.format(path, dname))
    if "Flash written and verified! jolly good!" not in output:
        msg = "ERROR: exec_command() - build all faild.\n\nOutput msg:\n{}"
        msgf = msg.format(output)
        logger.info(msgf)
        raise AssertionError(msgf)
    else:
        logger.info("Binary successfully written to flash.\n")
Пример #6
0
def test_help():
    returncode, stdout, stderr = exec_command(
        ['dcos-kubernetes', 'kubernetes', '--help'])

    assert returncode == 0
    assert stdout == b"""DCOS Kubernetes Subcommand

Usage:
    dcos kubectl parameters...
"""
    assert stderr == b''
Пример #7
0
def apply_topup(context, apply_topup_files, topup_out):
    """Applies a calculated topup correction to a list of files.

    Args:
        context (class: `flywheel.gear_context.GearContext`): flywheel gear context
        apply_topup_files (list): A list of files to apply topup correction to
        index_list (list): A list that corresponds 1:1 with apply_topup_files, this indicates which row to use from the
        "acquisition_parameters" text file for the associated file.  This essentially tells topup what PE direction each
        image is.
        topup_out (string): the base directory/filename for the topup analysis that was run previously.

    Returns:
        output_files (list): a list of topup corrected files

    """
    # Get the acquisition parameter file for the "--datain" option of topup
    acq_par = context.get_input_path('acquisition_parameters')
    output_files = []

    # For all the files we're applying topup to, loop through them with their associated row in the acquisition parameter file
    for fl, ix in apply_topup_files:

        # Generate an output name: "topup_corrected_" appended to the front of the original filename
        base = os.path.split(fl)[-1]
        output_file = os.path.join(context.output_dir, 'topup-corrected-{}'.format(base))
        output_files.append(output_file)

        # Generate the applytopup command
        cmd = ['applytopup',
               '--imain={}'.format(fl),
               '--datain={}'.format(acq_par),
               '--inindex={}'.format(ix),
               '--topup={}'.format(topup_out),
               '--method=jac',
               '--interp=spline',
               '--out={}'.format(output_file)]

        # Execute the command
        exec_command(cmd)

    return (output_files)
Пример #8
0
def bakeSrcCode(logger):
    path = getBaseDir()
    path = path + "/build"
    cmd = "make all 2>&1 | tee -a {}/logs/buildLog"
    output = common.exec_command(cmd.format(path))
    if "text	   data	    bss	    dec	    hex	filename" not in output:
        msg = "ERROR: exec_command() - build all faild.\n\nOutput msg:\n{}"
        msgf = msg.format(output)
        logger.info(msgf)
        raise AssertionError(msgf)
    else:
        msg = "make all successful.\n"
        logger.info(msg)
Пример #9
0
def bakeSrcCode(logger):
    path = getBaseDir()
    path = path + "/build"
    cmd = "make all 2>&1 | tee -a {}/logs/buildLog"
    output = common.exec_command(cmd.format(path))
    if "text	   data	    bss	    dec	    hex	filename" not in output:
        msg = "ERROR: exec_command() - build all faild.\n\nOutput msg:\n{}"
        msgf = msg.format(output)
        logger.info(msgf)
        raise AssertionError(msgf)
    else:
        msg = "make all successful.\n"
        logger.info(msg)
Пример #10
0
def count_jobs(job_name):
    """Returns how many jobs with self.jobs_name are currently queued or running"""

    try:
        out, err, code = common.exec_command("squeue")
    except OSError:
        raise RuntimeError("Couldn't run squeue, is it installed?")

    if code:
        raise RuntimeError(
            "squeue failed with code %d: stdout: %s, stderr: %s" %
            (code, out, err))

    lines_with_jobname = [l for l in out.splitlines() if job_name in l]
    return len(lines_with_jobname)
Пример #11
0
def test_help():
    returncode, stdout, stderr = exec_command(
        ['dcos-introspect', 'introspect', '--help'])

    assert returncode == 0
    assert stdout == b"""DCOS Introspect Example Subcommand

Usage:
    dcos introspect --info

Options:
    --help           Show this screen
    --version        Show version
"""
    assert stderr == b''
Пример #12
0
def test_help():
    returncode, stdout, stderr = exec_command(
        ['dcos-helloworld', 'helloworld', '--help'])

    assert returncode == 0
    assert stdout == b"""DCOS HelloWorld Example Subcommand

Usage:
    dcos helloworld --info

Options:
    --help           Show this screen
    --version        Show version
"""
    assert stderr == b''
Пример #13
0
def test_help():
    returncode, stdout, stderr = exec_command(
        ['dcos-quobyte', 'quobyte', '--help'])

    assert returncode == 0
    assert stdout == b"""DCOS Quobyte Example Subcommand

Usage:
    dcos quobyte info

Options:
    --help           Show this screen
    --version        Show version
"""
    assert stderr == b''
Пример #14
0
def test_help():
    returncode, stdout, stderr = exec_command(["dcos-helloworld", "helloworld", "--help"])

    assert returncode == 0
    assert (
        stdout
        == b"""DCOS HelloWorld Example Subcommand

Usage:
    dcos helloworld info

Options:
    --help           Show this screen
    --version        Show version
"""
    )
    assert stderr == b""
Пример #15
0
def generate_topup_input(context):
    """Takes gear input files and generates a merged input file for TOPUP.

    Args:
        context (class: `flywheel.gear_context.GearContext`): flywheel gear context

    Returns:
        merged (string): the path to the merged file for use in TOPUP

    """



    # Capture the paths of the input files from the gear context
    image1_path = context.get_input_path('image_1')
    image2_path = context.get_input_path('image_2')
    work_dir = context.work_dir

    # Create a base directory in the context's working directory for image 1
    base_out1 = os.path.join(work_dir, 'Image1')

    # If image 1 is 4D, we will only use the first volume (Assuming that a 4D image is fMRI and we only need one volume)
    # TODO: Allow the user to choose which volume to use for topup correction
    if is4D(image1_path):
        im_name = os.path.split(image1_path)[-1]
        log.info('Using volume 1 in 4D image {}'.format(im_name))

        # Generate a command to extract the first volume
        cmd = ['fslroi', image1_path, base_out1, '0', '1']
    else:
        # If the image is 3D, simply copy the image to our working directory using fslmaths because it's extension agnostic
        cmd = ['fslmaths', image1_path, base_out1]

    # Execute the command, resulting in a single volume from image_1 in the working directory
    exec_command(cmd)

    # Repeat the same steps with image 2
    base_out2 = os.path.join(work_dir, 'Image2')
    if is4D(image2_path):
        im_name = os.path.split(image2_path)[-1]
        log.info('Using volume 1 in 4D image {}'.format(im_name))

        cmd = ['fslroi', image2_path, base_out2, '0', '1']
    else:
        cmd = ['fslmaths', image2_path, base_out2]
    exec_command(cmd)

    # Merge the two volumes (image_1 then image_2)
    merged = os.path.join(work_dir, 'topup_vols')
    cmd = ['fslmerge', '-t', merged, base_out1, base_out2]
    exec_command(cmd)

    return (merged)
Пример #16
0
def test_help():
    returncode, stdout, stderr = exec_command(
        ['dcos-spark', 'spark', '--help'])

    assert returncode == 0
    assert stderr == b''
Пример #17
0
#! /usr/bin/env python

import os
import subprocess
import common
import traceback

abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(dname)

path = common.exec_command("pwd")
path = path.strip("\n")

def getBaseDir():
    out = os.listdir(".")
    while "Makefile" not in out:
        os.chdir("..")
        out = os.listdir(".")
    else:
        basePath = os.getcwd()
        return basePath

def bakeSrcCode(logger):
    path = getBaseDir()
    path = path + "/build"
    cmd = "make all 2>&1 | tee -a {}/logs/buildLog"
    output = common.exec_command(cmd.format(path))
    if "text	   data	    bss	    dec	    hex	filename" not in output:
        msg = "ERROR: exec_command() - build all faild.\n\nOutput msg:\n{}"
        msgf = msg.format(output)
Пример #18
0
def test_config_schema():
    returncode, stdout, stderr = exec_command(
        ['dcos-spark', 'spark', '--config-schema'])

    assert returncode == 0
    assert stderr == b''
Пример #19
0
def test_help():
    returncode, stdout, stderr = exec_command(["dcos-hdfs", "hdfs", "--help"])

    assert returncode == 0
    assert stderr == b""
Пример #20
0
#! /usr/bin/env python

import os
import subprocess
import common
import traceback

abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(dname)

path = common.exec_command("pwd")
path = path.strip("\n")


def getBaseDir():
    out = os.listdir(".")
    while "Makefile" not in out:
        os.chdir("..")
        out = os.listdir(".")
    else:
        basePath = os.getcwd()
        return basePath


def bakeSrcCode(logger):
    path = getBaseDir()
    path = path + "/build"
    cmd = "make all 2>&1 | tee -a {}/logs/buildLog"
    output = common.exec_command(cmd.format(path))
    if "text	   data	    bss	    dec	    hex	filename" not in output:
Пример #21
0
def run_topup(context, input):
    """Runs topup on a given input image.

    Requires acquisition parameters and input options from the gear context.

    Args:
        context (class: `flywheel.gear_context.GearContext`): flywheel gear context
        input (string): the path to the input file for topup's 'imain' input option

    Returns:
        out (string): the topup root path

    """



    # Get the output directory and config file from the gear context
    output_dir = context.output_dir
    config_path = context.get_input_path('config_file')
    acq_par = context.get_input_path('acquisition_parameters')

    # If the user didn't provide a config file, use the default
    if not config_path:
        config_path = DEFAULT_CONFIG

    # Setup output directories
    fout = os.path.join(output_dir, 'topup-fmap')
    iout = os.path.join(output_dir, 'topup-input-corrected')
    out = os.path.join(output_dir, 'topup')
    logout = os.path.join(output_dir, 'topup-log.txt')

    # Get output options from the gear context (which commands to include in the topup call)
    dfout = context.config['displacement_field']
    jacout = context.config['jacobian_determinants']
    rbmout = context.config['rigid_body_matrix']
    verbose = context.config['verbose']
    debug = context.config['topup_debug_level']
    # lout = context.config['mystery_output']

    # Begin generating the command arguments with the default commands that are always present
    argument_dict = {'imain': input, 'datain': acq_par, 'out': out, 'fout': fout,
                     'iout': iout, 'logout': logout, 'config': config_path}

    # Add the optional commands defined by the user in the config settings
    if dfout:
        argument_dict['dfout'] = out + '-dfield'
    if jacout:
        argument_dict['jacout'] = out + '-jacdet'
    if rbmout:
        argument_dict['rbmout'] = out + '-rbmat'
    if verbose:
        argument_dict['verbose'] = True
    if debug:
        argument_dict['debug'] = debug

    # Print the config file settings to the log
    log.info('Using config settings:\n\n{}\n\n'.format(open(config_path, 'r').read()))

    # Build the command and execute
    command = build_command_list(['topup'], argument_dict)
    exec_command(command)

    return (out)
Пример #22
0
def test_help():
    returncode, stdout, stderr = exec_command(
        ['dcos-arangodb3', 'arangodb3', '--help'])

    assert returncode == 0
    assert stderr == b''
Пример #23
0
def test_help():
    returncode, stdout, stderr = exec_command(
        ['dcos-arangodb', 'arangodb', '--help'])

    assert returncode == 0
    assert stderr == b''