X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plc.py;fp=plc.py;h=6ca46952bcc5c0cc10f0e907f4528dd6f64b053c;hb=cd46d68ad5c41c4b640b6c39f9a5ba357fd5a10f;hp=a41aecbf630b0c01c0d637c9eed7759bf647071e;hpb=a048ec7065ad812c5dfbe23efa8a4d67b04724af;p=monitor.git diff --git a/plc.py b/plc.py index a41aecb..6ca4695 100644 --- a/plc.py +++ b/plc.py @@ -45,6 +45,8 @@ except: api = xmlrpclib.Server(auth.server, verbose=False, allow_none=True) +global_error_count = 0 + class PLC: def __init__(self, auth, url): self.auth = auth @@ -56,7 +58,17 @@ class PLC: if method is None: raise AssertionError("method does not exist") - return lambda *params : method(self.auth, *params) + try: + return lambda *params : method(self.auth, *params) + except ProtocolError: + traceback.print_exc() + global_error_count += 1 + if global_error_count >= 10: + print "maximum error count exceeded; exiting..." + sys.exit(1) + else: + print "%s errors have occurred" % global_error_count + raise Exception("ProtocolError continuing") def __repr__(self): return self.api.__repr__()