Skip to content

Commit

Permalink
one way of addressing #827, making dangerWillRobinson a number that m…
Browse files Browse the repository at this point in the history
…ust match
  • Loading branch information
petersilva committed Nov 20, 2023
1 parent 244ae90 commit 2316b98
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions sarracenia/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2344,8 +2344,8 @@ def parse_args(self, isPost=False):
nargs='?',
help=' specifical configuration to select ')
parser.add_argument('--dangerWillRobinson',
action='store_true',
default=False,
type=int,
default=0,
help='Confirm you want to do something dangerous')
parser.add_argument('--debug',
action='store_true',
Expand Down
26 changes: 14 additions & 12 deletions sarracenia/sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1577,11 +1577,11 @@ def foreground(self):

def cleanup(self):

if len(self.filtered_configurations
) > 1 and not self.options.dangerWillRobinson:
logging.error(
"specify --dangerWillRobinson to cleanup > 1 config at a time")
return
if len(self.filtered_configurations) > 1 :
if len(self.filtered_configurations) != self.options.dangerWillRobinson:
logging.error(
"specify --dangerWillRobinson=<number> of configs to cleanup when cleaning more than one")
return

queues_to_delete = []
for f in self.filtered_configurations:
Expand Down Expand Up @@ -1828,11 +1828,13 @@ def remove(self):
logging.error("No configuration matched")
return

if len(self.filtered_configurations
) > 1 and not self.options.dangerWillRobinson:
logging.error(
"specify --dangerWillRobinson to remove > 1 config at a time")
return
logging.error( f" configs matched: {len(self.filtered_configurations)} ")

if len(self.filtered_configurations) > 1 :
if len(self.filtered_configurations) != self.options.dangerWillRobinson:
logging.error(
"specify --dangerWillRobinson=<n> of configs to remove when > 1 involved.")
return

for f in self.filtered_configurations:
if self.please_stop:
Expand Down Expand Up @@ -2128,7 +2130,7 @@ def stop(self):
print('All stopped after try %d' % attempts)
if len(fg_instances) > 0:
print(f"Foreground instances {fg_instances} are running and were not stopped.")
print("Use --dangerWillRobinson to force stop foreground instances with sr3 stop.")
print("Use --dangerWillRobinson=1 to force stop foreground instances with sr3 stop.")
return 0
attempts += 1

Expand Down Expand Up @@ -2187,7 +2189,7 @@ def stop(self):
print('All stopped after KILL')
if len(fg_instances) > 0:
print(f"Foreground instances {fg_instances} are running and were not stopped.")
print("Use --dangerWillRobinson to force stop foreground instances with sr3 stop.")
print("Use --dangerWillRobinson=1 to force stop foreground instances with sr3 stop.")
return 0
else:
print('not responding to SIGKILL:')
Expand Down

0 comments on commit 2316b98

Please sign in to comment.