Last active
August 29, 2015 14:05
-
-
Save pcn/879265aa4115e5a2da77 to your computer and use it in GitHub Desktop.
gawd I love python's sh module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sh | |
| import errno | |
| import time | |
| import json | |
| table_json = json.loads(str(sh.ovsdb_client("--format", "json", "list-tables"))) | |
| monitor_dict = dict() | |
| for t in table_json['data']: | |
| monitor_dict[t[0]] = sh.ovsdb_client("--format", "json", "monitor", t[0], _piped=True, _iter_noblock=True) | |
| while True: | |
| for table in monitor_dict.keys(): | |
| line = monitor_dict[table].next() | |
| if line == errno.EWOULDBLOCK: | |
| print("Would Block, But NOT!") | |
| else: | |
| print "{}: {}".format(table, line) | |
| time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment