def autoScan(databaseName, endless, useReprinter=False): """ Search tools to launch within defined conditions and attempts to launch them on celery workers. Gives a visual feedback on stdout Args: databaseName: The database to search tools in endless: a boolean that indicates if the autoscan will be endless or if it will stop at the moment it does not found anymore launchable tools. useReprinter: a boolean that indicates if the array outpur will be entirely reprinted or if it will be overwritten. """ mongoInstance = MongoCalendar.getInstance() mongoInstance.connectToDb(databaseName) my_monitor = Monitor(databaseName) Utils.resetUnfinishedTools() time_compatible_waves_id = Wave.searchForAddressCompatibleWithTime() killer = GracefulKiller() if not endless: killer.kill_now = len(time_compatible_waves_id) <= 0 print("No wave compatible") else: killer.kill_now = False if useReprinter: reprinter = Reprinter() else: reprinter = None max_tabulation = _getMaxColumnLen() while not killer.kill_now: # Extract commands with compatible time and not yet done launchableTools, waiting = findLaunchableTools() # Sort by command priority launchableTools.sort(key=lambda tup: int(tup["priority"])) dispatchLaunchableTools(my_monitor, launchableTools) printStatus(max_tabulation, waiting, reprinter) time.sleep(3) my_monitor.stop()
def resetUnfinishedTools(self): """ Reset all running tools to a ready state. """ mongoInstance = MongoCalendar.getInstance() if mongoInstance.hasACalendarOpen(): Utils.resetUnfinishedTools() self.treevw.load()