Skip to content

Commit 37b2a3a

Browse files
committed
Improved YAML loading and exception message printing.
1 parent ba20900 commit 37b2a3a

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

lib/ipLookupHelper.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,8 @@ def main(argv):
600600
with open(conf) as f:
601601
try:
602602
config = yaml.load(f, Loader=yaml.FullLoader)
603-
except:
604-
config = yaml.load(f)
603+
except Exception as e:
604+
self.logger.fatal(f'Could not parse {f} YAML file:\n\n{e}\n\n')
605605

606606
deter = IPGeolocationDeterminant(logger, config['ip_geolocation_requirements'])
607607
out = deter.determine(result)

lib/optionsparser.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ def parseParametersFromConfigFile(_params):
239239
with open(outparams['config']) as f:
240240
try:
241241
config = yaml.load(f, Loader=yaml.FullLoader)
242-
except:
243-
config = yaml.load(f)
242+
except Exception as e:
243+
self.logger.fatal(f'Could not parse {f} YAML file:\n\n{e}\n\n')
244244

245245
outparams.update(config)
246246

plugins/malleable_redirector.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,10 @@ def help(self, parser):
506506
try:
507507
if not self.proxyOptions['config'] and self.proxyOptions['redir_config'] != '':
508508
with open(self.proxyOptions['redir_config']) as f:
509-
#redirectorConfig = yaml.load(f, Loader=yaml.FullLoader)
510-
redirectorConfig = yaml.load(f)
509+
try:
510+
redirectorConfig = yaml.load(f, Loader=yaml.FullLoader)
511+
except Exception as e:
512+
self.logger.fatal(f'Could not parse redirector {f} YAML file:\n\n{e}\n\n')
511513

512514
self.proxyOptions.update(redirectorConfig)
513515

0 commit comments

Comments
 (0)