from . import serializable
from . import task
class Job(serializable.Serializable):
STATUS_PENDING = 'pending'
STATUS_WORKING = 'working'
STATUS_COMPLETE = 'complete'
STATUS_FAILED = 'failed'
STATUS_PAUSED = 'paused'
def __init__(self):
self.status = Job.STATUS_PENDING
self.tasks = []
self.working_tasks = []
def unserialize(self, data):
super().unserialize(data)
self.tasks = []
for task_serialized in data['tasks']:
self.tasks.append(task.Task(self).unserialize(task_serialized))
return self
def serialize(self):
out = super().serialize()
out['tasks'] = []
for task_object in self.tasks:
out['tasks'].tasks.append(task_object.serialize())
return out