-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCloneOperator.py
40 lines (33 loc) · 1.32 KB
/
CloneOperator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# aim: This is the class for doing clone detection
import os
import pathlib
import subprocess
current_folder = os.path.dirname(__file__)
NIL_path = str(pathlib.Path(current_folder).joinpath("bin/NIL.jar"))
class CloneOperator(object):
def execute(self, target_folder: str, nil_config: dict):
"""
Function: this is the function for running clone detection
params:
- target_folder: the folder path for detection
- nil_config: the configuration of NIL tool
"""
p = subprocess.Popen(
"cd {target_folder} && java -jar {NIL_path} -s ./ -mit {mit} -mil {mil} -t {thread_num} -o result.csv -p {partition_num}".format(
target_folder=target_folder,
NIL_path=NIL_path,
mit=int(nil_config["mit"]),
mil=int(nil_config["mil"]),
thread_num=int(nil_config["thread_num"]),
partition_num=int(nil_config["partition_num"]),
),
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
output = p.stdout.read().decode("utf-8", errors="replace")
if "[main] INFO jp.ac.osaka_u.sdl.nil.NILMain - End" not in output:
print(output)
_ = p.wait()
if __name__ == "__main__":
print("finish")