コード例 #1
0
def parseScope(data):
    global scopeCounter
    line = data.readline()
    lfile = None
    lline = None
    lid = None
    llocals = []
    while line.startswith(">"):
        if line.startswith(">4"):
            parts = line.split("=")
            rawname = parts[0]
            rawtype = parts[1]
            lname = rawname[rawname.find("[") + 1:rawname.find("]")]
            ltype = rawtype[rawtype.find("[") + 1:rawtype.find("]")]
            llocals.append((lname, ltype))
        else:
            value = line[line.find("[") + 1:line.find("]")]
            if line.startswith(">1"):
                lfile = value
            if line.startswith(">2"):
                lid = value
        line = data.readline()

    SQLiteSerializer.serializeScopeExecution(lfile, lid, llocals)
    scopeCounter = scopeCounter + 1
    return line
コード例 #2
0
def hydrateData():  # Hydrate data from GitHub API into Database
    if not SQLiteSerializer.isSetup:
        SQLiteSerializer.setup()
    skipped = []
    for path, name in database_repos:
        data = Miner.getRepodataUrl(path)
        if data == False:
            logging.info("Skipping Repodata hydrating for " + name)
            skipped.append(name)
        elif type(data) == dict:
            logging.info("Hydrating " + name)
            SQLiteSerializer.serializeRepoData(name, data)
    logging.info("Skipped total hydration of " +
                 str(len(skipped)) + " Repositories.")
    logging.info(str(skipped))
コード例 #3
0
def transformCode(code, filename, reponame):
    try:
        tree = None
        try:
            tree = ast.parse(code)
        except:
            return code
        SQLiteSerializer.serializeFileTransformation(reponame, filename)
        relocator = RelocateLambdas(filename)
        result = relocator.visit(tree)
        functions = relocator.getMethods()
        function_setter = FunctionSetter(functions, relocator.getGlobalVars())
        final_code = function_setter.visit(result)
    except:
        logging.warning("Could not transform file " + str(filename))
        return code
    return to_source(final_code)
コード例 #4
0
def parseLambda(data):
    line = data.readline()
    lfile = None
    lid = None
    lname = None
    ltype = None
    while line.startswith(">"):
        value = line[line.find("[") + 1:line.find("]")]
        if line.startswith(">1"):
            lfile = value
        if line.startswith(">2"):
            lid = value
        if line.startswith(">3"):
            lname = value
        if line.startswith(">4"):
            ltype = value
        line = data.readline()

    SQLiteSerializer.serializeLambdaExecution(lfile, lid, lname, ltype)
    return line
コード例 #5
0
def execute():
    SQLiteSerializer.setup()
    files = glob.glob(trace_folder + "/*.trace")

    for file in files:
        data = open(file, "r")
        init = data.readline().strip()
        if init != "Initialised":
            print("WRONG FILE START", init)
        else:
            line = data.readline()
            while line:
                if line.startswith("#L"):
                    line = parseLambda(data)
                elif line.startswith("#S"):
                    line = parseScope(data)
                else:
                    print(line)
                    line = data.readline()
    SQLiteSerializer.close()
コード例 #6
0
def executeTests():  # Test Execution
    SQLiteSerializer.setup()
    for repo in repo_name_path:
        logging.info("Testing " + repo[0])
        try:
            runner = testrunner.Runner(repo[0], repo[1], time_limit=60)
        except Exception as e:
            logging.warning("Error while building Runner:")
            logging.error(str(e))
        try:
            result = runner.run()
        except Exception as e:
            logging.warning("Error while executing tests:")
            logging.error(str(e))
        logging.debug(result[0])
        try:
            result = runner.get_run_result(result[0])
            logging.info(result)
            logging.error("Serializing Test Execution of " + str(repo[0]))
            SQLiteSerializer.serializeCoverage(repo[0], result.coverage)

        except Exception as e:
            logging.error("Error while getting test results:")
            logging.error(str(e))
    SQLiteSerializer.close()
コード例 #7
0
 def visit_Lambda(self, node):
     try:
         logging.info("Transforming Lambda: " + to_source(node))
     except:
         logging.info("Transforming Lambda: " + ast.dump(node))
     method_name = "_lambda_" + str(self.id_counter)
     SQLiteSerializer.serializeLambdaTransformation(self.filename, self.id_counter, node.lineno)
     self.methods.append(getLocalsFunction(method_name))
     self.methods.append(getLambdaMethod(
         method_name, node.body, node.args, self.filename, self.id_counter))
     self.globalvars.append(getGlobalVariable(method_name))
     self.id_counter += 1
     return Call(
         func=Name(
             id=method_name, ctx=Load()),
         args=[
             Call(
                 func=Name(id='locals', ctx=Load()),
                 args=[],
                 keywords=[]
             )
         ],
         keywords=[]
     )
コード例 #8
0
def transformCode():  # Code Transformation
    SQLiteSerializer.setup()
    for repo in repo_name_path:
        try:
            logging.info("Transforming " + repo[0] + " ...")
            Instrumentator.transformRepo(repo[1], repo[0])
            SQLiteSerializer.commit()
        except Exception as e:
            logging.error("Could not transform: " +
                          str(repo[0]) + "\n" + str(e))
    SQLiteSerializer.close()
コード例 #9
0
def executeMining():
    SQLiteSerializer.setup()
    projects = []

    # Static analysis
    failed = []
    for name, path in repo_name_path:
        try:
            project = Project.createProject(path, name)
            projects.append(project)
            logging.info("Serializing Project " + name)
            SQLiteSerializer.serializeProject(project)
        except:
            failed.append(name)
            logging.warning("Could not create Project for " +
                            name + " in " + path)
    SQLiteSerializer.close()
    logging.info("Serialization of " + str(len(failed)) +
                 " Repositories failed.")
    logging.info(str(failed))