Source code for beat.web.backend.models.result

#!/usr/bin/env python
# vim: set fileencoding=utf-8 :

###############################################################################
#                                                                             #
# Copyright (c) 2016 Idiap Research Institute, http://www.idiap.ch/           #
# Contact: beat.support@idiap.ch                                              #
#                                                                             #
# This file is part of the beat.web module of the BEAT platform.              #
#                                                                             #
# Commercial License Usage                                                    #
# Licensees holding valid commercial BEAT licenses may use this file in       #
# accordance with the terms contained in a written agreement between you      #
# and Idiap. For further information contact tto@idiap.ch                     #
#                                                                             #
# Alternatively, this file may be used under the terms of the GNU Affero      #
# Public License version 3 as published by the Free Software and appearing    #
# in the file LICENSE.AGPL included in the packaging of this file.            #
# The BEAT platform is distributed in the hope that it will be useful, but    #
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY  #
# or FITNESS FOR A PARTICULAR PURPOSE.                                        #
#                                                                             #
# You should have received a copy of the GNU Affero Public License along      #
# with the BEAT platform. If not, see http://www.gnu.org/licenses/.           #
#                                                                             #
###############################################################################


from django.db import models

import simplejson

import beat.core.stats



[docs]class Result(models.Model): '''Logging and status information concerning block or job execution. ''' # exit status code status = models.IntegerField() stdout = models.TextField(null=True, blank=True) stderr = models.TextField(null=True, blank=True) usrerr = models.TextField(null=True, blank=True) _stats = models.TextField(null=True, blank=True) timed_out = models.BooleanField(default=False) cancelled = models.BooleanField(default=False) def __str__(self): status = 'success' if self.status == 0 else 'failed' retval = 'Result(%s' % status if self.stdout: retval += ', stdout=' + self.stdout if self.stderr: retval += ', stderr=' + self.stderr if self.usrerr: retval += ', usrerr=' + self.usrerr retval += ')' return retval def _get_stats(self): if self._stats is not None: return beat.core.stats.Statistics(simplejson.loads(self._stats)) else: return beat.core.stats.Statistics() def _set_stats(self, v): self._stats = simplejson.dumps(v.as_dict()) stats = property(_get_stats, _set_stats)