diff --git a/eoptasks.py b/eoptasks.py index 19ec628..ee4562c 100755 --- a/eoptasks.py +++ b/eoptasks.py @@ -59,10 +59,15 @@ class Server: return '' % (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')