Beispiel #1
0
def get_app_paths(config, task):
    """Create a list of ``App`` objects from the task.

    These will have their ``orig_path`` set.

    Args:
        config (dict): the running config
        task (dict): the running task

    Returns:
        list: a list of App objects

    """
    all_paths = []
    for upstream_artifact_info in task["payload"]["upstreamArtifacts"]:
        for subpath in upstream_artifact_info["paths"]:
            orig_path = get_artifact_path(upstream_artifact_info["taskId"],
                                          subpath,
                                          work_dir=config["work_dir"])
            all_paths.append(
                App(
                    orig_path=orig_path,
                    formats=upstream_artifact_info["formats"],
                    artifact_prefix=_get_artifact_prefix(subpath),
                ))
    return all_paths
def _get_artifacts(task_payload, config):
    artifacts = []

    for upstream_artifact_definition in task_payload["upstreamArtifacts"]:
        task_id = upstream_artifact_definition["taskId"]
        for taskcluster_path in upstream_artifact_definition["paths"]:
            local_path = get_artifact_path(task_id,
                                           taskcluster_path,
                                           work_dir=config["work_dir"])
            target_path = _find_target_path(taskcluster_path,
                                            task_payload["artifactMap"])

            artifacts.append({
                "content_type": guess_type(local_path)[0],
                "local_path": local_path,
                "name": target_path,
                "size": os.path.getsize(local_path)
            })

    return artifacts
def test_get_artifact_path(work_dir, expected):
    """``get_artifact_path`` gives the expected path.

    """
    assert (utils.get_artifact_path("taskId", "public/foo",
                                    work_dir=work_dir) == expected)