mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
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:
parent
e401a5a028
commit
65a1985cc0
@ -235,6 +235,7 @@ def _enable_hs(restart=True):
|
|||||||
tries += 1
|
tries += 1
|
||||||
if tries >= 12:
|
if tries >= 12:
|
||||||
return
|
return
|
||||||
|
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
|
||||||
|
|
||||||
@ -325,6 +326,7 @@ def _update_ports():
|
|||||||
tries += 1
|
tries += 1
|
||||||
if tries >= 12:
|
if tries >= 12:
|
||||||
return
|
return
|
||||||
|
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
|
||||||
lines = """<?xml version="1.0" encoding="utf-8"?>
|
lines = """<?xml version="1.0" encoding="utf-8"?>
|
||||||
@ -340,6 +342,8 @@ def _update_ports():
|
|||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# XXX: We should ideally do firewalld reload instead. However,
|
||||||
|
# firewalld seems to fail to successfully reload sometimes.
|
||||||
action_utils.service_restart('firewalld')
|
action_utils.service_restart('firewalld')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -82,6 +82,11 @@ def _apply_changes(request, old_status, new_status):
|
|||||||
|
|
||||||
def __apply_changes(request, old_status, new_status):
|
def __apply_changes(request, old_status, new_status):
|
||||||
"""Apply the changes."""
|
"""Apply the changes."""
|
||||||
|
global config_process
|
||||||
|
if config_process:
|
||||||
|
# Already running a configuration task
|
||||||
|
return
|
||||||
|
|
||||||
arguments = []
|
arguments = []
|
||||||
|
|
||||||
if old_status['enabled'] != new_status['enabled']:
|
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])
|
arguments.extend(['--apt-transport-tor', arg_value])
|
||||||
|
|
||||||
if arguments:
|
if arguments:
|
||||||
global config_process
|
config_process = actions.superuser_run(
|
||||||
if not config_process:
|
'tor', ['configure'] + arguments, async=True)
|
||||||
config_process = actions.superuser_run(
|
|
||||||
'tor', ['configure'] + arguments, async=True)
|
|
||||||
else:
|
else:
|
||||||
messages.info(request, _('Setting unchanged'))
|
messages.info(request, _('Setting unchanged'))
|
||||||
|
|
||||||
@ -144,6 +147,6 @@ def _collect_config_result(request):
|
|||||||
if not return_code:
|
if not return_code:
|
||||||
messages.success(request, _('Configuration updated.'))
|
messages.success(request, _('Configuration updated.'))
|
||||||
else:
|
else:
|
||||||
messages.info(request, _('Error occurred during configuration.'))
|
messages.error(request, _('An error occurred during configuration.'))
|
||||||
|
|
||||||
config_process = None
|
config_process = None
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user