Skip to content

Commit

Permalink
fix: missing method self._initstatus() in task.refresh()
Browse files Browse the repository at this point in the history
  • Loading branch information
plaffitt authored and lperdereau committed Dec 2, 2024
1 parent c65104f commit a730fc4
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/pvecontrol/task.py
Original file line number Diff line number Diff line change
@@ -27,7 +27,22 @@ def __init__(self, api, upid):
self.starttime = task["starttime"]
self.type = task["type"]
self.user = task["user"]
self.runningstatus = TaskRunningStatus["vanished"]
self.endtime = 0
self.exitstatus = "UNK"

self.refresh()

def log(self, limit = 0, start = 0):
return(self._api.nodes(self.node).tasks(self.upid).log.get(limit=limit, start=start))

def running(self):
return(self.runningstatus == TaskRunningStatus.running)

def vanished(self):
return(self.runningstatus == TaskRunningStatus.vanished)

def refresh(self):
# This is bugguy. replace with a catch / except ?
# if self.node != NodeStatus.online:
# return
@@ -36,26 +51,12 @@ def __init__(self, api, upid):
# Some task information can be vanished over time (tasks status files removed from the node filesystem)
# In this case API return an error and we consider this tasks vanished and don't get more informations
except proxmoxer.core.ResourceException:
self.runningstatus = TaskRunningStatus["vanished"]
self.endtime = 0
self.exitstatus = "UNK"
pass
else:
self.runningstatus = TaskRunningStatus[status.get("status", "stopped")]
self.endtime = status.get("endtime", 0)
self.exitstatus = status.get("exitstatus", "")

def log(self, limit = 0, start = 0):
return(self._api.nodes(self.node).tasks(self.upid).log.get(limit=limit, start=start))

def running(self):
return(self.runningstatus == TaskRunningStatus.running)

def vanished(self):
return(self.runningstatus == TaskRunningStatus.vanished)

def refresh(self):
self._initstatus()

def decode_log(self, limit = 0, start = 0):
log = self.log(limit, start)
return(Tasks.decode_log(log))

0 comments on commit a730fc4

Please sign in to comment.