mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-06-03 10:50:20 +00:00
zoph: Don't fail at showing app view during uninstall
During uninstall step, zoph command may not be available and is_configured() may error out. In such cases, let the base class AppView show the operations view. Tests: - Introduce a sleep in overridden uninstall() method for zoph. Notice that there is an error showing the view during uninstall. Apply patch and the error is no longer shown. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
c8a8d4bf33
commit
f30c028289
@ -90,11 +90,15 @@ def set_configuration(enable_osm: Optional[bool] = None,
|
||||
|
||||
|
||||
@privileged
|
||||
def is_configured() -> bool:
|
||||
def is_configured() -> Optional[bool]:
|
||||
"""Return whether zoph app is configured."""
|
||||
process = subprocess.run(['zoph', '--get-config', 'interface.user.remote'],
|
||||
stdout=subprocess.PIPE, check=True)
|
||||
return process.stdout.decode().strip() == 'true'
|
||||
try:
|
||||
process = subprocess.run(
|
||||
['zoph', '--get-config', 'interface.user.remote'],
|
||||
stdout=subprocess.PIPE, check=True)
|
||||
return process.stdout.decode().strip() == 'true'
|
||||
except FileNotFoundError:
|
||||
return None
|
||||
|
||||
|
||||
@privileged
|
||||
|
||||
@ -48,9 +48,12 @@ class ZophAppView(views.AppView):
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
"""Redirect to setup page if setup is not done yet."""
|
||||
if not privileged.is_configured():
|
||||
is_configured = privileged.is_configured()
|
||||
if is_configured is False:
|
||||
return redirect('zoph:setup')
|
||||
|
||||
# During operations such as uninstall, zoph command may not be
|
||||
# available, let the base class show operations view instead.
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_initial(self):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user