Beispiel #1
0
    def list(self, from_timestap=None, to_timestap=None):
        """
        list all task. Optionally filter on time of creation
        from_timestamp: filter all task created before from_timetamp
        to_timestamp: filter all task created after to_timestamp
        """
        stmt = _find_task_stmt
        args = None
        if from_timestap and not to_timestap:
            stmt += ' WHERE created >= ? '
            args = (from_timestap, )
        elif to_timestap and not from_timestap:
            stmt += ' WHERE created <= ? '
            args = (to_timestap, )
        elif from_timestap and to_timestap:
            stmt += ' WHERE created >= ? AND created <= ?'
            args = (from_timestap, to_timestap)

        if args:
            self._cursor.execute(stmt, args)
        else:
            self._cursor.execute(stmt)

        tasks = []
        for result in self._cursor.fetchall():
            task = self._deserialize_task(result[2])
            task['guid'] = result[0]
            task = _instantiate_task(task, self.service)
            tasks.append(task)
        return tasks
Beispiel #2
0
 def get(self, guid):
     """
     find a task by guid
     """
     stmt = _find_task_stmt + ' WHERE guid=?'
     self._cursor.execute(stmt, (guid, ))
     result = self._cursor.fetchone()
     if not result:
         raise TaskNotFoundError("task %s not found" % guid)
     task = self._deserialize_task(result[2])
     task['guid'] = guid
     task = _instantiate_task(task, self.service)
     return task
Beispiel #3
0
 def _deserialize_task(self, blob):
     task = j.data.serializer.json.loads(blob)
     return _instantiate_task(task, self._service)
Beispiel #4
0
def deserialize_task(blob, service):
    task = j.data.serializer.json.loads(blob)
    return _instantiate_task(task, service)