tor: Minor fixes and styling

- Add note about resetarting firewalld.

- Refactor checking for running configuration process.

- Fix error message being show as info message.

- Minor indentation fixes.
This commit is contained in:
Sunil Mohan Adapa 2016-01-30 19:41:13 +05:30
parent e401a5a028
commit 65a1985cc0
No known key found for this signature in database
GPG Key ID: 36C361440C9BC971
2 changed files with 12 additions and 5 deletions

View File

@ -235,6 +235,7 @@ def _enable_hs(restart=True):
tries += 1
if tries >= 12:
return
time.sleep(10)
@ -325,6 +326,7 @@ def _update_ports():
tries += 1
if tries >= 12:
return
time.sleep(10)
lines = """<?xml version="1.0" encoding="utf-8"?>
@ -340,6 +342,8 @@ def _update_ports():
except FileNotFoundError:
return
# XXX: We should ideally do firewalld reload instead. However,
# firewalld seems to fail to successfully reload sometimes.
action_utils.service_restart('firewalld')

View File

@ -82,6 +82,11 @@ def _apply_changes(request, old_status, new_status):
def __apply_changes(request, old_status, new_status):
"""Apply the changes."""
global config_process
if config_process:
# Already running a configuration task
return
arguments = []
if old_status['enabled'] != new_status['enabled']:
@ -100,10 +105,8 @@ def __apply_changes(request, old_status, new_status):
arguments.extend(['--apt-transport-tor', arg_value])
if arguments:
global config_process
if not config_process:
config_process = actions.superuser_run(
'tor', ['configure'] + arguments, async=True)
config_process = actions.superuser_run(
'tor', ['configure'] + arguments, async=True)
else:
messages.info(request, _('Setting unchanged'))
@ -144,6 +147,6 @@ def _collect_config_result(request):
if not return_code:
messages.success(request, _('Configuration updated.'))
else:
messages.info(request, _('Error occurred during configuration.'))
messages.error(request, _('An error occurred during configuration.'))
config_process = None