From 477d056768eb61b38f5236a8a2fdf4ff43b71fd0 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Wed, 19 Feb 2020 15:56:07 -0600 Subject: snmp: T1769: fix indentation error and add try clause --- src/conf_mode/snmp.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/conf_mode/snmp.py') diff --git a/src/conf_mode/snmp.py b/src/conf_mode/snmp.py index 7cffa5e04..ac94afb1a 100755 --- a/src/conf_mode/snmp.py +++ b/src/conf_mode/snmp.py @@ -710,18 +710,20 @@ def apply(snmp): # Passwords are not available immediately in the configuration file, # after daemon startup - we wait until they have been processed by # snmpd, which we see when a magic line appears in this file. - ready = False - while not ready: + while True: while not os.path.exists(config_file_user): sleep(0.5) - ready = True - with open(config_file_user, 'r') as f: - for line in f: - # Search for our magic string inside the file - if 'usmUser' in line: - ready = True - break + try: + with open(config_file_user, 'r') as f: + for line in f: + # Search for our magic string inside the file + if 'usmUser' in line: + break + except IOError: + continue + else: + break # net-snmp is now regenerating the configuration file in the background # thus we need to re-open and re-read the file as the content changed. -- cgit v1.2.3