|
1 #!/usr/bin/python2.5 |
|
2 # |
|
3 # Copyright 2009 the Melange authors. |
|
4 # |
|
5 # Licensed under the Apache License, Version 2.0 (the "License"); |
|
6 # you may not use this file except in compliance with the License. |
|
7 # You may obtain a copy of the License at |
|
8 # |
|
9 # http://www.apache.org/licenses/LICENSE-2.0 |
|
10 # |
|
11 # Unless required by applicable law or agreed to in writing, software |
|
12 # distributed under the License is distributed on an "AS IS" BASIS, |
|
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 # See the License for the specific language governing permissions and |
|
15 # limitations under the License. |
|
16 |
|
17 """This module contains the Job Model.""" |
|
18 |
|
19 __authors__ = [ |
|
20 '"Sverre Rabbelier" <sverre@rabbelier.nl>', |
|
21 ] |
|
22 |
|
23 |
|
24 from google.appengine.ext import db |
|
25 |
|
26 from django.utils.translation import ugettext |
|
27 |
|
28 from soc.models import base |
|
29 from soc.models import priority_group |
|
30 |
|
31 |
|
32 class Job(base.ModelWithFieldAttributes): |
|
33 """The Job model. |
|
34 """ |
|
35 |
|
36 #: reference to the priority group this job belongs to |
|
37 priority_group = db.ReferenceProperty( |
|
38 reference_class=priority_group.PriorityGroup, required=True, |
|
39 collection_name='jobs') |
|
40 |
|
41 #: the name of the task as defined in soc.cron.job |
|
42 task_name = db.StringProperty(required=True) |
|
43 |
|
44 #: field storing the status of this job |
|
45 #: Waiting means that this job is waiting to be run. |
|
46 #: Started means that this job has a worker that is running it. |
|
47 #: Finished means that this job has been completed. |
|
48 #: Aborted means that this job has been aborted due to a fatal error. |
|
49 status = db.StringProperty(default='waiting', |
|
50 choices=['waiting','started','finished', 'aborted']) |
|
51 |
|
52 #: the date this job was last modified on |
|
53 last_modified_on = db.DateTimeProperty(auto_now_add=True) |
|
54 |
|
55 #: the amount of times this job raised an Exception (other than an |
|
56 #: DeadlineExceededException). |
|
57 errors = db.IntegerProperty(default=0) |
|
58 |
|
59 #: the data that the worker will use to process this job |
|
60 text_data = db.TextProperty(required=False, default="") |
|
61 |
|
62 #: the data that the worker will use to process this job |
|
63 key_data = db.ListProperty(db.Key, default=[]) |