@@ -35,7 +35,7 @@ def clear_screen():
35
35
os .system ("clear -x" )
36
36
37
37
38
- def interactive_shell (_app , _ui , _interactive ):
38
+ def interactive_shell (_app , _ui , _interactive , open_shell = False ):
39
39
"""
40
40
Starts an interactive shell for the application.
41
41
@@ -50,8 +50,9 @@ def interactive_shell(_app, _ui, _interactive):
50
50
__only_first_time = True
51
51
52
52
while _app .cleaning_up is False :
53
- if _app .is_running is True and _interactive is True and __only_first_time is True :
53
+ if ( _app .is_running is True and _interactive is True and __only_first_time is True ) or open_shell is True :
54
54
__only_first_time = False
55
+ open_shell = False
55
56
pass
56
57
else :
57
58
# Setting input with timeout in order not to block in case of cancel
@@ -176,7 +177,7 @@ def do_view(self, _):
176
177
Execute the view action using the current configuration"""
177
178
try :
178
179
_r = self ._app .view ()
179
- output = CliOutput (_r , self ._app .suppress )
180
+ output = CliOutput (_r , self ._app .verbose )
180
181
_res = output .display ()
181
182
self .last_index_to_uuid_mapping = _res
182
183
except Exception as e :
@@ -301,7 +302,7 @@ def run():
301
302
parser = argparse .ArgumentParser (
302
303
prog = 'deltascan' , description = 'A package for scanning deltas' )
303
304
parser .add_argument (
304
- "action" , help = 'the command to run' , choices = ['scan' , 'diff' , 'view' , 'import' , 'version' ])
305
+ "action" , help = 'the command to run' , choices = ['scan' , 'diff' , 'view' , 'import' , 'shell' , ' version' ])
305
306
parser .add_argument ("-o" , "--output" , help = 'output file' , required = False )
306
307
parser .add_argument ("-d" , "--diff-files" ,
307
308
help = 'comma separated files to find their differences (xml)' ,
@@ -326,8 +327,8 @@ def run():
326
327
# "-v", "--verbose", default=False, action='store_true',
327
328
# help="verbose output", required=False)
328
329
parser .add_argument (
329
- "-s " , "--suppress " , default = False , action = 'store_true' ,
330
- help = "suppress output" , required = False )
330
+ "-v " , "--verbose " , default = False , action = 'store_true' ,
331
+ help = "verbose output" , required = False )
331
332
parser .add_argument (
332
333
"--n-scans" , help = "limit of scans databse queries. It is applied in scans view as well as scans diff" ,
333
334
required = False )
@@ -388,8 +389,7 @@ def run():
388
389
"action" : clargs .action ,
389
390
"profile" : clargs .profile ,
390
391
"conf_file" : clargs .conf_file ,
391
- "verbose" : None ,
392
- "suppress" : clargs .suppress ,
392
+ "verbose" : clargs .verbose ,
393
393
"n_scans" : clargs .n_scans ,
394
394
"n_diffs" : clargs .n_diffs ,
395
395
"fdate" : clargs .from_date ,
@@ -445,7 +445,7 @@ def run():
445
445
item for sublist in [
446
446
_s ["scans" ] for _s in _dscan .result if "scans" in _s
447
447
] for item in sublist
448
- ], _dscan .suppress )
448
+ ], _dscan .verbose )
449
449
450
450
output .display ()
451
451
os ._exit (0 )
@@ -455,16 +455,23 @@ def run():
455
455
_r = _dscan .files_diff ()
456
456
else :
457
457
_r = _dscan .diffs ()
458
- output = CliOutput (_r )
458
+ output = CliOutput (_r , _dscan . verbose )
459
459
output .display ()
460
460
elif clargs .action == 'view' :
461
461
_r = _dscan .view ()
462
- output = CliOutput (_r )
462
+ output = CliOutput (_r , _dscan . verbose )
463
463
output .display ()
464
464
elif clargs .action == 'import' :
465
465
_r = _dscan .import_data ()
466
- output = CliOutput (_r )
466
+ output = CliOutput (_r , _dscan . verbose )
467
467
output .display ()
468
+ elif clargs .action == 'shell' :
469
+ _dscan_thread = ThreadWithException (target = _dscan .scan )
470
+ _shell_thread = ThreadWithException (
471
+ target = interactive_shell , args = (_dscan , ui_context , clargs .interactive , True ))
472
+ _dscan_thread .start ()
473
+ _shell_thread .start ()
474
+ _dscan_thread .join ()
468
475
else :
469
476
if clargs .interactive is True :
470
477
print ("No action provided. Starting interactive shell." )
0 commit comments