def make_watcher_results(watcher_log, watcher_output, topoFile, simParams, watcher_type="delay"): import datetime now = datetime.datetime.now() if watcher_log is not None: if os.path.exists(watcher_log): import shutil shutil.copyfile(watcher_log, 'watchers/logs/%s.log' % now) else: lg.error("No log file was found in %s\n" % watcher_log) if watcher_output is not None: if os.path.exists(watcher_output): if watcher_type == "delay": import watcher_delay as wa elif watcher_type == "bw": import watcher_bw as wa else: lg.error("Unknown watcher type passed : %s\n" % watcher_type) return try: wa.appendResults( wa.makeResults(watcher_output, topoFile, simParams)) except Exception as e: lg.error("Error while processing results %s\n" % e) lg.error(traceback.format_exc()) # prevent results from being processed twice os.rename(watcher_output, 'watchers/output/%s.json' % now) else: lg.error('No file watcher output was found in %s\n' % watcher_output)
def do_watchers(self, line = "delay"): import vars, os if vars.watcher_output is not None and os.path.exists(vars.watcher_output): if line == "delay": import watcher_delay as wa else: import watcher_bw as wa import datetime wa.appendResults(wa.makeResults(vars.watcher_output, vars.topoFile)) # prevent results from being processed twice os.rename(vars.watcher_output, 'watchers/output/%s.json' % datetime.datetime.now())