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)
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]]
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
def up(): name = gtx.get([])["_kubernetes"]["_provisioner"]["_name"] provisioner = provisioners[name] if not provisioner.is_up(): provisioner.start()
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)
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)
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
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
def register(): for key in gtx.get(["_kubernetes", "_run"]).keys(): gtx.register_cmd("kube", "run", key, run)