summaryrefslogtreecommitdiff
path: root/subplot/clab.py
blob: a16a5b84a52d1ab5b541348d9f6ea99ee72319e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import io
import os
import yaml


def install_clab(ctx):
    runcmd_prepend_to_path = globals()["runcmd_prepend_to_path"]
    srcdir = globals()["srcdir"]

    # Add the directory with built Rust binaries to the path.
    default_target = os.path.join(srcdir, "target")
    target = os.environ.get("CARGO_TARGET_DIR", default_target)
    runcmd_prepend_to_path(ctx, dirname=os.path.join(target, "debug"))
    ctx["server-binary"] = os.path.join(target, "debug", "obnam-server")


def stdout_is_yaml(ctx):
    runcmd_get_stdout = globals()["runcmd_get_stdout"]
    stdout = runcmd_get_stdout(ctx)
    yaml.safe_load(io.StringIO(stdout))