def startIBCancellationWatcher(pid, request_id): print "IBCancellationWatcher started with pid %s and request_id %s" % (str(pid), str(request_id)) procs = ProcessTree(user=None, detail=True, xinfo=None, show=False) while True: time.sleep(60) try: procs.updateSelected(None, None, pid) if (len(procs.selectedTree)==0): print "PID %s doesnt's exist anymore, exiting..." % str(pid) break data = None try: data = tagCollectorAPI.getRequestData(request_id) except: pass if data['state'] == "Cancelled" or data['state'] == "Failed": print "Found status Cancelled or Failed for request %s" % str(request_id) proc2kill = ProcessTree(user=None, detail=True, xinfo=None, show=True) proc2kill.killSelected(None, None, pid) break procs.allProcesses(None) except: print "Error: An exception occured while checking cancelled status" return
try: ret = tc.getPendingRequests(architecture_pattern=plat, requestType="CIB") print "ret=" + str(ret) if not ret: return None # no requests pending at the moment except Exception, e: if 'Unable to perform' in str(e): print "ERROR from TC - retrying ..." return None # assume temporary downtime of TC, retry later ... print "Error getting request : " + str(e) raise # unknown error, re-throw else: try: ret = tc.getRequestData(jobId) except Exception, e: if 'Unable to perform' in str(e): print "ERROR from TC - retrying ..." return None # assume temporary downtime of TC, retry later ... print "Error getting request for id " + jobId + ": " + str(e) raise # unknown error, re-throw if self.doDeBuG: print "--> got:", ret # map over the params ... self.id = int(ret['id']) self.ref = ret['release_name'] latestIB = False if self.ref[-2:] == '_X': latestIB = True
if not jobId: try: ret = tc.getPendingRequests(architecture_pattern=plat,requestType="CIB") print "ret=" + str(ret) if not ret: return None # no requests pending at the moment except Exception, e: if 'Unable to perform' in str(e): print "ERROR from TC - retrying ..." return None # assume temporary downtime of TC, retry later ... print "Error getting request : "+str(e) raise # unknown error, re-throw else: try: ret = tc.getRequestData(jobId) except Exception, e: if 'Unable to perform' in str(e): print "ERROR from TC - retrying ..." return None # assume temporary downtime of TC, retry later ... print "Error getting request for id "+jobId+": "+str(e) raise # unknown error, re-throw if self.doDeBuG: print "--> got:", ret # map over the params ... self.id = int(ret['id']) self.ref = ret['release_name'] latestIB = False