From 8b7cac2607bda6ace3444ff20917c6262395bd7a Mon Sep 17 00:00:00 2001 From: radhika Date: Tue, 17 Jun 2014 11:43:38 -0400 Subject: [PATCH] 2896: incorporate review comments: add logging, enhance creating filter object. --- sdk/python/bin/arv-ws | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/sdk/python/bin/arv-ws b/sdk/python/bin/arv-ws index 07216879a9..58b628145f 100755 --- a/sdk/python/bin/arv-ws +++ b/sdk/python/bin/arv-ws @@ -1,34 +1,30 @@ #!/usr/bin/env python -import argparse import sys +import logging +import argparse +import arvados +from arvados.events import subscribe parser = argparse.ArgumentParser() parser.add_argument('-u', '--uuid', type=str, default="") args = parser.parse_args() -def on_message(ev): - print "\n", ev - filters = [] -if len(args.uuid)>0: - filter1 = [] - filter1.append ('object_uuid') - filter1.append ('=') - filter1.append (args.uuid) - filters.append (filter1) - -import arvados -from arvados.events import subscribe +if len(args.uuid)>0: filters = [ ['object_uuid', '=', args.uuid] ] api = arvados.api('v1', cache=False) +def on_message(ev): + print "\n", ev + ws = None try: ws = subscribe(api, filters, lambda ev: on_message(ev)) ws.run_forever() +except KeyboardInterrupt: + print '' # don't log it except: + logging.exception('') if (ws): ws.close_connection() - else: - sys.exc_info() -- 2.30.2