MCPcopy Index your code
hub / github.com/Tencent/CodeAnalysis / scan

Method scan

client/tool/util/compass.py:28–49  ·  view source on GitHub ↗
(self, source_dir=None, task_request=None, args=None)

Source from the content-addressed store, hash-verified

26 self.params = params
27
28 def scan(self, source_dir=None, task_request=None, args=None) -> str:
29 # 2022/11/25 参数不能使用可变类型变量作为默认值,比如[] {}等,每次调用都会指向同一个指针
30 if args is None:
31 args = []
32
33 source_dir = source_dir if source_dir else self.params["source_dir"]
34 task_dir = os.path.dirname(os.getcwd())
35 os.environ["SOURCE_DIR"] = source_dir
36 request_file = os.path.abspath(os.path.join(task_dir, "task_request.json"))
37 os.environ["TASK_REQUEST"] = task_request if task_request else request_file
38 tool_cmd = self.get_cmd(args)
39 work_dir = os.getcwd()
40
41 sp = SubProcController(
42 command=tool_cmd,
43 cwd=work_dir,
44 stdout_line_callback=subprocc_log,
45 stderr_line_callback=subprocc_log,
46 env=EnvSet().get_origin_env(),
47 )
48 sp.wait()
49 return os.path.join(work_dir, "result.json")
50
51 def get_cmd(self, args):
52 tool_path = os.path.join(self.tool_home, "bin", settings.PLATFORMS[sys.platform], self.tool_name)

Callers

nothing calls this directly

Calls 3

get_cmdMethod · 0.95
EnvSetClass · 0.90
get_origin_envMethod · 0.80

Tested by

no test coverage detected