Try a literal eval first

This is a breakage between the older version of Celery (Deb10) and
newer. The hard removal broke Deb10 instances.

So try that first, and on failure, assume newer Celery format.
This commit is contained in:
Joshua Boniface 2022-09-06 10:34:50 -04:00
parent 239c392892
commit 096bcdfd75
1 changed files with 9 additions and 2 deletions

View File

@ -26,6 +26,7 @@ from requests_toolbelt.multipart.encoder import (
import pvc.cli_lib.ansiprint as ansiprint import pvc.cli_lib.ansiprint as ansiprint
from pvc.cli_lib.common import UploadProgressBar, call_api from pvc.cli_lib.common import UploadProgressBar, call_api
from ast import literal_eval
# #
@ -792,9 +793,15 @@ def task_status(config, task_id=None, is_watching=False):
task["type"] = task_type task["type"] = task_type
task["worker"] = task_host task["worker"] = task_host
task["id"] = task_job.get("id") task["id"] = task_job.get("id")
try:
task_args = literal_eval(task_job.get("args"))
except Exception:
task_args = task_job.get("args") task_args = task_job.get("args")
task["vm_name"] = task_args[0] task["vm_name"] = task_args[0]
task["vm_profile"] = task_args[1] task["vm_profile"] = task_args[1]
try:
task_kwargs = literal_eval(task_job.get("kwargs"))
except Exception:
task_kwargs = task_job.get("kwargs") task_kwargs = task_job.get("kwargs")
task["vm_define"] = str(bool(task_kwargs["define_vm"])) task["vm_define"] = str(bool(task_kwargs["define_vm"]))
task["vm_start"] = str(bool(task_kwargs["start_vm"])) task["vm_start"] = str(bool(task_kwargs["start_vm"]))