示例#1
0
def print_target_foot(target: Target) -> None:
    """
    Print the footer line when a target execution finished.
    
    Parameters
    ----------
    target : Target
        Target object
    """
    console.echo("=" * WIDTH)
示例#2
0
def shell(cmd: str) -> int:
    """
    Execute the given shell string 
    
    Parameters
    ----------
    `cmd` : str
        Command string to execute
    
    Returns
    -------
    int
        Returncode of the shell
    """
    # Print the string to the console
    console.echo(SHELLCHAR + cmd)
    return os.system(cmd)
示例#3
0
def print_provider_list(providers: List[Provider]) -> None:
    """
    Print the list of providers in tabular format to the console.
    
    Parameters
    ----------
    providers : List[Provider]
        List of provider objects
    """
    table = [(p.name, p.help) for p in providers]
    if len(table) > 0:
        console.echo()
        console.echo("List of available providers:")
        console.echo(
            tabulate.tabulate(table, headers=['Provider', 'Description']))
    else:
        console.echo()
        console.echo("No providers found!")
示例#4
0
def print_target_list(targets: List[Target]) -> None:
    """
    Print the list of targets in tabular format to the console.
    
    Parameters
    ----------
    targets : List[Target]
        List of target objects
    """
    table = [(t.name, t.help) for t in targets]
    if len(table) > 0:
        console.echo()
        console.echo("List of available targets:")
        console.echo(
            tabulate.tabulate(table, headers=['Target', 'Description']))
    else:
        console.echo()
        console.echo("No targets found!")
示例#5
0
def drop_path(path: str):
    """
    Remove an already 'picked-up' path from the global FRUITPATH.

    Parameters
    ----------
    path : str
        Path to remove. May be relative or absolute
    """
    abspath = os.path.abspath(path)
    pathlist = load_fruit_env()

    try:
        pathlist.remove(abspath)
        save_fruit_env(pathlist)
        console.echo(f"{abspath} was dropped!")
    except Exception as exc:
        console.error(f"The path {abspath} cannot be removed!")
        console.error(f"Reason: {str(exc)}")
示例#6
0
def pickup_path(path: str):
    """
    Add a new path to the FRUITPATH environmental variable for global fruit configurations.

    Parameters
    ----------
    path : str
        New path to add. May be relative or absolute path
    """
    abspath = os.path.abspath(path)
    pathlist = load_fruit_env()

    if abspath not in pathlist:
        pathlist.append(abspath)
        console.echo(f"{abspath} was picked up!")
    else:
        console.warning(f"The path {abspath} is already picked up!")

    save_fruit_env(pathlist)
示例#7
0
def print_summary(last_target: Target, steps: List[Step]) -> None:
    """
    Print the summarized results as a table to the console. All run steps & substeps and targets
    will be summarized.
    
    Parameters
    ----------
    last_target : Target
        Target that the summary belonds to

    steps : List[Step]
        List of executed steps
    """
    table = []
    for each_step in steps:
        # Determine the status icon
        if each_step.status == STATUS_OK:
            icon = ICON_OK
            status = "OK"
        elif each_step.status == STATUS_SKIPPED:
            icon = ICON_SKIP
            status = "Skipped"
        elif each_step.status == STATUS_ERR:
            icon = ICON_ERR
            status = "Failed"
        else:
            icon = ICON_UNKNOWN
            status = "Unknown"

        name = each_step.fullname
        xtime = "%.3f" % each_step.time
        table.append((icon, status, xtime, name))

    console.echo()
    console.echo(f"Summary of target '{last_target.name}':")
    console.echo()
    console.echo(
        tabulate.tabulate(table, headers=('', 'Status', 'Time', 'Name')))
    console.echo()
    console.echo_green(f"{ICON_OK} Target '{last_target.name}' was succesful!")
示例#8
0
def print_target_head(target: Target) -> None:
    """
    Print the target header when a target make starts
    
    Parameters
    ----------
    target : Target
        Target object
    """
    console.echo()
    console.echo(f"{ICON_TARGET} Making '{target.name}' ...")
    console.echo("=" * WIDTH)
示例#9
0
def print_step_head(step: Step, number: int) -> None:
    """
    Print the header line of a step, when the step is activated.
    
    Parameters
    ----------
    step : Step
        Step object
    """
    mstring = f"{ICON_STEP} Step {number} : {step.fullname}"
    if len(mstring) < WIDTH:
        mstring += " " + "-" * (WIDTH - len(mstring) - 2)
    console.echo()
    console.echo(mstring)
    console.echo()