mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
fix configparser import & log if error was raised
This commit is contained in:
parent
ca1b1bb633
commit
d7f65dc7a7
1 changed files with 11 additions and 2 deletions
|
@ -35,8 +35,10 @@ try:
|
|||
import yum
|
||||
HAS_YUM = True
|
||||
except ImportError:
|
||||
from salt.ext.six.moves import configparser
|
||||
HAS_YUM = False
|
||||
|
||||
from salt.ext.six.moves import configparser
|
||||
|
||||
# pylint: enable=import-error,redefined-builtin
|
||||
|
||||
# Import salt libs
|
||||
|
@ -2525,9 +2527,16 @@ def _parse_repo_file(filename):
|
|||
Turn a single repo file into a dict
|
||||
'''
|
||||
parsed = configparser.ConfigParser()
|
||||
parsed.read(filename)
|
||||
config = {}
|
||||
|
||||
try:
|
||||
parsed.read(filename)
|
||||
except configparser.MissingSectionHeaderError as err:
|
||||
log.error(
|
||||
'Failed to parser file {0}, error: {1}'.format(filename, err.message)
|
||||
)
|
||||
return ('', {})
|
||||
|
||||
for section in parsed._sections:
|
||||
section_dict = dict(parsed._sections[section])
|
||||
section_dict.pop('__name__')
|
||||
|
|
Loading…
Add table
Reference in a new issue