Пример #1
0
def pipe():
    identifier = gtx.get(["_cli"])["_identifier"]

    ctx = gtx.get(["_golang", "_build", identifier])
    go.build_in_container(ctx)

    ctx = gtx.get(["_docker", "_image", identifier])
    docker.build(ctx)

    kubectl.delete(identifier)

    kubectl.apply(identifier)

    kubectl.logs(identifier)
Пример #2
0
def get(levels, args):
    if isinstance(args, dict):
        return [args]

    if isinstance(args, str):
        if args == "all":
            return gtx.get(levels).items()
        else:
            return [gtx.get(levels)[args]]

    identifier = gtx.get(["_cli", "_identifier"])
    if identifier == "all":
        return gtx.get(levels).values()

    return [gtx.get(levels)[identifier]]
Пример #3
0
def get_base_command():
    config = gtx.get(['_kubernetes', '_config'])

    base_command = bloks.render.string_as_string(
        "kubectl --kubeconfig {{ _path }} --context {{ _context }}", config)

    return base_command
Пример #4
0
def up():
    name = gtx.get([])["_kubernetes"]["_provisioner"]["_name"]

    provisioner = provisioners[name]

    if not provisioner.is_up():
        provisioner.start()
Пример #5
0
def string_as_string(text, ctx):
    env = jinja2.Environment(
        loader=jinja2.BaseLoader,
        undefined=jinja2.StrictUndefined,
    )

    ctx["gtx"] = gtx.get([])
    return env.from_string(text).render(ctx)
Пример #6
0
def file_as_string(path, ctx):
    path, filename = os.path.split(path)

    env = jinja2.Environment(
        loader=jinja2.FileSystemLoader(path or './'),
        undefined=jinja2.StrictUndefined,
    )

    ctx["gtx"] = gtx.get([])
    return env.get_template(filename).render(ctx)
Пример #7
0
def listen():
    phrases = list(set(gtx.get(["_cmd", "_phrases"])))

    recognizer = sr.Recognizer()
    audio = record(recognizer)
    speech_words = recognize(recognizer, phrases, audio).split()

    if debug:
        print(speech_words)

    print(gtx.get(["_cmd", "_tree"].items()))
    # for tool in gtx.get(["_cmd", "_tree"].items()):
    #     for action in action

    distances = get_distances(phrases, speech_words)
    phrases = get_closest_phrases(speech_words, distances)

    if debug:
        print(phrases)

    return phrases
Пример #8
0
def runo(command, check=True, env={}):
    log.info(__name__ + ".runo : " + str(locals()))

    completed = None
    try:
        completed = subprocess.run(command, shell=True, check=check, env={})
    except Exception as e:
        log.error("command failed")

        if gtx.get(["_ignore-errors"]) == False:
            raise

    return completed
Пример #9
0
Файл: cmd.py Проект: ppwfx/bloks
def register():
    for key in gtx.get(["_kubernetes", "_run"]).keys():
        gtx.register_cmd("kube", "run", key, run)