| 108 | |
| 109 | |
| 110 | def render(s): |
| 111 | s = str(s) |
| 112 | cmd_exists = lambda x: any( |
| 113 | os.access(os.path.join(path, x), os.X_OK) |
| 114 | for path in os.getenv("PATH", "").split(os.pathsep) |
| 115 | ) |
| 116 | if cmd_exists("graph-easy"): |
| 117 | p = Popen("graph-easy", stdin=PIPE) |
| 118 | try: |
| 119 | p.stdin.write(s.encode("utf-8")) |
| 120 | except IOError as e: |
| 121 | if e.errno == errno.EPIPE or e.errno == errno.EINVAL: |
| 122 | pass |
| 123 | else: |
| 124 | # Raise any other error. |
| 125 | raise |
| 126 | |
| 127 | p.stdin.close() |
| 128 | p.wait() |
| 129 | else: |
| 130 | print(s) |
| 131 | |
| 132 | |
| 133 | NeuralNetOperator = C.NeuralNetOperator |