From 8868d29303a545901cce2edfa9d69b586421c61f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bar=C4=B1=C5=9F=20Metin?= Date: Wed, 16 Dec 2009 14:51:54 +0000 Subject: [PATCH] handle IndexError in getpcu --- monitor/wrapper/plc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/monitor/wrapper/plc.py b/monitor/wrapper/plc.py index b7b55d9..87355fa 100644 --- a/monitor/wrapper/plc.py +++ b/monitor/wrapper/plc.py @@ -248,7 +248,11 @@ Returns dict of PCU info of a given node. def getpcu(nodename): api = xmlrpclib.Server(auth.server, verbose=False, allow_none=True) anon = {'AuthMethod': "anonymous"} - nodeinfo = api.GetNodes(auth.auth, {"hostname": nodename}, ["pcu_ids", "ports"])[0] + try: + nodeinfo = api.GetNodes(auth.auth, {"hostname": nodename}, ["pcu_ids", "ports"])[0] + except IndexError: + logger.info("Can not find node: %s" % nodename) + return False if nodeinfo['pcu_ids']: print nodeinfo sitepcu = api.GetPCUs(auth.auth, nodeinfo['pcu_ids'])[0] -- 2.43.0