57
57
import com .ibm .usecases .scanning .services .git .GitService ;
58
58
import com .ibm .usecases .scanning .services .indexing .JavaIndexService ;
59
59
import com .ibm .usecases .scanning .services .indexing .ProjectModule ;
60
+ import com .ibm .usecases .scanning .services .indexing .PythonIndexService ;
60
61
import com .ibm .usecases .scanning .services .pkg .MavenPackageFinderService ;
61
62
import com .ibm .usecases .scanning .services .pkg .SetupPackageFinderService ;
62
63
import com .ibm .usecases .scanning .services .pkg .TomlPackageFinderService ;
65
66
import com .ibm .usecases .scanning .services .resolve .PurlResolver ;
66
67
import com .ibm .usecases .scanning .services .scan .ScanResultDTO ;
67
68
import com .ibm .usecases .scanning .services .scan .java .JavaScannerService ;
69
+ import com .ibm .usecases .scanning .services .scan .python .PythonScannerService ;
68
70
import jakarta .annotation .Nonnull ;
69
71
import jakarta .annotation .Nullable ;
70
72
import java .io .File ;
@@ -292,11 +294,11 @@ private void handleIndexModulesCommand(@Nonnull IndexModulesCommand command) thr
292
294
javaIndexService .index (scanAggregate .getPackageFolder ());
293
295
this .index .put (Language .JAVA , javaIndex );
294
296
// python
295
- // final PythonIndexService pythonIndexService =
296
- // new PythonIndexService(this.progressDispatcher, dir);
297
- // final List<ProjectModule> pythonIndex =
298
- // pythonIndexService.index(scanAggregate.getPackageFolder());
299
- // this.index.put(Language.PYTHON, pythonIndex);
297
+ final PythonIndexService pythonIndexService =
298
+ new PythonIndexService (this .progressDispatcher , dir );
299
+ final List <ProjectModule > pythonIndex =
300
+ pythonIndexService .index (scanAggregate .getPackageFolder ());
301
+ this .index .put (Language .PYTHON , pythonIndex );
300
302
// continue with scan
301
303
this .commandBus .send (new ScanCommand (command .id ()));
302
304
} catch (Exception e ) {
@@ -372,43 +374,43 @@ private void handleScanCommand(@Nonnull ScanCommand command)
372
374
javaScanResultDTO .cbom ()));
373
375
}
374
376
375
- // // python
376
- // final PythonScannerService pythonScannerService =
377
- // new PythonScannerService(
378
- // this.progressDispatcher,
379
- // Optional.ofNullable(this.projectDirectory)
380
- // .orElseThrow(NoProjectDirectoryProvided::new));
381
- // final ScanResultDTO pythonScanResultDTO =
382
- // pythonScannerService.scan(
383
- // gitUrl,
384
- // scanAggregate.getRevision(),
385
- // commit,
386
- // scanAggregate.getPackageFolder().orElse(null),
387
- // Optional.ofNullable(this.index)
388
- // .map(i -> i.get(Language.PYTHON))
389
- // .orElseThrow(NoIndexForProject::new));
390
- // // update statistics
391
- // numberOfScannedLine += pythonScanResultDTO.numberOfScannedLine();
392
- // numberOfScannedFiles += pythonScanResultDTO.numberOfScannedFiles();
377
+ // python
378
+ final PythonScannerService pythonScannerService =
379
+ new PythonScannerService (
380
+ this .progressDispatcher ,
381
+ Optional .ofNullable (this .projectDirectory )
382
+ .orElseThrow (NoProjectDirectoryProvided ::new ));
383
+ final ScanResultDTO pythonScanResultDTO =
384
+ pythonScannerService .scan (
385
+ gitUrl ,
386
+ scanAggregate .getRevision (),
387
+ commit ,
388
+ scanAggregate .getPackageFolder ().orElse (null ),
389
+ Optional .ofNullable (this .index )
390
+ .map (i -> i .get (Language .PYTHON ))
391
+ .orElseThrow (NoIndexForProject ::new ));
392
+ // update statistics
393
+ numberOfScannedLine += pythonScanResultDTO .numberOfScannedLine ();
394
+ numberOfScannedFiles += pythonScanResultDTO .numberOfScannedFiles ();
393
395
394
- // if (pythonScanResultDTO.cbom() != null) {
395
- // // update statistics
396
- // if (cbom != null) {
397
- // cbom.merge(pythonScanResultDTO.cbom());
398
- // } else {
399
- // cbom = pythonScanResultDTO.cbom();
400
- // }
396
+ if (pythonScanResultDTO .cbom () != null ) {
397
+ // update statistics
398
+ if (cbom != null ) {
399
+ cbom .merge (pythonScanResultDTO .cbom ());
400
+ } else {
401
+ cbom = pythonScanResultDTO .cbom ();
402
+ }
401
403
402
- // scanAggregate.reportScanResults(
403
- // new LanguageScan(
404
- // Language.PYTHON,
405
- // new ScanMetadata(
406
- // pythonScanResultDTO.startTime(),
407
- // pythonScanResultDTO.endTime(),
408
- // pythonScanResultDTO.numberOfScannedLine(),
409
- // pythonScanResultDTO.numberOfScannedFiles()),
410
- // pythonScanResultDTO.cbom()));
411
- // }
404
+ scanAggregate .reportScanResults (
405
+ new LanguageScan (
406
+ Language .PYTHON ,
407
+ new ScanMetadata (
408
+ pythonScanResultDTO .startTime (),
409
+ pythonScanResultDTO .endTime (),
410
+ pythonScanResultDTO .numberOfScannedLine (),
411
+ pythonScanResultDTO .numberOfScannedFiles ()),
412
+ pythonScanResultDTO .cbom ()));
413
+ }
412
414
413
415
// publish scan finished and save state
414
416
scanAggregate .scanFinished ();
@@ -435,10 +437,9 @@ private void handleScanCommand(@Nonnull ScanCommand command)
435
437
.toString ()));
436
438
this .progressDispatcher .send (
437
439
new ProgressMessage (ProgressMessageType .LABEL , "Finished" ));
438
- } catch (Exception e ) {
440
+ } catch (Exception | NoSuchMethodError e ) { // catch NoSuchMethodError: see issue #138
439
441
this .progressDispatcher .send (
440
442
new ProgressMessage (ProgressMessageType .ERROR , e .getMessage ()));
441
- this .compensate (command .id ());
442
443
throw e ;
443
444
} finally {
444
445
this .compensate (command .id ());
0 commit comments