def getCountriesOverview(self): countries = {} for country in MediationConfig.getCountryList(): allStatuses = self.getAll(country) ok = 0 warning = 0 outage = 0 expired = 0 disabled = 0 for lobName, lob in MediationConfig.getLobs(country).items(): for flow in lob["flows"].values(): gName = flow["gName"] if flow["options"]["enabled"] is False: disabled += 1 continue flowStatus = allStatuses.get( gName, {"status": status.NA})["status"] if flowStatus == status.NA: expired += 1 elif flowStatus == status.OK: ok += 1 elif flowStatus == status.WARNING: warning += 1 elif flowStatus == status.OUTAGE: outage += 1 countries[country] = { status.OK: ok, status.WARNING: warning, status.OUTAGE: outage, status.NA: expired, status.DISABLED: disabled } return countries
def _executeInternal(self): flowQueue = Queue() for country in MediationConfig.getCountryList(): self._enqueFlowsToAnalyze(flowQueue, country) if not flowQueue.empty(): start = time.time() flowsToAnalyzeCnt = flowQueue.unfinished_tasks logging.info("Going to analyze " + str(flowsToAnalyzeCnt)+" flows") workers = [Worker(flowQueue, self.statusManager) for i in range(0, MediationConfig.threadsCount())] for worker in workers: worker.start() for worker in workers: worker.join() logging.info("Finished analyzing " + str(flowsToAnalyzeCnt) + " flows. Time: " + str(int(time.time() - start)) + " seconds.")