From 86db1201c2457fbc4ec66d39db9bfa66291a937d Mon Sep 17 00:00:00 2001 From: DanielPerkins7 Date: Wed, 2 Aug 2023 14:26:12 +0000 Subject: [PATCH 1/4] adds loop to fix len(dns). issue 79 resolve #79 . i have just looped everything in the try statement although i am not sure if it is whats needed. --- ssm/agents.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ssm/agents.py b/ssm/agents.py index 673a9906..c9574fb5 100644 --- a/ssm/agents.py +++ b/ssm/agents.py @@ -374,7 +374,21 @@ def get_dns(dn_file, log): f.close() # If no valid DNs, SSM cannot receive any messages. if len(dns) == 0: - raise Ssm2Exception('No valid DNs found in %s. SSM will not start' % dn_file) + fails = 0 + while fails < 3 and len(dns) == 0: + for line in lines: + if line.isspace() or line.strip().startswith('#'): + continue + elif line.strip().startswith('/'): + dns.append(line.strip()) + else: + log.warning('DN in incorrect format: %s', line) + if len(dns) == 0: + raise Ssm2Exception('No valid DNs found in %s. SSM will not start' % dn_file) + + finally: + if f is not None: + f.close() log.debug('%s DNs found.', len(dns)) return dns From 46f0d1ab389984f8f18714db15a01fa6d27fd5bb Mon Sep 17 00:00:00 2001 From: DanielPerkins7 Date: Wed, 2 Aug 2023 15:03:38 +0000 Subject: [PATCH 2/4] adds loop to fix len(dns) - fixed. issue 79 resolve #79 --- ssm/agents.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ssm/agents.py b/ssm/agents.py index c9574fb5..a8ce5553 100644 --- a/ssm/agents.py +++ b/ssm/agents.py @@ -369,9 +369,24 @@ def get_dns(dn_file, log): dns.append(line.strip()) else: log.warning('DN in incorrect format: %s', line) + + # If no valid DNs, SSM cannot receive any messages. + if len(dns) == 0: + fails = 0 + while fails < 3 and len(dns) == 0: + for line in lines: + if line.isspace() or line.strip().startswith('#'): + continue + elif line.strip().startswith('/'): + dns.append(line.strip()) + else: + log.warning('DN in incorrect format: %s', line) + if len(dns) == 0: + raise Ssm2Exception('No valid DNs found in %s. SSM will not start' % dn_file) finally: if f is not None: f.close() +<<<<<<< Updated upstream # If no valid DNs, SSM cannot receive any messages. if len(dns) == 0: fails = 0 @@ -389,6 +404,8 @@ def get_dns(dn_file, log): finally: if f is not None: f.close() +======= +>>>>>>> Stashed changes log.debug('%s DNs found.', len(dns)) return dns From fb427c03c99a0812afdc07ea225a091ff64a9e04 Mon Sep 17 00:00:00 2001 From: DanielPerkins7 Date: Wed, 2 Aug 2023 15:06:36 +0000 Subject: [PATCH 3/4] adds loop to fix len(dns) - fixed. issue 79 resolve #79 --- ssm/agents.py | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/ssm/agents.py b/ssm/agents.py index a8ce5553..b9bca24f 100644 --- a/ssm/agents.py +++ b/ssm/agents.py @@ -386,26 +386,6 @@ def get_dns(dn_file, log): finally: if f is not None: f.close() -<<<<<<< Updated upstream - # If no valid DNs, SSM cannot receive any messages. - if len(dns) == 0: - fails = 0 - while fails < 3 and len(dns) == 0: - for line in lines: - if line.isspace() or line.strip().startswith('#'): - continue - elif line.strip().startswith('/'): - dns.append(line.strip()) - else: - log.warning('DN in incorrect format: %s', line) - if len(dns) == 0: - raise Ssm2Exception('No valid DNs found in %s. SSM will not start' % dn_file) - - finally: - if f is not None: - f.close() -======= ->>>>>>> Stashed changes log.debug('%s DNs found.', len(dns)) return dns From db0d6afd6c07b1e9318154b645ee084f711b826d Mon Sep 17 00:00:00 2001 From: DanielPerkins7 Date: Wed, 2 Aug 2023 14:26:12 +0000 Subject: [PATCH 4/4] adds loop to fix len(dns). issue 79 resolve #79 . i have just looped everything in the try statement although i am not sure if it is whats needed. --- ssm/agents.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ssm/agents.py b/ssm/agents.py index 3d6ef885..9d8126d1 100644 --- a/ssm/agents.py +++ b/ssm/agents.py @@ -373,12 +373,23 @@ def get_dns(dn_file, log): dns.append(line.strip()) else: log.warning('DN in incorrect format: %s', line) + + # If no valid DNs, SSM cannot receive any messages. + if len(dns) == 0: + fails = 0 + while fails < 3 and len(dns) == 0: + for line in lines: + if line.isspace() or line.strip().startswith('#'): + continue + elif line.strip().startswith('/'): + dns.append(line.strip()) + else: + log.warning('DN in incorrect format: %s', line) + if len(dns) == 0: + raise Ssm2Exception('No valid DNs found in %s. SSM will not start' % dn_file) finally: if f is not None: f.close() - # If no valid DNs, SSM cannot receive any messages. - if len(dns) == 0: - raise Ssm2Exception('No valid DNs found in %s. SSM will not start' % dn_file) log.debug('%s DNs found.', len(dns)) return dns