Ejemplo n.º 1
0
def get_hostname():
    mongo_home = os.environ.get("MONGO_HOME", None)
    if mongo_home:
        file_name = os.path.join(mongo_home, "host_machine.txt")
        if cache.file_exists(file_name):
            return cache.read_file(file_name).strip()
    return get_default_hostname()
Ejemplo n.º 2
0
 def parse_file(self, file_path):
     stmts = []
     source = cache.read_file(file_path)
     for line in source.split("\n"):
         line = line.strip()
         if line and not line.startswith("#"):
             matched = self.parse(line)
             if matched:
                 stmts.append(matched)
     return stmts
Ejemplo n.º 3
0
def coverage(project_name):
  """
  Return coverage for project.
  :param project_name: Name of the project.
  :return: Dictionary with project_name, sloc, lines_covered and code_coverage
  """
  coverage_file = "%s/%s/sloc.json" % (properties.META_RESULTS_FOLDER, project_name)
  json_data = json.loads(cache.read_file(file_name=coverage_file))
  sloc = 0
  lines_covered = 0
  for java_file, stats in json_data.items():
    f_sloc = len(stats["sloc"])
    f_lines_covered = len(stats["linesCovered"])
    sloc += f_sloc
    lines_covered += f_lines_covered
  code_coverage = lines_covered / sloc * 100
  return {
    "project": project_name,
    "sloc": sloc,
    "lines_covered": lines_covered,
    "code_coverage": code_coverage
  }
Ejemplo n.º 4
0
 def parse(self):
     source_code = cache.read_file(self.file_path)
     tree = ast.parse(source_code)
     self.visit(tree)
     self.update_danglings()
     return self
Ejemplo n.º 5
0
 def parse(self):
     source_code = cache.read_file(self.file_path)
     self.ast_tokenized = asttokens.ASTTokens(source_code, parse=True)
     self.set_root_method()
     meta = {"method": self._root_method}
     self.visit(self.ast_tokenized.tree, meta)
Ejemplo n.º 6
0
def compile_py(file_name):
    source = cache.read_file(file_name)
    ast.parse(source)