Skip to content

Commit

Permalink
adds loop to fix len(dns) - fixed. issue 79
Browse files Browse the repository at this point in the history
resolve apel#79
  • Loading branch information
DanielPerkins7 committed Aug 2, 2023
1 parent 86db120 commit 46f0d1a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ssm/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 46f0d1a

Please sign in to comment.