File tree 1 file changed +8
-11
lines changed 1 file changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -71,23 +71,20 @@ def zap_shutdown():
71
71
logging .info ("Attempting to shutdown ZAP" )
72
72
apikey = os .getenv ("ZAP_API_KEY" , "" )
73
73
zap = ZAPv2 (proxies = {"http" : PROXY , "https" : PROXY }, apikey = apikey )
74
- try :
75
- sleep_time = 20
76
- attempts = int (( TIMEOUT_MINS * 60 ) / 20 )
77
- for _ in range ( attempts ) :
74
+ sleep_time = 20
75
+ attempts = int (( TIMEOUT_MINS * 60 ) / 20 )
76
+ for attempt in range ( attempts ):
77
+ try :
78
78
shutdown_endpoint = zap .base + "core/action/shutdown/"
79
79
headers = { "X-ZAP-API-Key" : apikey }
80
80
resp = requests .get (shutdown_endpoint , proxies = proxies , headers = headers ,
81
81
timeout = int (TIMEOUT_MINS * 60 )/ 2 )
82
82
logging .info (f"Response code from requesting ZAP shutdown: { resp .status_code } " )
83
83
if int (resp .status_code ) == 200 :
84
- break
85
- time .sleep (sleep_time )
86
-
87
- except Exception as e :
88
- logging .error ("failed to shut down zap." )
89
- logging .error (e )
90
-
84
+ return
85
+ except Exception as e :
86
+ logging .error (f"An error occured while shutting down zap. Attempt { attempt + 1 } " )
87
+ time .sleep (sleep_time )
91
88
92
89
def parse_url (url ):
93
90
"""
You can’t perform that action at this time.
0 commit comments