def find_dependencies(x, dep, visited): dependencies = ImportManager.GetDependencies(x) if x not in visited: visited.add(x) for v in dependencies: log(" {0}\n", v.__name__) dep.add(v) public_cls.find_dependencies(v, dep, visited)
def report_err(self): exc = traceback.format_exc() if QThread.currentThread() == QCoreApplication.instance().thread(): log.now() log(exc) else: @public.mth def f(): log.now() log(exc)
def collectTotalSendData(): ifconfigResult = subprocess.check_output("ifconfig", shell=True) framework.log("ifconfig result", ifconfigResult) for line in ifconfigResult.split("\n"): matchObj = re.match(r'(.*) Link (.*)', line, re.M) if matchObj: currentInt = matchObj.group(1) else: matchObj = re.match(r'(.*)RX bytes:(.*)\((.*) TX bytes:(.*)\((.*)', line, re.M) if matchObj: framework.record("tx_" + str(currentInt), int(matchObj.group(4))) framework.record("rx_" + str(currentInt), int(matchObj.group(2)))
def LoadExtensions(self): extensions_settings = appconfig.setdefault('extensions', {}) found_extensions = [] lst = os.listdir(self.extensions_path) for v in lst: if v == '__init__.py': continue path = self.extensions_path + os.sep + v if os.path.isdir(path): name = v module_name = self.extensions_path + '.' + v elif v.endswith('.py'): name = v[:-3] module_name = self.extensions_path + '.' + v[:-3] else: continue found_extensions.append(name) if name in extensions_settings: if not extensions_settings[name]: log( 'Skipping extension {0}\n'.format(name) ) continue else: if name in ('examples'): extensions_settings[name] = False continue extensions_settings[name] = True log( 'Loading extension {0}\n'.format(name) ) try: __import__(module_name) except: log.exception() for k in extensions_settings.copy().iterkeys(): if k not in found_extensions: del extensions_settings[k] appconfig.SaveSettings()
def LoadExtensions(self): extensions_settings = appconfig.setdefault('extensions', {}) found_extensions = [] lst = os.listdir(self.extensions_path) for v in lst: if v == '__init__.py': continue path = self.extensions_path + os.sep + v if os.path.isdir(path): name = v module_name = self.extensions_path + '.' + v elif v.endswith('.py'): name = v[:-3] module_name = self.extensions_path + '.' + v[:-3] else: continue found_extensions.append(name) if name in extensions_settings: if not extensions_settings[name]: log('Skipping extension {0}\n'.format(name)) continue else: if name in ('examples'): extensions_settings[name] = False continue extensions_settings[name] = True log('Loading extension {0}\n'.format(name)) try: __import__(module_name) except: log.exception() for k in extensions_settings.copy().iterkeys(): if k not in found_extensions: del extensions_settings[k] appconfig.SaveSettings()
def reimport(self): modules_to_reload = set() dependent_modules = set() for k, v in sys.modules.items(): try: fname = v.__file__ found = False for pre in ('framework', 'extensions', 'iso15926'): if pre in fname: found = True break if not found: continue if fname.endswith('.pyc') or fname.endswith('.pyo'): fname = fname[:-1] stat = os.stat(fname) except: continue mtime = stat.st_mtime mtime -= stat.st_ctime # msw32 old = self.mtimes.get(fname) if old is not None and old != mtime: modules_to_reload.add(v) self.mtimes[fname] = mtime if len(modules_to_reload) == 0: return log('\n<<< REIMPORT >>>\n') for v in modules_to_reload: log("dependencies for {0}\n", v.__name__) public_cls.find_dependencies(v, dependent_modules, set()) modules_to_reload = list(modules_to_reload | dependent_modules) modules_to_reload = sorted(modules_to_reload, cmp=public_cls.module_compare) for v in modules_to_reload: log("reloading {0}\n", v.__name__) reload(v) import framework.menu framework.menu.AssignMenuBar(appdata.topwindow, 'workbench.menubar')
import framework from subprocess import check_output if __name__ == '__main__': framework.start() result = check_output( "java -jar testJar.jar {{number_of_nodes}} {{avg_node_degree}}", shell=True) framework.log("java_call", result) framework.stop()
print "myParameter has the value", {{myParameter}} """ 3. Store measurement results during the experiment. You might even store multiple values for the same metric key. """ framework.record("targetMetric", 1) """ Each measurement record contains a time offset. Override this offset if required (e.g., for time-based analysis) """ framework.record("targetMetric", 1, offset=5) """ 4. Store additional logs and warnings during the experiment. Note that the standard output is also recorded, e.g., prints. """ framework.log("key", "value") framework.warn("key", "value") # create dummy logfile os.system("echo blub > mylogfile.txt") framework.addLogfile("mylogfile.txt") """ 5. Finally, inform the framework about the end of the experiment. """ framework.stop()
# just lines of time spans (in ms) it took to read what was expected in one second (1000 ms) if line[-1] != "" and line != "finished": framework.record("cbr_for_1s", int(line[:-1]), offset=i) error = math.pow(1000 - int(line[:-1]), 2) framework.record("cbr_error", error, offset=i) i = i + 1 if __name__ == '__main__': framework.start() # we ignore the seed here, but we do not want to get a warning framework.param("seed") usedLinuxKernel = subprocess.check_output("uname -a", shell=True) framework.log("Used Linux kernel", usedLinuxKernel) loadedSchedulers = subprocess.check_output( "cat /proc/net/mptcp_net/rbs/schedulers", shell=True) framework.log("Loaded schedulers", loadedSchedulers) # clean up os.system('sudo mn -c') os.system('sudo dmesg -c > /dev/null') # configure system os.system('sysctl -w net.mptcp.mptcp_enabled=1') os.system("echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6") os.system('sysctl -w net.mptcp.mptcp_debug={{mptcp_debug}}') os.system('sysctl -w net.mptcp.mptcp_path_manager=fullmesh')
def f(): log.now() log(exc)
def print_public_keys(self): log('public keys:\n') for k in self.places.iterkeys(): log(' {0}\n', k)