def _buildPackages(self, buildThreads): statusEvent = threading.Event() self._initializeScheduler(statusEvent) self._initializeThreadPool(statusEvent) for i in range(0, buildThreads): workerName = "WorkerThread" + str(i) ThreadPool.addWorkerThread(workerName) ThreadPool.startWorkerThread(workerName) statusEvent.wait() Scheduler.stopScheduling = True self.logger.debug("Waiting for all remaining worker threads") ThreadPool.join_all() setFailFlag = False allPackagesBuilt = False if Scheduler.isAnyPackagesFailedToBuild(): setFailFlag = True if Scheduler.isAllPackagesBuilt(): allPackagesBuilt = True if setFailFlag: self.logger.error("Some of the packages failed:") self.logger.error(Scheduler.listOfFailedPackages) raise Exception("Failed during building package") if not setFailFlag: if allPackagesBuilt: self.logger.debug("All packages built successfully") else: self.logger.error("Build stopped unexpectedly.Unknown error.") raise Exception("Unknown error")
def _buildGivenPackages(self, listPackages, buildThreads): # Extend listPackages from ["name1", "name2",..] to ["name1-vers1", "name2-vers2",..] listPackageNamesAndVersions = [] for pkg in listPackages: for version in SPECS.getData().getVersions(pkg): listPackageNamesAndVersions.append(pkg + "-" + version) if constants.rpmCheck: listMakeCheckPackages = set() for pkg in listPackages: version = SPECS.getData().getHighestVersion(pkg) listMakeCheckPackages.add(pkg + "-" + version) alreadyBuiltRPMS = self._readAlreadyAvailablePackages() listPackageNamesAndVersions = (list( set(listPackageNamesAndVersions) | (listMakeCheckPackages - alreadyBuiltRPMS))) returnVal = self._calculateParams(listPackageNamesAndVersions) if not returnVal: self.logger.error( "Unable to set paramaters. Terminating the package manager.") raise Exception("Unable to set paramaters") statusEvent = threading.Event() self._initializeScheduler(statusEvent) self._initializeThreadPool(statusEvent) for i in range(0, buildThreads): workerName = "WorkerThread" + str(i) ThreadPool.addWorkerThread(workerName) ThreadPool.startWorkerThread(workerName) statusEvent.wait() Scheduler.stopScheduling = True self.logger.info("Waiting for all remaining worker threads") ThreadPool.join_all() setFailFlag = False allPackagesBuilt = False if Scheduler.isAnyPackagesFailedToBuild(): setFailFlag = True if Scheduler.isAllPackagesBuilt(): allPackagesBuilt = True if setFailFlag: self.logger.error("Some of the packages failed:") self.logger.error(Scheduler.listOfFailedPackages) raise Exception("Failed during building package") if not setFailFlag: if allPackagesBuilt: self.logger.info("All packages built successfully") else: self.logger.error("Build stopped unexpectedly.Unknown error.") raise Exception("Unknown error") self.logger.info("Terminated")
def buildGivenPackages(self, listPackages): returnVal = self.calculateParams(listPackages) if not returnVal: self.logger.error( "Unable to set paramaters. Terminating the package manager.") return False statusEvent = threading.Event() numWorkerThreads = self.calculatePossibleNumWorkerThreads() if numWorkerThreads > 8: numWorkerThreads = 8 if numWorkerThreads == 0: return False self.initializeScheduler(statusEvent) self.initializeThreadPool(statusEvent) i = 0 while i < numWorkerThreads: workerName = "WorkerThread" + str(i) ThreadPool.addWorkerThread(workerName) ThreadPool.startWorkerThread(workerName) i = i + 1 statusEvent.wait() Scheduler.stopScheduling = True self.logger.info("Waiting for all remaining worker threads") listWorkerObjs = ThreadPool.getAllWorkerObjects() for w in listWorkerObjs: w.join() setFailFlag = False allPackagesBuilt = False if Scheduler.isAnyPackagesFailedToBuild(): setFailFlag = True if Scheduler.isAllPackagesBuilt(): allPackagesBuilt = True if setFailFlag: self.logger.error("Some of the packages failed:") self.logger.error(Scheduler.listOfFailedPackages) return False if not setFailFlag: if allPackagesBuilt: self.logger.info("All packages built successfully") else: self.logger.error("Build stopped unexpectedly.Unknown error.") return False self.logger.info("Terminated") return True
def buildGivenPackages(self, listPackages, buildThreads): if constants.rpmCheck: alreadyBuiltRPMS = self.readAlreadyAvailablePackages() listPackages = list( set(listPackages) | (set(constants.listMakeCheckRPMPkgtoInstall) - set(alreadyBuiltRPMS))) returnVal = self.calculateParams(listPackages) if not returnVal: self.logger.error( "Unable to set paramaters. Terminating the package manager.") raise Exception("Unable to set paramaters") statusEvent = threading.Event() self.initializeScheduler(statusEvent) self.initializeThreadPool(statusEvent) i = 0 while i < buildThreads: workerName = "WorkerThread" + str(i) ThreadPool.addWorkerThread(workerName) ThreadPool.startWorkerThread(workerName) i = i + 1 statusEvent.wait() Scheduler.stopScheduling = True self.logger.info("Waiting for all remaining worker threads") listWorkerObjs = ThreadPool.getAllWorkerObjects() for w in listWorkerObjs: w.join() setFailFlag = False allPackagesBuilt = False if Scheduler.isAnyPackagesFailedToBuild(): setFailFlag = True if Scheduler.isAllPackagesBuilt(): allPackagesBuilt = True if setFailFlag: self.logger.error("Some of the packages failed:") self.logger.error(Scheduler.listOfFailedPackages) raise Exception("Failed during building package") if not setFailFlag: if allPackagesBuilt: self.logger.info("All packages built successfully") else: self.logger.error("Build stopped unexpectedly.Unknown error.") raise Exception("Unknown error") self.logger.info("Terminated")
def buildGivenPackages (self, listPackages): returnVal=self.calculateParams(listPackages) if not returnVal: self.logger.error("Unable to set paramaters. Terminating the package manager.") return False statusEvent=threading.Event() numWorkerThreads=self.calculatePossibleNumWorkerThreads() if numWorkerThreads > 8: numWorkerThreads = 8 if numWorkerThreads == 0: return False self.initializeScheduler(statusEvent) self.initializeThreadPool(statusEvent) i=0 while i < numWorkerThreads: workerName="WorkerThread"+str(i) ThreadPool.addWorkerThread(workerName) ThreadPool.startWorkerThread(workerName) i = i + 1 statusEvent.wait() Scheduler.stopScheduling=True self.logger.info("Waiting for all remaining worker threads") listWorkerObjs=ThreadPool.getAllWorkerObjects() for w in listWorkerObjs: w.join() setFailFlag=False allPackagesBuilt=False if Scheduler.isAnyPackagesFailedToBuild(): setFailFlag=True if Scheduler.isAllPackagesBuilt(): allPackagesBuilt=True if setFailFlag: self.logger.error("Some of the packages failed:") self.logger.error(Scheduler.listOfFailedPackages) return False if not setFailFlag: if allPackagesBuilt: self.logger.info("All packages built successfully") else: self.logger.error("Build stopped unexpectedly.Unknown error.") return False self.logger.info("Terminated") return True
def startServer(): ## if no packages to build then return if Scheduler.isAllPackagesBuilt(): return logger.info("Starting Server ...") try: logger.disabled = True app.run(host='0.0.0.0', port='80', debug=False, use_reloader=False) except Exception as e: logger.exception(e) logger.error("unable to start server") logger.error("")
def buildGivenPackages (self, listPackages, buildThreads): if constants.rpmCheck: alreadyBuiltRPMS=self.readAlreadyAvailablePackages() listPackages=list(set(listPackages)|(set(constants.listMakeCheckRPMPkgtoInstall)-set(alreadyBuiltRPMS))) returnVal=self.calculateParams(listPackages) if not returnVal: self.logger.error("Unable to set paramaters. Terminating the package manager.") raise Exception("Unable to set paramaters") statusEvent=threading.Event() self.initializeScheduler(statusEvent) self.initializeThreadPool(statusEvent) i=0 while i < buildThreads: workerName="WorkerThread"+str(i) ThreadPool.addWorkerThread(workerName) ThreadPool.startWorkerThread(workerName) i = i + 1 statusEvent.wait() Scheduler.stopScheduling=True self.logger.info("Waiting for all remaining worker threads") listWorkerObjs=ThreadPool.getAllWorkerObjects() for w in listWorkerObjs: w.join() setFailFlag=False allPackagesBuilt=False if Scheduler.isAnyPackagesFailedToBuild(): setFailFlag=True if Scheduler.isAllPackagesBuilt(): allPackagesBuilt=True if setFailFlag: self.logger.error("Some of the packages failed:") self.logger.error(Scheduler.listOfFailedPackages) raise Exception("Failed during building package") if not setFailFlag: if allPackagesBuilt: self.logger.info("All packages built successfully") else: self.logger.error("Build stopped unexpectedly.Unknown error.") raise Exception("Unknown error") self.logger.info("Terminated")
def _buildGivenPackages(self, listPackages, buildThreads): # Extend listPackages from ["name1", "name2",..] to ["name1-vers1", "name2-vers2",..] listPackageNamesAndVersions=set() for pkg in listPackages: base = SPECS.getData().getSpecName(pkg) for version in SPECS.getData().getVersions(base): listPackageNamesAndVersions.add(base+"-"+version) returnVal = self._calculateParams(listPackageNamesAndVersions) if not returnVal: self.logger.error("Unable to set parameters. Terminating the package manager.") raise Exception("Unable to set parameters") statusEvent = threading.Event() self._initializeScheduler(statusEvent) self._initializeThreadPool(statusEvent) for i in range(0, buildThreads): workerName = "WorkerThread" + str(i) ThreadPool.addWorkerThread(workerName) ThreadPool.startWorkerThread(workerName) statusEvent.wait() Scheduler.stopScheduling = True self.logger.debug("Waiting for all remaining worker threads") ThreadPool.join_all() setFailFlag = False allPackagesBuilt = False if Scheduler.isAnyPackagesFailedToBuild(): setFailFlag = True if Scheduler.isAllPackagesBuilt(): allPackagesBuilt = True if setFailFlag: self.logger.error("Some of the packages failed:") self.logger.error(Scheduler.listOfFailedPackages) raise Exception("Failed during building package") if not setFailFlag: if allPackagesBuilt: self.logger.debug("All packages built successfully") else: self.logger.error("Build stopped unexpectedly.Unknown error.") raise Exception("Unknown error")