aboutcode-org / aboutcode-org/scancode-toolkit

Feedback on using `run_scan` from Python

Abierto
#2,003 0 comentarios 0 reacciones 1 asignado Reclamado por @pombredanne Ver en GitHub
bug
Lenguaje dominante
Python
Estrellas
2.6k
Forks
791
Merge medio
1 d 12 h
PR fusionados (30 d)
5

Descripción

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
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.