1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# Copyright 2010-2011 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Interfaces for using the Jobs system for Apport BLOB processing."""
__metaclass__ = type
__all__ = [
'ApportJobType',
'IApportJob',
'IApportJobSource',
'IProcessApportBlobJob',
'IProcessApportBlobJobSource',
]
from lazr.enum import (
DBEnumeratedType,
DBItem,
)
from zope.interface import (
Attribute,
Interface,
)
from zope.schema import (
Int,
Object,
)
from canonical.launchpad import _
from canonical.launchpad.interfaces.temporaryblobstorage import (
ITemporaryBlobStorage,
)
from lp.services.job.interfaces.job import (
IJob,
IJobSource,
IRunnableJob,
)
class ApportJobType(DBEnumeratedType):
"""Values that IApportJob.job_type can take."""
PROCESS_BLOB = DBItem(0, """
Process a BLOB and extract salient data from it.
This type of job extracts data from a BLOB so that it can be
used in the bug-filing process.
""")
class IApportJob(Interface):
"""A Job related to an Apport BLOB."""
id = Int(
title=_('DB ID'), required=True, readonly=True,
description=_("The tracking number for this job."))
blob = Object(
title=_('The BLOB this job is about'),
schema=ITemporaryBlobStorage, required=True)
job = Object(title=_('The common Job attributes'), schema=IJob,
required=True)
metadata = Attribute('A dict of data about the job.')
class IApportJobSource(IJobSource):
"""An interface for acquiring IApportJobs."""
def create(bug):
"""Create a new IApportJob for a bug."""
def getByBlobUUID(uuid):
"""For a given BLOB UUID, return any jobs pertaining to that BLOB."""
class IProcessApportBlobJob(IRunnableJob):
"""A Job to process an Apport BLOB."""
def getFileBugData():
"""Return the FileBugData parsed out of the blob by this job."""
class IProcessApportBlobJobSource(IApportJobSource):
"""Interface for acquiring ProcessApportBlobJobs."""
|