16
16
from rich .columns import Columns
17
17
import threading
18
18
import signal
19
- import select
19
+ import select
20
20
import sys
21
21
22
+
22
23
def interactive_shell (_app , _ui , _is_interactive ):
23
24
"""
24
25
Starts an interactive shell for the application.
@@ -33,15 +34,15 @@ def interactive_shell(_app, _ui, _is_interactive):
33
34
shell = Shell (_app )
34
35
__only_first_time = True
35
36
36
- while _app .cleaning_up == False :
37
- if _app .is_running == False and _is_interactive == True and __only_first_time == True :
37
+ while _app .cleaning_up is False :
38
+ if _app .is_running is False and _is_interactive is True and __only_first_time is True :
38
39
__only_first_time = False
39
40
pass
40
41
else :
41
42
# Setting inpout with timeout in order not to block in case of cancel
42
43
# and _app.cleaning_up is re-checked
43
44
a , b , c = select .select ([sys .stdin ], [], [], 2 )
44
- if a == [] and b == [] and c == []:
45
+ if a == [] and b == [] and c == []:
45
46
continue
46
47
47
48
_ui ["ui_live" ].stop ()
@@ -135,7 +136,7 @@ def do_scan(self, v):
135
136
return
136
137
v1 , v2 = v .split (" " )
137
138
_r = self ._app .add_scan (v1 , v2 )
138
- if self ._app .is_running == False :
139
+ if self ._app .is_running is False :
139
140
_dscan_thread = threading .Thread (target = self ._app .scan )
140
141
_dscan_thread .start ()
141
142
if _r is False :
@@ -220,10 +221,12 @@ def do_exit(self, _):
220
221
Exit Deltascan"""
221
222
os ._exit (0 )
222
223
224
+
223
225
def signal_handler (signal , frame ):
224
226
print ("Exiting without cleanup :-(" )
225
227
os ._exit (1 )
226
228
229
+
227
230
def run ():
228
231
"""
229
232
Entry point for the command line interface.
@@ -362,8 +365,8 @@ def run():
362
365
_dscan_thread .start ()
363
366
_shell_thread .start ()
364
367
_dscan_thread .join ()
365
-
366
- if _dscan .is_interactive or clargs .interactive == True :
368
+
369
+ if _dscan .is_interactive or clargs .interactive is True :
367
370
_shell_thread .join ()
368
371
else :
369
372
print ("No scans left in the queue... Exiting." )
@@ -389,12 +392,12 @@ def run():
389
392
output = CliOutput (_r )
390
393
output .display ()
391
394
else :
392
- if clargs .interactive == True :
395
+ if clargs .interactive is True :
393
396
print ("No action provided. Starting interactive shell." )
394
397
else :
395
398
print ("Invalid action. Exiting..." )
396
399
397
- if clargs .interactive == True :
400
+ if clargs .interactive is True :
398
401
_shell_thread = threading .Thread (
399
402
target = interactive_shell , args = (_dscan , ui_context , clargs .interactive ,))
400
403
_shell_thread .start ()
@@ -406,8 +409,9 @@ def run():
406
409
signal .signal (signal .SIGINT , signal_handler )
407
410
_dscan .cleanup ()
408
411
print ("Cancelling running scans and closing ..." )
409
- except Exception :
412
+ except Exception as e :
410
413
print (f"Unknown error occurred: { str (e )} " )
411
414
415
+
412
416
if __name__ == "__main__" :
413
417
run ()
0 commit comments