def _serialize(self, include_run_logs=False, strict_json=False):
        """ Serialize a representation of this Task to a Python dict. """

        result = {'command': self.command,
                  'name': self.name,
                  'started_at': self.started_at,
                  'completed_at': self.completed_at,
                  'success': self.successful,
                  'soft_timeout': self.soft_timeout,
                  'hard_timeout': self.hard_timeout,
                  'hostname': self.hostname}

        if include_run_logs:
            last_run = self.backend.get_latest_run_log(self.parent_job.job_id,
                                                       self.name)
            if last_run:
                run_log = last_run.get('tasks', {}).get(self.name, {})
                if run_log:
                    result['run_log'] = run_log

        if strict_json:
            result = json.loads(json.dumps(result, cls=StrictJSONEncoder))
        return result
def _serialize ( self , include_run_logs = False , strict_json = False ) : result = { 'command' : self . command , 'name' : self . name , 'started_at' : self . started_at , 'completed_at' : self . completed_at , 'success' : self . successful , 'soft_timeout' : self . soft_timeout , 'hard_timeout' : self . hard_timeout , 'hostname' : self . hostname } if include_run_logs : last_run = self . backend . get_latest_run_log ( self . parent_job . job_id , self . name ) if last_run : run_log = last_run . get ( 'tasks' , { } ) . get ( self . name , { } ) if run_log : result [ 'run_log' ] = run_log if strict_json : result = json . loads ( json . dumps ( result , cls = StrictJSONEncoder ) ) return result
Serialize a representation of this Task to a Python dict.