factor reading of configuration file
This commit is contained in:
parent
e445ebc24e
commit
1ddfe568f9
12
eoptasks.py
12
eoptasks.py
|
@ -59,10 +59,15 @@ class Server:
|
|||
return '<Server %s %r>' % (self.name, self.keywords)
|
||||
|
||||
|
||||
def get_servers():
|
||||
servers = []
|
||||
def get_config():
|
||||
config = configparser.ConfigParser()
|
||||
config.read(os.path.join(os.path.expanduser('~/.config/eoptasks.ini')))
|
||||
return config
|
||||
|
||||
|
||||
def get_servers():
|
||||
servers = []
|
||||
config = get_config()
|
||||
serversfile = config.get('config', 'servers', fallback=None)
|
||||
if serversfile is None:
|
||||
print(
|
||||
|
@ -244,8 +249,7 @@ def get_commands():
|
|||
# puppet.update, unfortunately without proper error checking.
|
||||
'puppet.update': '''sudo puppet agent -t || true''',
|
||||
}
|
||||
config = configparser.ConfigParser()
|
||||
config.read(os.path.join(os.path.expanduser('~/.config/eoptasks.ini')))
|
||||
config = get_config()
|
||||
for section in config.sections():
|
||||
if section.startswith('command:'):
|
||||
commands[section[len('command:') :]] = config.get(section, 'cmd')
|
||||
|
|
Loading…
Reference in New Issue