1 from couchdbkit
.ext
.django
.schema
import *
4 class CommandRunStatus(DocumentSchema
):
5 """ Status of a single Command run """
7 timestamp_started
= DateTimeProperty()
8 timestamp_finished
= DateTimeProperty()
9 error_msg
= StringProperty()
10 start_seq
= IntegerProperty()
11 end_seq
= IntegerProperty()
12 status_counter
= DictProperty()
15 return '<%(cls)s %(start_seq)d - %(end_seq)d>' % \
16 dict(cls
=self
.__class
__.__name
__, start_seq
=self
.start_seq
,
20 class CommandStatus(Document
):
21 """ Contains status info for several runs of a command """
23 command
= StringProperty()
24 runs
= SchemaListProperty(CommandRunStatus
)
29 runs
= filter(lambda r
: r
.end_seq
, self
.runs
)
30 return runs
[-1].end_seq
if runs
else 0
34 return '<%(cls)s %(cmd)s %(num_runs)d>' % \
35 dict(cls
=self
.__class
__.__name
__, cmd
=self
.command
,
36 num_runs
=len(self
.runs
))