edf-hpc / clara

Cluster Administration tools
Other
18 stars 12 forks source link

Errors when a value is not in config file #10

Closed fmdm closed 10 years ago

fmdm commented 10 years ago

When a value isn't specified in the config file, clara retuens exeptions like this :

BB03654S@clausn24:~$ clara repo key Traceback (most recent call last): File "/usr/bin/clara", line 68, in m.main() File "/usr/lib/python2.7/dist-packages/clara/plugins/clara_repo.py", line 174, in main do_key() File "/usr/lib/python2.7/dist-packages/clara/plugins/clara_repo.py", line 65, in do_key cmd = ['gpg', '--list-secret-keys', get_from_config("repo", "gpg_key")] File "/usr/lib/python2.7/dist-packages/clara/utils.py", line 68, in get_from_config return getconfig().get(section, value) File "/usr/lib/python2.7/ConfigParser.py", line 618, in get raise NoOptionError(option, section) ConfigParser.NoOptionError: No option 'gpg_key' in section: 'repo'

This patch should resolve the problem : commit 9ec75f2b747acc66fdc1ef1296c6e8eee868dc79 Author: BB03654S BB03654S@clausn24.postes.calibre.edf.fr Date: Fri Sep 5 16:48:18 2014 +0200

Correct behavior when value nor found in config file

diff --git a/clara/utils.py b/clara/utils.py index db8f202..28ff673 100644 --- a/clara/utils.py +++ b/clara/utils.py @@ -65,20 +65,23 @@ def run(cmd): def get_from_config(section, value, dist=''): """ Read a value from config.ini and return it""" if dist == '':

- return getconfig().get(section, value)