Skip to content

Commit

Permalink
adds loop to fix len(dns). issue 79
Browse files Browse the repository at this point in the history
resolve apel#79 . i have just looped everything in the try statement although i am not sure if it is whats needed.
  • Loading branch information
DanielPerkins7 committed Aug 2, 2023
1 parent cb8957a commit 86db120
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion ssm/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 86db120

Please sign in to comment.