2121# Visit https://github.com/aboutcode-org/scancode.io for support and download.
2222
2323import json
24+ import logging
2425
2526from django .apps import apps
2627from django .core .exceptions import ObjectDoesNotExist
5859from scanpipe .pipes .compliance import get_project_compliance_alerts
5960from scanpipe .views import project_results_json_response
6061
62+ logger = logging .getLogger (__name__ )
6163scanpipe_app = apps .get_app_config ("scanpipe" )
6264
6365
@@ -401,8 +403,11 @@ def add_webhook(self, request, *args, **kwargs):
401403 def destroy (self , request , * args , ** kwargs ):
402404 try :
403405 return super ().destroy (request , * args , ** kwargs )
404- except RunInProgressError as error :
405- return Response ({"status" : str (error )}, status = status .HTTP_400_BAD_REQUEST )
406+ except RunInProgressError :
407+ return Response (
408+ {"status" : "Cannot delete project while a run is in progress." },
409+ status = status .HTTP_400_BAD_REQUEST ,
410+ )
406411
407412 @action (detail = True , methods = ["get" , "post" ])
408413 def archive (self , request , * args , ** kwargs ):
@@ -423,10 +428,13 @@ def archive(self, request, *args, **kwargs):
423428 remove_codebase = request .data .get ("remove_codebase" ),
424429 remove_output = request .data .get ("remove_output" ),
425430 )
426- except RunInProgressError as error :
427- return Response ({"status" : str (error )}, status = status .HTTP_400_BAD_REQUEST )
428- else :
429- return Response ({"status" : f"The project { project } has been archived." })
431+ except RunInProgressError :
432+ return Response (
433+ {"status" : "Cannot archive project while a run is in progress." },
434+ status = status .HTTP_400_BAD_REQUEST ,
435+ )
436+
437+ return Response ({"status" : f"The project { project } has been archived." })
430438
431439 @action (detail = True , methods = ["get" , "post" ])
432440 def reset (self , request , * args , ** kwargs ):
@@ -442,8 +450,11 @@ def reset(self, request, *args, **kwargs):
442450 restore_pipelines = request .data .get ("restore_pipelines" , False ),
443451 execute_now = request .data .get ("execute_now" , False ),
444452 )
445- except RunInProgressError as error :
446- return Response ({"status" : str (error )}, status = status .HTTP_400_BAD_REQUEST )
453+ except RunInProgressError :
454+ return Response (
455+ {"status" : "Cannot reset project while a run is in progress." },
456+ status = status .HTTP_400_BAD_REQUEST ,
457+ )
447458 else :
448459 message = f"The { project } project has been reset."
449460 return Response ({"status" : message })
0 commit comments