aboutcode-org / aboutcode-org/scancode-toolkit
Feedback on using `run_scan` from Python
- Dominant language
- Python
- Stars
- 2.6k
- Forks
- 791
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 5
Description
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
```
Contributor guide
Assessment
This issue has not been assessed yet.