コード例 #1
0
def _display_dot_via_imgcat(dot: Dot):
    data = dot.pipe(format='png')
    try:
        proc = subprocess.Popen("imgcat", stdout=subprocess.PIPE, stdin=subprocess.PIPE)
    except OSError as e:
        if e.errno == errno.ENOENT:
            raise AirflowException(
                "Failed to execute. Make sure the imgcat executables are on your systems \'PATH\'"
            )
        else:
            raise
    out, err = proc.communicate(data)
    if out:
        print(out.decode('utf-8'))
    if err:
        print(err.decode('utf-8'))
コード例 #2
0
def _save_dot_to_file(dot: Dot, filename: str):
    filename_without_ext, _, ext = filename.rpartition('.')
    dot.render(filename=filename_without_ext, format=ext, cleanup=True)
    print(f"File {filename} saved")