Skip to content

Instantly share code, notes, and snippets.

@pcn
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save pcn/879265aa4115e5a2da77 to your computer and use it in GitHub Desktop.

Select an option

Save pcn/879265aa4115e5a2da77 to your computer and use it in GitHub Desktop.
gawd I love python's sh module
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