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:
Sunil Mohan Adapa 2023-04-28 15:09:51 -07:00 committed by James Valleroy
parent c8a8d4bf33
commit f30c028289
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 12 additions and 5 deletions

View File

@ -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

View File

@ -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):