2
0
mirror of https://github.com/frappe/bench.git synced 2024-09-24 13:09:01 +00:00

fix: add confirmation for supervisord conf update

This commit is contained in:
Gavin D'souza 2020-06-10 18:22:15 +05:30
parent c43da5be68
commit deb854b9d9

View File

@ -76,7 +76,7 @@ def update_supervisord_config(user=None, yes=False):
"chmod": "0760", "chmod": "0760",
"chown": "{user}:{user}".format(user=user) "chown": "{user}:{user}".format(user=user)
} }
supervisord_conf_updated = False supervisord_conf_changes = ""
if not supervisord_conf: if not supervisord_conf:
return return
@ -86,18 +86,24 @@ def update_supervisord_config(user=None, yes=False):
if section not in config.sections(): if section not in config.sections():
config.add_section(section) config.add_section(section)
supervisord_conf_updated = True action = "Section {0} Added".format(section)
logger.log(action)
supervisord_conf_changes += '\n' + action
for key, value in updated_values.items(): for key, value in updated_values.items():
current_value = config[section].get(key, "") current_value = config[section].get(key, "")
if current_value.strip() != value: if current_value.strip() != value:
config.set(section, key, value) config.set(section, key, value)
supervisord_conf_updated = True action = "Updated supervisord config: '{0}' changed from '{1}' to '{2}'".format(key, current_value, value)
logger.log("Updated supervisord config: '{0}' changed from '{1}' to '{2}'".format(key, current_value, value)) logger.log(action)
supervisord_conf_changes += '\n' + action
if not supervisord_conf_updated: if not supervisord_conf_changes:
return return
if not yes:
click.confirm("{0} will be updated with the following values:\n{1}\nDo you want to continue?".format(supervisord_conf, supervisord_conf_changes), abort=True)
try: try:
with open(supervisord_conf, "w") as f: with open(supervisord_conf, "w") as f:
config.write(f) config.write(f)