aboutcode-org / aboutcode-org/scancode-toolkit

Feedback on using `run_scan` from Python

Ouverte
#2,003 0 commentaires 0 réactions 1 personne assignée Réclamée par @pombredanne Voir sur GitHub
bug
Langage dominant
Python
Étoiles
2.6k
Forks
791
Merge moyen
1 j 12 h
PR mergées (30 j)
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
```

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.