aboutcode-org / aboutcode-org/scancode-toolkit

Feedback on using `run_scan` from Python

Đang mở
#2,003 0 bình luận 0 reaction 1 người được giao Được @pombredanne nhận Xem trên GitHub
bug
Ngôn ngữ chính
Python
Star
2.6k
Fork
791
Merge trung bình
1 ngày 12 giờ
Pull request đã merge (30 ngày)
5

Mô tả

I've started to use the internal ScanCode API to run my scans using `run_scan`.
It works great but I found minor issues on which we could improve for the Python API:

### 1. Options are not set in the `headers`
Using the command line, we got a proper list of used options during the scan:
```
'options': {
'--classify': True,
'--consolidate': True,
[...]
```
Those are missing when calling directly `run_scan`:
```
'options': {}
```

### 2. Scan options are not validated
```
run_scan(input, wrong_option=True)
```
The fact `wrong_option` is not supported is not reported. It would be nice to have a sanity check on the provided scanning options. We do have that check using the command line:
```
$ scancode --wrong_option
Error: no such option: --wrong_option
```

### 3. Different default value for `quiet`
`quiet` is False by default when using the command line but declared as True in the `run_scan` function:
```
def run_scan(
[...]
quiet=True,
```

### 4. Logging capture leak
We can capture the logging done to stdout/stderr by the command providing a `echo_func`, for example:
```
scan_log = []
def capture_scan_log(text, *args, **kwargs):
scan_log.append(text)

run_scan(
[...],
echo_func=capture_scan_log,
)
```
Everywhere is properly captured except the progress bar that is displayed and not capture:
```
[####################] 10
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.