Tencent / CodeAnalysis

Static Code Analysis - 静态代码分析
https://tencent.github.io/CodeAnalysis/
Other
1.68k stars 287 forks source link

客户端执行 执行python3 codepuppy.py localscan 报错: #112

Closed Master-Kang closed 2 years ago

Master-Kang commented 2 years ago

image 提示没有

Master-Kang commented 2 years ago

提示没有此模块 结果 用pip安装也找不到这个模块 image

Master-Kang commented 2 years ago

还是建议建一个交流群

bensonhome commented 2 years ago

@Master-Kang 确认下是否用的不是python3.7版本

Lingghh commented 2 years ago

可以配置一下软链,比如下面的例子: python的安装路径是/usr/local/python3/,可以根据python安装的实际路径进行调整

# 链接构建产出的Python动态库
$ ln -s /usr/local/python3/lib/libpython3.7m.so.1.0 /usr/lib/libpython3.7m.so.1.0
# 配置动态库
$ ldconfig
Master-Kang commented 2 years ago

image

确认是用的python3.7

Lingghh commented 2 years ago

@Master-Kang 这里可以试一下上述软链的方式,看看是否ok

Master-Kang commented 2 years ago

可以了

Donny2g commented 2 years ago

@bensonhome 我这遇到另一个错误,是否为服务端配置有问题?

[root@localhost client]# python3 codepuppy.py localscan 2022-01-20 18:21:29,021-INFO-util.logutil: Tencent Cloud Code Analysis (OpenSource Beta) 2022-01-20 18:21:29,129-INFO-util.logutil: ------------------------------ 2022-01-20 18:21:29,129-INFO-util.logutil: ####### #### # 2022-01-20 18:21:29,130-INFO-util.logutil: # # # # 2022-01-20 18:21:29,130-INFO-util.logutil: # # ### 2022-01-20 18:21:29,130-INFO-util.logutil: # # # # 2022-01-20 18:21:29,130-INFO-util.logutil: # # ##### 2022-01-20 18:21:29,130-INFO-util.logutil: # # # # # 2022-01-20 18:21:29,130-INFO-util.logutil: # #### ## ## 2022-01-20 18:21:29,130-INFO-util.logutil: ------------------------------ 2022-01-20 18:21:29,247-INFO-util.logutil: using config file: /data/tca_open_source/client/codedog.ini 2022-01-20 18:21:29,249-INFO-util.logutil: connect to server: http://192.168.138.163/ 2022-01-20 18:21:30,056-INFO-util.logutil: scan plan(默认) already exists: http://192.168.138.163/t/Am018RCImQa/p/cipher_platform_test/code-analysis/repos/1/schemes/1/basic 2022-01-20 18:21:30,101-INFO-util.logutil: Use the already existed project(id: 1). 2022-01-20 18:21:30,460-INFO-util.logutil: Project url: http://192.168.138.163/t/Am018RCImQa/p/cipher_platform_test/code-analysis/repos/1/projects/1/overview 2022-01-20 18:21:30,770-INFO-util.logutil: Job starts ... 2022-01-20 18:21:30,780-INFO-util.logutil: USE_LOCAL_TOOL=True, use local tool dir: /data/tca_open_source/client/data/tools/puppy-tools-config 2022-01-20 18:21:30,785-INFO-util.logutil: USE_LOCAL_TOOL=True, use local tool dir: /data/tca_open_source/client/data/tools/linux-scc 2022-01-20 18:21:30,786-INFO-util.logutil: USE_LOCAL_TOOL=True, use local tool dir: /data/tca_open_source/client/data/tools/cloc 2022-01-20 18:21:30,786-INFO-util.logutil: USE_LOCAL_TOOL=True, use local tool dir: /data/tca_open_source/client/data/tools/linux-jdk1.8.0_65 2022-01-20 18:21:30,786-INFO-util.logutil: USE_LOCAL_TOOL=True, use local tool dir: /data/tca_open_source/client/data/tools/common-pmd-bin-6.19.0 2022-01-20 18:21:30,786-INFO-util.logutil: USE_LOCAL_TOOL=True, use local tool dir: /data/tca_open_source/client/data/tools/checkstyle 2022-01-20 18:21:30,786-INFO-util.logutil: USE_LOCAL_TOOL=True, use local tool dir: /data/tca_open_source/client/data/tools/common-lizard-1.17.5 2022-01-20 18:21:30,786-INFO-util.logutil: USE_LOCAL_TOOL=True, use local tool dir: /data/tca_open_source/client/data/tools/common-dart-code-metrics-1.7.1 2022-01-20 18:21:30,786-INFO-util.logutil: USE_LOCAL_TOOL=True, use local tool dir: /data/tca_open_source/client/data/tools/linux-dart-sdk-v2.7.2 2022-01-20 18:21:30,786-INFO-util.logutil: USE_LOCAL_TOOL=True, use local tool dir: /data/tca_open_source/client/data/tools/common-detekt-cli-1.7.1-all 2022-01-20 18:21:30,786-INFO-util.logutil: USE_LOCAL_TOOL=True, use local tool dir: /data/tca_open_source/client/data/tools/linux-Python-v3.7.2 2022-01-20 18:21:30,786-INFO-util.logutil: USE_LOCAL_TOOL=True, use local tool dir: /data/tca_open_source/client/data/tools/common-pmd-bin-5.8.1 2022-01-20 18:21:30,786-INFO-util.logutil: Initing 11 tools, please wait a minute ... [Tools init]: 100%|█████████████████████████████████████████████| 11/11 [00:00<00:00, 148351.59it/s] 2022-01-20 18:21:30,790-INFO-util.logutil: Initialize tools done.(use time: 0.00s) 2022-01-20 18:21:31,021-INFO-util.logutil: Start to count code lines... 2022-01-20 18:21:31,022-INFO-util.logutil: Codemetric only scans main code (exclude test_source, auto_generate_source, third_party_source). 2022-01-20 18:21:31,023-INFO-util.logutil: Codelint only cans main code. 2022-01-20 18:21:31,051-INFO-util.logutil: [文件数]过滤前:124,过滤后:124 2022-01-20 18:21:31,052-INFO-util.logutil: ['/data/tca_open_source/client/data/tools/linux-scc/scc', '--by-file', '-c', '--no-cocomo', '-f', 'json', '-o', '/data/tca_open_source/client/data/taskdirs/task_16/scc_result_bc4b441279da11ec8e090050569a45a5.json', '/data/code/cipher_IBC_SOAP'] 2022-01-20 18:21:31,080-INFO-util.logutil: results written to /data/tca_open_source/client/data/taskdirs/task_16/scc_result_bc4b441279da11ec8e090050569a45a5.json 2022-01-20 18:21:31,142-INFO-util.logutil: Task_16 (CheckStyle) starts ...

2022-01-20 18:21:41,253-INFO-util.logutil: Task_16 is done. 2022-01-20 18:21:41,272-ERROR-util.api.httpclient: error code: 405, reason: Not Allowed, headers: Server: nginx/1.20.2 Date: Thu, 20 Jan 2022 10:21:41 GMT Content-Type: text/html Content-Length: 157 Connection: close

2022-01-20 18:21:41,272-ERROR-util.wrapper: method(upload_file) call fails on error: HTTP Error 405: Not Allowed 2022-01-20 18:21:41,272-INFO-util.wrapper: retrying method(upload_file) after 5 seconds 2022-01-20 18:21:46,276-ERROR-util.api.httpclient: error code: 405, reason: Not Allowed, headers: Server: nginx/1.20.2 Date: Thu, 20 Jan 2022 10:21:46 GMT Content-Type: text/html Content-Length: 157 Connection: close

2022-01-20 18:21:46,276-ERROR-util.wrapper: method(upload_file) call fails on error: HTTP Error 405: Not Allowed 2022-01-20 18:21:46,276-INFO-util.wrapper: retrying method(upload_file) after 5 seconds 2022-01-20 18:21:51,283-ERROR-util.api.httpclient: error code: 405, reason: Not Allowed, headers: Server: nginx/1.20.2 Date: Thu, 20 Jan 2022 10:21:51 GMT Content-Type: text/html Content-Length: 157 Connection: close

2022-01-20 18:21:51,283-ERROR-util.wrapper: method(upload_file) call fails on error: HTTP Error 405: Not Allowed 2022-01-20 18:21:51,283-WARNING-util.wrapper: method(upload_file) call still fails after 2 retries 2022-01-20 18:21:51,283-INFO-util.logutil:


代码分析结果: HTTPError: HTTP Error 405: Not Allowed


2022-01-20 18:21:51,283-INFO-util.logutil: json report: /data/tca_open_source/client/scan_status.json 2022-01-20 18:21:51,283-ERROR-util.logutil: HTTPError: HTTP Error 405: Not Allowed Traceback (most recent call last): File "/data/tca_open_source/client/node/localrunner.py", line 396, in run run_task_mgr.scan_project(cur_execute_request_list, proj_conf) File "/data/tca_open_source/client/node/localtask/runlocaltask.py", line 96, in scan_project self._proj_id).run() File "/data/tca_open_source/client/node/localtask/runtask.py", line 170, in run ResultCheck.upload_task_result(task, self._proj_id) File "/data/tca_open_source/client/node/localtask/runtask.py", line 97, in upload_task_result data_url, log_url = TaskRunner.upload_result_detail(proj_id, task.task_id, task_dir, data, task.task_log) File "node/taskrunner.py", line 59, in node.taskrunner.TaskRunner.upload_result_detail File "util/wrapper.py", line 51, in util.wrapper._RetryMethod.call File "util/wrapper.py", line 107, in util.wrapper.Retry.__retry_call File "util/wrapper.py", line 92, in util.wrapper.Retry.retry_call File "/data/tca_open_source/client/util/api/fileserver.py", line 103, in upload_file return self.upload_data(fp, rel_url, headers) File "/data/tca_open_source/client/util/api/fileserver.py", line 87, in __upload_data HttpClient(self._server_url, rel_url, headers=headers, data=data, proxies=self._proxies).put() File "/data/tca_open_source/client/util/api/httpclient.py", line 82, in put result = HttpRequest.request(url=self.url, headers=self.headers, body=self.data, method="PUT") File "/data/tca_open_source/client/util/api/httpclient.py", line 43, in request response = urlopen(req).read() File "/usr/local/python3/lib/python3.7/urllib/request.py", line 222, in urlopen return opener.open(url, data, timeout) File "/usr/local/python3/lib/python3.7/urllib/request.py", line 531, in open response = meth(req, response) File "/usr/local/python3/lib/python3.7/urllib/request.py", line 641, in http_response 'http', request, response, code, msg, hdrs) File "/usr/local/python3/lib/python3.7/urllib/request.py", line 569, in error return self._call_chain(args) File "/usr/local/python3/lib/python3.7/urllib/request.py", line 503, in _call_chain result = func(args) File "/usr/local/python3/lib/python3.7/urllib/request.py", line 649, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 405: Not Allowed

Donny2g commented 2 years ago

补充NGINX日志

405 157 "-" "Python-urllib/3.7" "-" 127.0.0.1 - - [20/Jan/2022:18:21:46 +0800] "PUT /server/files/taskdata/projects/1/task_16/c26265ec79da11ec9f600050569a45a5/task_16.log HTTP/1.1" 405 157 "-" "Python-urllib/3.7" "-" 127.0.0.1 - - [20/Jan/2022:18:21:51 +0800] "PUT /server/files/taskdata/projects/1/task_16/c26265ec79da11ec9f600050569a45a5/task_16.log HTTP/1.1" 405 157 "-" "Python-urllib/3.7" "-" 127.0.0.1 - - [20/Jan/2022:18:46:12 +0800] "PUT /api/files/codedog/public_server_temp/jobdata/projects/1/job1/2edafdda79de11ecb2e10050569a45a5/job_context.json HTTP/1.0" 200 24 "-" "python-urllib3/1.26.8" "127.0.0.1" 127.0.0.1 - - [20/Jan/2022:18:46:22 +0800] "PUT /server/files/taskdata/projects/1/task_1/35754dd079de11ecbe740050569a45a5/task_1.log HTTP/1.1" 405 157 "-" "Python-urllib/3.7" "-" 127.0.0.1 - - [20/Jan/2022:18:46:27 +0800] "PUT /server/files/taskdata/projects/1/task_1/35754dd079de11ecbe740050569a45a5/task_1.log HTTP/1.1" 405 157 "-" "Python-urllib/3.7" "-" 127.0.0.1 - - [20/Jan/2022:18:46:32 +0800] "PUT /server/files/taskdata/projects/1/task_1/35754dd079de11ecbe740050569a45a5/task_1.log HTTP/1.1" 405 157 "-" "Python-urllib/3.7" "-"

Donny2g commented 2 years ago

已解决,在client中的config.ini文件中SERVER_URL和FILE_SERVER必须填写一致,端口也是一致

zhang9w0v5 commented 2 years ago

@Master-Kang 当前初期,还是在github上沉淀好一些,便于后续新接触的人能查阅。目前我们主职内部工作也繁忙,兼顾外部交流群暂时很难提高交流频率。大家先不要着急,我们一起一步步来完善项目。

aaaa-j commented 2 years ago

还是建议建一个交流群

@Master-Kang 现在有QQ交流群啦(361791391)