2525 snapshot_bitcoin_datadir ,
2626)
2727from .process import run_command , stream_command
28+ from .status import _get_active_binaries , _get_active_scenarios
2829
2930console = Console ()
3031
3132
32- def get_active_scenarios ():
33- """Get list of active scenarios"""
34- commanders = get_mission ("commander" )
35- return [c .metadata .name for c in commanders ]
36-
37-
3833@click .command ()
39- @click .argument ("scenario_name" , required = False )
40- def stop (scenario_name ):
41- """Stop a running scenario or all scenarios"""
42- active_scenarios = get_active_scenarios ()
34+ @click .argument ("name" , required = False )
35+ def stop (name ):
36+ """Stop one or all running scenarios or binaries"""
37+ all_running = [c ["name" ] for c in _get_active_scenarios ()] + [
38+ b ["name" ] for b in _get_active_binaries ()
39+ ]
4340
44- if not active_scenarios :
45- console .print ("[bold red]No active scenarios found.[/bold red]" )
41+ if not all_running :
42+ console .print ("[bold red]No active scenarios or binaries found.[/bold red]" )
4643 return
4744
48- if not scenario_name :
49- table = Table (title = "Active Scenarios" , show_header = True , header_style = "bold magenta" )
45+ if not name :
46+ table = Table (
47+ title = "Active Scenarios & binaries" , show_header = True , header_style = "bold magenta"
48+ )
5049 table .add_column ("Number" , style = "cyan" , justify = "right" )
51- table .add_column ("Scenario Name" , style = "green" )
50+ table .add_column ("Name" , style = "green" )
5251
53- for idx , name in enumerate (active_scenarios , 1 ):
52+ for idx , name in enumerate (all_running , 1 ):
5453 table .add_row (str (idx ), name )
5554
5655 console .print (table )
5756
58- choices = [str (i ) for i in range (1 , len (active_scenarios ) + 1 )] + ["a" , "q" ]
57+ choices = [str (i ) for i in range (1 , len (all_running ) + 1 )] + ["a" , "q" ]
5958 choice = Prompt .ask (
60- "[bold yellow]Enter the number of the scenario to stop, 'a' to stop all, or 'q' to quit[/bold yellow]" ,
59+ "[bold yellow]Enter the number you want to stop, 'a' to stop all, or 'q' to quit[/bold yellow]" ,
6160 choices = choices ,
6261 show_choices = False ,
6362 )
@@ -67,18 +66,18 @@ def stop(scenario_name):
6766 return
6867 elif choice == "a" :
6968 if Confirm .ask ("[bold red]Are you sure you want to stop all scenarios?[/bold red]" ):
70- stop_all_scenarios (active_scenarios )
69+ stop_all_scenarios (all_running )
7170 else :
7271 console .print ("[bold blue]Operation cancelled.[/bold blue]" )
7372 return
7473
75- scenario_name = active_scenarios [int (choice ) - 1 ]
74+ name = all_running [int (choice ) - 1 ]
7675
77- if scenario_name not in active_scenarios :
78- console .print (f"[bold red]No active scenario found with name: { scenario_name } [/bold red]" )
76+ if name not in all_running :
77+ console .print (f"[bold red]No active scenario or binary found with name: { name } [/bold red]" )
7978 return
8079
81- stop_scenario (scenario_name )
80+ stop_scenario (name )
8281
8382
8483def stop_scenario (scenario_name ):
@@ -111,7 +110,7 @@ def stop_all_scenarios(scenarios):
111110
112111def list_active_scenarios ():
113112 """List all active scenarios"""
114- active_scenarios = get_active_scenarios ()
113+ active_scenarios = [ c [ "name" ] for c in _get_active_scenarios ()]
115114 if not active_scenarios :
116115 print ("No active scenarios found." )
117116 return
0 commit comments