| 28 | |
| 29 | |
| 30 | class Schedule(FirstClassObjectInterface, BaseObject): |
| 31 | schema = ScheduleSchema() |
| 32 | |
| 33 | @property |
| 34 | def unique(self): |
| 35 | return self.hash('%s' % self.id) |
| 36 | |
| 37 | def __init__(self, schedule, task, id=''): |
| 38 | super().__init__() |
| 39 | self.id = str(id) if id else str(uuid.uuid4()) |
| 40 | self.schedule = schedule |
| 41 | self.task = task |
| 42 | |
| 43 | def store(self, ram): |
| 44 | existing = self.retrieve(ram['schedules'], self.unique) |
| 45 | if not existing: |
| 46 | ram['schedules'].append(self) |
| 47 | return self.retrieve(ram['schedules'], self.unique) |
| 48 | existing.update('schedule', self.schedule) |
| 49 | existing.task.update('state', self.task.state) |
| 50 | existing.task.update('autonomous', self.task.autonomous) |
| 51 | existing.task.update('obfuscator', self.task.obfuscator) |
| 52 | return existing |
no test coverage detected