source: server/lib/gutenbach/ipp/object_attributes/job_description_attributes.py @ b828a96

no-cups
Last change on this file since b828a96 was b828a96, checked in by Jessica B. Hamrick <jhamrick@…>, 12 years ago

Use classes for standard IPP attributes

  • Property mode set to 100644
File size: 15.4 KB
Line 
1__all__ = [
2    'JobUri',
3    'JobId',
4    'JobPrinterUri',
5    'JobMoreInfo',
6    'JobName',
7    'JobOriginatingUserName',
8    'JobState',
9    'JobStateReasons',
10    'JobStateMessage',
11    'JobDetailedStatusMessages',
12    'JobDocumentAccessErrors',
13    'NumberOfDocuments',
14    'OutputDeviceAssigned',
15    'TimeAtCreation',
16    'TimeAtProcessing',
17    'TimeAtCompleted',
18    'JobPrinterUpTime',
19    'DateTimeAtCreation',
20    'DateTimeAtProcessing',
21    'DateTimeAtCompletion',
22    'NumberOfInterveningJobs',
23    'JobMessageFromOperator',
24    'JobKOctets',
25    'JobImpressions',
26    'JobMediaSheets',
27    'JobKOctetsProcessed',
28    'JobImpressionsCompleted',
29    'JobMediaSheetsCompleted',
30    'AttributesCharset',
31    'AttributesNaturalLanguage',
32]
33
34from ..attribute import Attribute
35from ..value import Value
36from ..exceptions import ClientErrorAttributes
37from ..constants import *
38
39def JobUri(val):
40    """4.3.1 job-uri (uri)
41
42    This REQUIRED attribute contains the URI for the job. The Printer
43    object, on receipt of a new job, generates a URI which identifies the
44    new Job. The Printer object returns the value of the 'job-uri'
45    attribute as part of the response to a create request. The precise
46    format of a Job URI is implementation dependent. If the Printer
47    object supports more than one URI and there is some relationship
48    between the newly formed Job URI and the Printer object's URI, the
49    Printer object uses the Printer URI supplied by the client in the
50    create request. For example, if the create request comes in over a
51    secure channel, the new Job URI MUST use the same secure channel.
52    This can be guaranteed because the Printer object is responsible for
53    generating the Job URI and the Printer object is aware of its
54    security configuration and policy as well as the Printer URI used in
55    the create request.
56
57    For a description of this attribute and its relationship to 'job-id'
58    and 'job-printer-uri' attribute, see the discussion in section 2.4 on
59    'Object Identity'.
60
61    """
62
63    return Attribute(
64        'job-uri',
65        [Value(CharacterStringTags.URI, val)])
66
67def JobId(val):
68    """4.3.2 job-id (integer(1:MAX))
69
70    This REQUIRED attribute contains the ID of the job. The Printer,
71    on receipt of a new job, generates an ID which identifies the new
72    Job on that Printer. The Printer returns the value of the 'job-id'
73    attribute as part of the response to a create request. The 0 value
74    is not included to allow for compatibility with SNMP index values
75    which also cannot be 0.
76
77    For a description of this attribute and its relationship to
78    'job-uri' and 'job-printer-uri' attribute, see the discussion in
79    section 2.4 on 'Object Identity'.
80
81    """
82   
83    return Attribute(
84        'job-id',
85        [Value(IntegerTags.INTEGER, val)])
86
87def JobPrinterUri(val):
88    """4.3.3 job-printer-uri (uri)
89
90    This REQUIRED attribute identifies the Printer object that created
91    this Job object. When a Printer object creates a Job object, it
92    populates this attribute with the Printer object URI that was used
93    in the create request. This attribute permits a client to identify
94    the Printer object that created this Job object when only the Job
95    object's URI is available to the client. The client queries the
96    creating Printer object to determine which languages, charsets,
97    operations, are supported for this Job.
98
99    For a description of this attribute and its relationship to
100    'job-uri' and 'job-id' attribute, see the discussion in section
101    2.4 on 'Object Identity'.
102
103    """
104
105    return Attribute(
106        'job-printer-uri',
107        [Value(CharacterStringTags.URI, val)])
108
109def JobMoreInfo(val):
110    """4.3.4 job-more-info (uri)
111
112    """
113
114    raise ClientErrorAttributes, "job-more-info"
115
116def JobName(val):
117    """4.3.5 job-name (name(MAX))
118   
119    This REQUIRED attribute is the name of the job. It is a name that
120    is more user friendly than the 'job-uri' attribute value. It does
121    not need to be unique between Jobs. The Job's 'job-name' attribute
122    is set to the value supplied by the client in the 'job-name'
123    operation attribute in the create request (see Section 3.2.1.1).
124    If, however, the 'job-name' operation attribute is not supplied by
125    the client in the create request, the Printer object, on creation
126    of the Job, MUST generate a name. The printer SHOULD generate the
127    value of the Job's 'job-name' attribute from the first of the
128    following sources that produces a value: 1) the 'document-name'
129    operation attribute of the first (or only) document, 2) the
130    'document-URI' attribute of the first (or only) document, or 3)
131    any other piece of Job specific and/or Document Content
132    information.
133
134    """
135   
136    return Attribute(
137        'job-name',
138        [Value(CharacterStringTags.NAME_WITHOUT_LANGUAGE, val)])
139
140def JobOriginatingUserName(val):
141    """4.3.6 job-originating-user-name (name(MAX))
142
143    This REQUIRED attribute contains the name of the end user that
144    submitted the print job. The Printer object sets this attribute to
145    the most authenticated printable name that it can obtain from the
146    authentication service over which the IPP operation was received.
147    Only if such is not available, does the Printer object use the
148    value supplied by the client in the 'requesting-user-name'
149    operation attribute of the create operation (see Sections 4.4.2,
150    4.4.3, and 8).  Note: The Printer object needs to keep an internal
151    originating user id of some form, typically as a credential of a
152    principal, with the Job object. Since such an internal attribute
153    is implementation- dependent and not of interest to clients, it is
154    not specified as a Job Description attribute. This originating
155    user id is used for authorization checks (if any) on all
156    subsequent operations.
157
158    """
159   
160    return Attribute(
161        'job-originating-user-name',
162        [Value(CharacterStringTags.NAME_WITHOUT_LANGUAGE, val)])
163
164def JobState(val):
165    """4.3.7 job-state (type1 enum)
166
167    This REQUIRED attribute identifies the current state of the job.
168    Even though the IPP protocol defines seven values for job states
169    (plus the out-of-band 'unknown' value - see Section 4.1),
170    implementations only need to support those states which are
171    appropriate for the particular implementation. In other words, a
172    Printer supports only those job states implemented by the output
173    device and available to the Printer object implementation.
174   
175    """
176   
177    return Attribute(
178        'job-state',
179        [Value(IntegerTags.ENUM, val)])
180
181def JobStateReasons(val):
182    """4.3.8 job-state-reasons (1setOf type2 keyword)
183
184    This REQUIRED attribute provides additional information about the
185    job's current state, i.e., information that augments the value of
186    the job's 'job-state' attribute.
187
188    These values MAY be used with any job state or states for which
189    the reason makes sense. Some of these value definitions indicate
190    conformance requirements; the rest are OPTIONAL. Furthermore, when
191    implemented, the Printer MUST return these values when the reason
192    applies and MUST NOT return them when the reason no longer applies
193    whether the value of the Job's 'job-state' attribute changed or
194    not.  When the Job does not have any reasons for being in its
195    current state, the value of the Job's 'job-state-reasons'
196    attribute MUST be 'none'.
197
198    Note: While values cannot be added to the 'job-state' attribute
199    without impacting deployed clients that take actions upon
200    receiving 'job-state' values, it is the intent that additional
201    'job-state- reasons' values can be defined and registered without
202    impacting such deployed clients. In other words, the
203    'job-state-reasons' attribute is intended to be extensible.
204
205    """
206
207    return Attribute(
208        'job-state-reasons',
209        [Value(CharacterStringTags.KEYWORD, val) for val in vals])
210
211def JobStateMessage(val):
212    """4.3.9 job-state-message (text(MAX))
213
214    """
215
216    raise ClientErrorAttributes, "job-state-message"
217
218def JobDetailedStatusMessages(val):
219    """4.3.10 job-detailed-status-messages (1setOf text(MAX))
220
221    """
222
223    raise ClientErrorAttributes, "job-detailed-status-messages"
224
225def JobDocumentAccessErrors(val):
226    """4.3.11 job-document-access-errors (1setOf text(MAX))
227
228    """
229
230    raise ClientErrorAttributes, "job-document-access-errors"
231
232def NumberOfDocuments(val):
233    """4.3.12 number-of-documents (integer(0:MAX))
234
235    """
236
237    raise ClientErrorAttributes, "number-of-documents"
238
239def OutputDeviceAssigned(val):
240    """4.3.13 output-device-assigned (name(127))
241
242    """
243
244    raise ClientErrorAttributes, "output-device-assigned"
245
246def TimeAtCreation(val):
247    """4.3.14.1 time-at-creation (integer(MIN:MAX))
248
249    This REQUIRED attribute indicates the time at which the Job object
250    was created.
251
252    """
253   
254    return Attribute(
255        "time-at-creation",
256        [Value(IntegerTags.INTEGER, val)])
257
258def TimeAtProcessing(val):
259    """4.3.14.2 time-at-processing (integer(MIN:MAX))
260
261    This REQUIRED attribute indicates the time at which the Job object
262    first began processing after the create operation or the most
263    recent Restart-Job operation. The out-of-band 'no-value' value is
264    returned if the job has not yet been in the 'processing' state
265    (see the beginning of Section 4.1).
266
267    """
268
269    return Attribute(
270        "time-at-processing",
271        [Value(IntegerTags.INTEGER, val)])
272
273def TimeAtCompleted(val):
274    """4.3.14.3 time-at-completed (integer(MIN:MAX))
275
276    This REQUIRED attribute indicates the time at which the Job object
277    completed (or was canceled or aborted). The out-of-band 'no-value'
278    value is returned if the job has not yet completed, been canceled,
279    or aborted (see the beginning of Section 4.1).
280
281    """
282
283    return Attribute(
284        "time-at-completed",
285        [Value(IntegerTags.INTEGER, val)])
286
287def JobPrinterUpTime(val):
288    """4.3.14.4 job-printer-up-time (integer(1:MAX))
289
290    This REQUIRED Job Description attribute indicates the amount of
291    time (in seconds) that the Printer implementation has been up and
292    running.  This attribute is an alias for the 'printer-up-time'
293    Printer Description attribute (see Section 4.4.29).
294
295    A client MAY request this attribute in a Get-Job-Attributes or
296    Get- Jobs request and use the value returned in combination with
297    other requested Event Time Job Description Attributes in order to
298    display time attributes to a user. The difference between this
299    attribute and the 'integer' value of a 'time-at-xxx' attribute is
300    the number of seconds ago that the 'time-at-xxx' event occurred. A
301    client can compute the wall-clock time at which the 'time-at-xxx'
302    event occurred by subtracting this difference from the client's
303    wall-clock time.
304   
305    """
306
307    return Attribute(
308        "job-printer-up-time",
309        [Value(IntegerTags.INTEGER, val)])
310
311
312def DateTimeAtCreation(val):
313    """4.3.14.5 date-time-at-creation (dateTime)
314
315    """
316
317    raise ClientErrorAttributes, "date-time-at-creation"
318
319def DateTimeAtProcessing(val):
320    """4.3.14.6 date-time-at-processing (dateTime)
321
322    """
323
324    raise ClientErrorAttributes, "date-time-at-processing"
325
326def DateTimeAtCompletion(val):
327    """4.3.14.7 date-time-at-completed (dateTime)
328
329    """
330
331    raise ClientErrorAttributes, "date-time-at-completion"
332
333def NumberOfInterveningJobs(val):
334    """4.3.15 number-of-intervening-jobs (integer(0:MAX))
335
336    """
337
338    raise ClientErrorAttributes, "number-of-intervening-jobs"
339
340def JobMessageFromOperator(val):
341    """4.3.16 job-message-from-operator (text(127))
342
343    """
344
345    raise ClientErrorAttributes, "job-message-from-operator"
346
347def JobKOctets(val):
348    """4.3.17.1 job-k-octets (integer(0:MAX))
349
350    This attribute specifies the total size of the document(s) in K
351    octets, i.e., in units of 1024 octets requested to be processed in
352    the job. The value MUST be rounded up, so that a job between 1 and
353    1024 octets MUST be indicated as being 1, 1025 to 2048 MUST be 2,
354    etc.
355
356    This value MUST NOT include the multiplicative factors contributed
357    by the number of copies specified by the 'copies' attribute,
358    independent of whether the device can process multiple copies
359    without making multiple passes over the job or document data and
360    independent of whether the output is collated or not. Thus the
361    value is independent of the implementation and indicates the size
362    of the document(s) measured in K octets independent of the number
363    of copies.  This value MUST also not include the multiplicative
364    factor due to a copies instruction embedded in the document
365    data. If the document data actually includes replications of the
366    document data, this value will include such replication. In other
367    words, this value is always the size of the source document data,
368    rather than a measure of the hardcopy output to be produced.
369
370    """
371   
372    return Attribute(
373        'job-k-octets',
374        [Value(IntegerTags.INTEGER, val)])
375
376def JobImpressions(val):
377    """4.3.17.2 job-impressions (integer(0:MAX))
378
379    """
380
381    raise ClientErrorAttributes, "job-impressions"
382
383def JobMediaSheets(val):
384    """4.3.17.3 job-media-sheets (integer(0:MAX))
385
386    """
387
388    raise ClientErrorAttributes, "job-media-sheets"
389
390def JobKOctetsProcessed(val):
391    """4.3.18.1 job-k-octets-processed (integer(0:MAX))
392
393    """
394
395    raise ClientErrorAttributes, "job-k-octets-processed"
396
397def JobImpressionsCompleted(val):
398    """4.3.18.2 job-impressions-completed (integer(0:MAX))
399
400    """
401
402    raise ClientErrorAttributes, "job-impressions-completed"
403
404def JobMediaSheetsCompleted(val):
405    """4.3.18.3 job-media-sheets-completed (integer(0:MAX))
406
407    """
408
409    raise ClientErrorAttributes, "job-media-sheets-completed"
410
411def AttributesCharset(val):
412    """4.3.19 attributes-charset (charset)
413
414    This REQUIRED attribute is populated using the value in the client
415    supplied 'attributes-charset' attribute in the create request. It
416    identifies the charset (coded character set and encoding method)
417    used by any Job attributes with attribute syntax 'text' and 'name'
418    that were supplied by the client in the create request. See
419    Section 3.1.4 for a complete description of the
420    'attributes-charset' operation attribute.
421
422    This attribute does not indicate the charset in which the 'text'
423    and 'name' values are stored internally in the Job object. The
424    internal charset is implementation-defined. The IPP object MUST
425    convert from whatever the internal charset is to that being
426    requested in an operation as specified in Section 3.1.4.
427
428    """
429   
430    return Attribute(
431        'attributes-charset',
432        [Value(CharacterStringTags.CHARSET, val)])
433
434def AttributesNaturalLanguage(val):
435    """4.3.20 attributes-natural-language (naturalLanguage)
436
437    This REQUIRED attribute is populated using the value in the client
438    supplied 'attributes-natural-language' attribute in the create
439    request. It identifies the natural language used for any Job
440    attributes with attribute syntax 'text' and 'name' that were
441    supplied by the client in the create request. See Section 3.1.4
442    for a complete description of the 'attributes-natural-language'
443    operation attribute. See Sections 4.1.1.2 and 4.1.2.2 for how a
444    Natural Language Override may be supplied explicitly for each
445    'text' and 'name' attribute value that differs from the value
446    identified by the 'attributes-natural-language' attribute.
447
448    """
449   
450    return Attribute(
451        'attributes-natural-language',
452        [Value(CharacterStringTags.NATURAL_LANGUAGE, val)])
Note: See TracBrowser for help on using the repository browser.