From 1b9b89b5876cc493edaae87c28bce23199a005bc Mon Sep 17 00:00:00 2001 From: Peter Silva Date: Fri, 9 Aug 2024 16:23:48 -0400 Subject: [PATCH] fix #1159 obvious error messages when no configurations match --- sarracenia/sr.py | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/sarracenia/sr.py b/sarracenia/sr.py index 3f20d23db..466a2e744 100755 --- a/sarracenia/sr.py +++ b/sarracenia/sr.py @@ -1601,8 +1601,8 @@ def declare(self): flow=None def disable(self): - if len(self.filtered_configurations) == 0: - logging.error('%s configuration not found', self.leftovers) + if len(self.leftovers) > 0 and not self._action_all_configs: + logging.error( f"{self.leftovers} configuration not found" ) return for f in self.filtered_configurations: @@ -1667,8 +1667,8 @@ def log(self): self.run_command(['tail', '-f', lfn]) def enable(self): - if len(self.filtered_configurations) == 0: - logging.error('%s configuration not found', self.leftovers) + if len(self.leftovers) > 0 and not self._action_all_configs: + logging.error( f'{self.leftovers} configuration not found' ) return # declare exchanges first. for f in self.filtered_configurations: @@ -1791,6 +1791,10 @@ def foreground(self): def cleanup(self) -> bool: + if len(self.leftovers) > 0 and not self._action_all_configs: + logging.error( f'{self.leftovers} configuration not found' ) + return + if len(self.filtered_configurations) > 1 : if len(self.filtered_configurations) != self.options.dangerWillRobinson: logging.error( @@ -2065,8 +2069,8 @@ def config_show(self): def remove(self): - if len(self.filtered_configurations) == 0: - logging.error("No configuration matched") + if len(self.leftovers) > 0 and not self._action_all_configs: + logging.error( f"{self.leftovers} configuration not found" ) return if len(self.filtered_configurations) > 1 : @@ -2153,6 +2157,10 @@ def sanity(self): :return: """ + if len(self.leftovers) > 0 and not self._action_all_configs: + logging.error( f"{self.leftovers} configuration not found" ) + return + pcount = 0 kill_hung=[] for f in self.filtered_configurations: @@ -2236,6 +2244,10 @@ def start(self): :return: """ + if len(self.leftovers) > 0 and not self._action_all_configs: + logging.error( f"{self.leftovers} configuration not found" ) + return + pcount = 0 for f in self.filtered_configurations: @@ -2282,13 +2294,16 @@ def stop(self): return 0 on success, non-zero on failure. """ + if len(self.leftovers) > 0 and not self._action_all_configs: + logging.error( f"{self.leftovers} configuration not found" ) + return + self._clean_missing_proc_state() if len(self.procs) == 0: print('no procs running...already stopped') return - print('sending SIGTERM ', end='', flush=True) pcount = 0 fg_instances = set() @@ -2536,6 +2551,10 @@ def status(self): """ v3 Printing prettier statuses for each component/configs found """ + if len(self.leftovers) > 0 and not self._action_all_configs: + logging.error( f"{self.leftovers} configuration not found" ) + return + flowNameWidth=self.cumulative_stats['flowNameWidth'] latestTransferWidth=self.cumulative_stats['latestTransferWidth'] @@ -2879,6 +2898,11 @@ def overview(self): :return: """ + + if len(self.leftovers) > 0 and not self._action_all_configs: + logging.error( f"{self.leftovers} configuration not found" ) + return + bad = 0