summaryrefslogtreecommitdiff
path: root/example.py
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2013-09-11 18:24:12 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2013-09-11 18:25:27 +0900
commite161a51bbe40ba8550e9bf4a9049fb63cd82e399 (patch)
treea42af66275ac4260660af85cb5470fab900fa57f /example.py
parentae73d53259d3639a65e16a6af97c4251a188b663 (diff)
downloadpygerrit-e161a51bbe40ba8550e9bf4a9049fb63cd82e399.tar.gz
Allow example script to continue if errors are received
Add an option to ignore error events and continue receiving. Connection errors are not ignored and will still result in the script exiting. Change-Id: I807fa50700eb6970b7fbabe48c499fe513717c4d
Diffstat (limited to 'example.py')
-rwxr-xr-xexample.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/example.py b/example.py
index 4a836d1..cde021c 100755
--- a/example.py
+++ b/example.py
@@ -52,6 +52,9 @@ def _main():
parser.add_option('-v', '--verbose', dest='verbose',
action='store_true',
help='enable verbose (debug) logging')
+ parser.add_option('-i', '--ignore-stream-errors', dest='ignore',
+ action='store_true',
+ help='do not exit when an error event is received')
(options, _args) = parser.parse_args()
if options.timeout and not options.blocking:
@@ -77,7 +80,7 @@ def _main():
timeout=options.timeout)
if event:
logging.info("Event: %s", event)
- if isinstance(event, ErrorEvent):
+ if isinstance(event, ErrorEvent) and not options.ignore:
logging.error(event.error)
errors.set()
break