Development
This commit is contained in:
parent
b99ea35f79
commit
5149e5a035
10 changed files with 197 additions and 213 deletions
|
|
@ -232,29 +232,30 @@ def queue_command(cmd, description=''):
|
|||
return _queue_command(cmd, description)
|
||||
|
||||
|
||||
def queued_msg(cmd=None, description=''):
|
||||
def queued_msg(cmd=None, description='', action_label='Configuration saved'):
|
||||
"""Queue cmd if given, then return a timing message.
|
||||
Without cmd, just returns timing (for commands already queued by the caller)."""
|
||||
Without cmd, just returns timing (for commands already queued by the caller).
|
||||
action_label replaces the 'Configuration saved' prefix for non-save actions."""
|
||||
entry_ts = None
|
||||
if cmd is not None:
|
||||
_entry_uuid, entry_ts = queue_command(cmd, description)
|
||||
if not _apply_on_save():
|
||||
return 'Configuration saved. Click Apply Now on the Configuration Changes card to apply.'
|
||||
return f'{action_label}. Click Apply Now on the Configuration Changes card to apply.'
|
||||
if _is_locked():
|
||||
mtime = _lock_mtime()
|
||||
if entry_ts is not None and mtime and entry_ts < mtime:
|
||||
return 'Configuration saved. Changes are being applied now.'
|
||||
return 'Configuration saved. Changes will be applied on the next run.'
|
||||
return f'{action_label}. Changes are being applied now.'
|
||||
return f'{action_label}. Changes will be applied on the next run.'
|
||||
timing = _format_timing(_seconds_until_next_run())
|
||||
if timing:
|
||||
return f'Configuration saved. Changes will be applied {timing}.'
|
||||
return f'{action_label}. Changes will be applied {timing}.'
|
||||
if cmd is None:
|
||||
return 'Changes queued. The processing service is not running.'
|
||||
return f'{action_label}. The processing service is not running.'
|
||||
parts = cmd.split()
|
||||
cli_cmd = f'sudo python3 {parts[0]}.py --{parts[1]}' if len(parts) == 2 else cmd
|
||||
install_cmd = f'sudo python3 install.py'
|
||||
from markupsafe import Markup
|
||||
return Markup(f'Configuration saved. The command processing service is not installed. '
|
||||
return Markup(f'{action_label}. The command processing service is not installed. '
|
||||
f'Run <strong>{install_cmd}</strong> to enable it, '
|
||||
f'or <strong>{cli_cmd}</strong> to apply manually.')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue