lemonrule bugfix

This commit is contained in:
Kload 2013-10-10 13:19:26 +02:00
parent e06fc6554f
commit 0a5eafc16d

View file

@ -339,15 +339,17 @@ def tools_lemonrule(id=None, url=None, key=None, value=None, priority=None, dele
for level in key: for level in key:
line = line +"->{'"+ level +"'}" line = line +"->{'"+ level +"'}"
# Append value if line != '$tmp':
if value is None: conf_lines.append(line +';') if value is None:
elif isinstance(value, int): conf_lines.append(line +' = '+ str(value) +';') line = line +';'
else: conf_lines.append(line +' = \''+ value +'\';') elif isinstance(value, int):
line = line +' = '+ str(value) +';'
else:
line = line +' = \''+ value +'\';'
# Write configuration # Write configuration
with open(lemon_tmp_conf,'a+') as lemon_conf: with open(lemon_tmp_conf,'a+') as lemon_conf:
for conf_line in conf_lines: lemon_conf.write(line + '\n')
lemon_conf.write(conf_line + '\n')
# Apply & reload configuration # Apply & reload configuration
if apply: if apply:
@ -358,6 +360,6 @@ def tools_lemonrule(id=None, url=None, key=None, value=None, priority=None, dele
else: else:
raise YunoHostError(1, _("An error occured during LemonLDAP configuration")) raise YunoHostError(1, _("An error occured during LemonLDAP configuration"))
os.system("echo '' > lemon_tmp_conf") os.system("echo '' > "+ lemon_tmp_conf)