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)
try:
return getconfig().get(section, value)
except:
sys.exit("E: Value '%s' not found in section '%s'" % (value,section))
elif dist in getconfig().get("common", "distributions"):
or_section = section+"-"+dist
Check if override section exist, if not read the value from base section
if getconfig().has_section(or_section):
If the value is not in the override section, return the base value
if getconfig().has_option(or_section, value):
If the value is not in the override section, return the base value
if getconfig().has_option(or_section, value):
try:
return getconfig().get(or_section, value)
else:
return getconfig().get(section, value)
except:
sys.exit("E: Value '%s' not found in section '%s'" % (value,section))
else:
try:
return getconfig().get(section, value)
except:
sys.exit("E: Value '%s' not found in section '%s'" % (value,section))
else:
sys.exit("{0} is not a know distribution".format(dist))
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
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)
Check if override section exist, if not read the value from base section
If the value is not in the override section, return the base value
If the value is not in the override section, return the base value
try: return getconfig().get(section, value)