source: server/lib/gutenbach/ipp/attributes/job.py @ 793432f

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

Reorganization

  • Property mode set to 100644
File size: 19.7 KB
Line 
1__all__ = [
2    'JobPriority',
3    'JobHoldUntil',
4    'JobSheets',
5    'MultipleDocumentHandling',
6    'Copies',
7    'Finishings',
8    'PageRanges',
9    'Sides',
10    'NumberUp',
11    'OrientationRequested',
12    'Media',
13    'PrinterResolution',
14    'PrintQuality',
15
16    'JobUri',
17    'JobId',
18    'JobPrinterUri',
19    'JobMoreInfo',
20    'JobName',
21    'JobOriginatingUserName',
22    'JobState',
23    'JobStateReasons',
24    'JobStateMessage',
25    'JobDetailedStatusMessages',
26    'JobDocumentAccessErrors',
27    'NumberOfDocuments',
28    'OutputDeviceAssigned',
29    'TimeAtCreation',
30    'TimeAtProcessing',
31    'TimeAtCompleted',
32    'JobPrinterUpTime',
33    'DateTimeAtCreation',
34    'DateTimeAtProcessing',
35    'DateTimeAtCompletion',
36    'NumberOfInterveningJobs',
37    'JobMessageFromOperator',
38    'JobKOctets',
39    'JobImpressions',
40    'JobMediaSheets',
41    'JobKOctetsProcessed',
42    'JobImpressionsCompleted',
43    'JobMediaSheetsCompleted',
44    'AttributesCharset',
45    'AttributesNaturalLanguage',
46]
47
48from .. import Attribute
49from .. import Value
50from .. import errors
51from .. import IntegerTags, CharacterStringTags
52
53def JobPriority(val):
54    """4.2.1 job-priority (integer(1:100))
55
56    This attribute specifies a priority for scheduling the Job. A
57    higher value specifies a higher priority. The value 1 indicates
58    the lowest possible priority. The value 100 indicates the highest
59    possible priority. Among those jobs that are ready to print, a
60    Printer MUST print all jobs with a priority value of n before
61    printing those with a priority value of n-1 for all n.
62
63    If the Printer object supports this attribute, it MUST always
64    support the full range from 1 to 100. No administrative
65    restrictions are permitted. This way an end-user can always make
66    full use of the entire range with any Printer object. If
67    privileged jobs are implemented outside IPP/1.1, they MUST have
68    priorities higher than 100, rather than restricting the range
69    available to end-users.
70
71    If the client does not supply this attribute and this attribute is
72    supported by the Printer object, the Printer object MUST use the
73    value of the Printer object's 'job-priority-default' at job
74    submission time (unlike most Job Template attributes that are used
75    if necessary at job processing time).
76   
77    The syntax for the 'job-priority-supported' is also
78    integer(1:100).  This single integer value indicates the number of
79    priority levels supported. The Printer object MUST take the value
80    supplied by the client and map it to the closest integer in a
81    sequence of n integers values that are evenly distributed over the
82    range from 1 to 100 using the formula:
83
84        roundToNearestInt((100x+50)/n)
85
86    where n is the value of 'job-priority-supported' and x ranges from
87    0 through n-1.
88
89    For example, if n=1 the sequence of values is 50; if n=2, the
90    sequence of values is: 25 and 75; if n = 3, the sequence of values
91    is: 17, 50 and 83; if n = 10, the sequence of values is: 5, 15,
92    25, 35, 45, 55, 65, 75, 85, and 95; if n = 100, the sequence of
93    values is: 1, 2, 3, ... 100.
94
95    If the value of the Printer object's 'job-priority-supported' is
96    10 and the client supplies values in the range 1 to 10, the
97    Printer object maps them to 5, in the range 11 to 20, the Printer
98    object maps them to 15, etc.
99
100    """
101   
102   
103    return Attribute(
104        'job-priority',
105        [Value(IntegerTags.INTEGER), val])
106
107def JobHoldUntil(val):
108    """4.2.2 job-hold-until (type3 keyword | name (MAX))
109   
110    """
111
112    raise errors.ClientErrorAttributes, "job-hold-until"
113   
114def JobSheets(val):
115    """4.2.3 job-sheets (type3 keyword | name(MAX))
116
117    """
118   
119    raise errors.ClientErrorAttributes, "job-sheets"
120
121def MultipleDocumentHandling(val):
122    """4.2.4 multiple-document-handling (type2 keyword)
123
124    """
125
126    raise errors.ClientErrorAttributes, "multiple-document-handling"
127
128def Copies(val):
129    """4.2.5 copies (integer(1:MAX))
130
131    """
132   
133    raise errors.ClientErrorAttributes, "copies"
134
135def Finishings(*vals):
136    """4.2.6 finishings (1setOf type2 enum)
137
138    """
139
140    raise errors.ClientErrorAttributes, "finishings"
141
142def PageRanges(*vals):
143    """4.2.7 page-ranges (1setOf rangeOfInteger (1:MAX))
144
145    """
146
147    raise errors.ClientErrorAttributes, "page-ranges"
148
149def Sides(val):
150    """4.2.8 sides (type2 keyword)
151
152    """
153
154    raise errors.ClientErrorAttributes, "sides"
155
156def NumberUp(val):
157    """4.2.9 number-up (integer(1:MAX))
158
159    """
160
161    raise errors.ClientErrorAttributes, "number-up"
162
163def OrientationRequested(val):
164    """4.2.10 orientation-requested (type2 enum)
165
166    """
167
168    raise errors.ClientErrorAttributes, "orientation-requested"
169
170def Media(val):
171    """4.2.11 media (type3 keyword | name(MAX))
172
173    """
174
175    raise errors.ClientErrorAttributes, "media"
176
177### XXX: we may want to repurpose this for bitrate?
178def PrinterResolution(val):
179    """4.2.12 printer-resolution (resolution)
180
181    """
182
183    raise errors.ClientErrorAttributes, "printer-resolution"
184
185def PrintQuality(val):
186    """4.2.13 print-quality (type2 enum)
187
188    """
189
190    raise errors.ClientErrorAttributes, "print-quality"
191
192def JobUri(val):
193    """4.3.1 job-uri (uri)
194
195    This REQUIRED attribute contains the URI for the job. The Printer
196    object, on receipt of a new job, generates a URI which identifies the
197    new Job. The Printer object returns the value of the 'job-uri'
198    attribute as part of the response to a create request. The precise
199    format of a Job URI is implementation dependent. If the Printer
200    object supports more than one URI and there is some relationship
201    between the newly formed Job URI and the Printer object's URI, the
202    Printer object uses the Printer URI supplied by the client in the
203    create request. For example, if the create request comes in over a
204    secure channel, the new Job URI MUST use the same secure channel.
205    This can be guaranteed because the Printer object is responsible for
206    generating the Job URI and the Printer object is aware of its
207    security configuration and policy as well as the Printer URI used in
208    the create request.
209
210    For a description of this attribute and its relationship to 'job-id'
211    and 'job-printer-uri' attribute, see the discussion in section 2.4 on
212    'Object Identity'.
213
214    """
215
216    return Attribute(
217        'job-uri',
218        [Value(CharacterStringTags.URI, val)])
219
220def JobId(val):
221    """4.3.2 job-id (integer(1:MAX))
222
223    This REQUIRED attribute contains the ID of the job. The Printer,
224    on receipt of a new job, generates an ID which identifies the new
225    Job on that Printer. The Printer returns the value of the 'job-id'
226    attribute as part of the response to a create request. The 0 value
227    is not included to allow for compatibility with SNMP index values
228    which also cannot be 0.
229
230    For a description of this attribute and its relationship to
231    'job-uri' and 'job-printer-uri' attribute, see the discussion in
232    section 2.4 on 'Object Identity'.
233
234    """
235   
236    return Attribute(
237        'job-id',
238        [Value(IntegerTags.INTEGER, val)])
239
240def JobPrinterUri(val):
241    """4.3.3 job-printer-uri (uri)
242
243    This REQUIRED attribute identifies the Printer object that created
244    this Job object. When a Printer object creates a Job object, it
245    populates this attribute with the Printer object URI that was used
246    in the create request. This attribute permits a client to identify
247    the Printer object that created this Job object when only the Job
248    object's URI is available to the client. The client queries the
249    creating Printer object to determine which languages, charsets,
250    operations, are supported for this Job.
251
252    For a description of this attribute and its relationship to
253    'job-uri' and 'job-id' attribute, see the discussion in section
254    2.4 on 'Object Identity'.
255
256    """
257
258    return Attribute(
259        'job-printer-uri',
260        [Value(CharacterStringTags.URI, val)])
261
262def JobMoreInfo(val):
263    """4.3.4 job-more-info (uri)
264
265    """
266
267    raise errors.ClientErrorAttributes, "job-more-info"
268
269def JobName(val):
270    """4.3.5 job-name (name(MAX))
271   
272    This REQUIRED attribute is the name of the job. It is a name that
273    is more user friendly than the 'job-uri' attribute value. It does
274    not need to be unique between Jobs. The Job's 'job-name' attribute
275    is set to the value supplied by the client in the 'job-name'
276    operation attribute in the create request (see Section 3.2.1.1).
277    If, however, the 'job-name' operation attribute is not supplied by
278    the client in the create request, the Printer object, on creation
279    of the Job, MUST generate a name. The printer SHOULD generate the
280    value of the Job's 'job-name' attribute from the first of the
281    following sources that produces a value: 1) the 'document-name'
282    operation attribute of the first (or only) document, 2) the
283    'document-URI' attribute of the first (or only) document, or 3)
284    any other piece of Job specific and/or Document Content
285    information.
286
287    """
288   
289    return Attribute(
290        'job-name',
291        [Value(CharacterStringTags.NAME_WITHOUT_LANGUAGE, val)])
292
293def JobOriginatingUserName(val):
294    """4.3.6 job-originating-user-name (name(MAX))
295
296    This REQUIRED attribute contains the name of the end user that
297    submitted the print job. The Printer object sets this attribute to
298    the most authenticated printable name that it can obtain from the
299    authentication service over which the IPP operation was received.
300    Only if such is not available, does the Printer object use the
301    value supplied by the client in the 'requesting-user-name'
302    operation attribute of the create operation (see Sections 4.4.2,
303    4.4.3, and 8).  Note: The Printer object needs to keep an internal
304    originating user id of some form, typically as a credential of a
305    principal, with the Job object. Since such an internal attribute
306    is implementation- dependent and not of interest to clients, it is
307    not specified as a Job Description attribute. This originating
308    user id is used for authorization checks (if any) on all
309    subsequent operations.
310
311    """
312   
313    return Attribute(
314        'job-originating-user-name',
315        [Value(CharacterStringTags.NAME_WITHOUT_LANGUAGE, val)])
316
317def JobState(val):
318    """4.3.7 job-state (type1 enum)
319
320    This REQUIRED attribute identifies the current state of the job.
321    Even though the IPP protocol defines seven values for job states
322    (plus the out-of-band 'unknown' value - see Section 4.1),
323    implementations only need to support those states which are
324    appropriate for the particular implementation. In other words, a
325    Printer supports only those job states implemented by the output
326    device and available to the Printer object implementation.
327   
328    """
329   
330    return Attribute(
331        'job-state',
332        [Value(IntegerTags.ENUM, val)])
333
334def JobStateReasons(val):
335    """4.3.8 job-state-reasons (1setOf type2 keyword)
336
337    This REQUIRED attribute provides additional information about the
338    job's current state, i.e., information that augments the value of
339    the job's 'job-state' attribute.
340
341    These values MAY be used with any job state or states for which
342    the reason makes sense. Some of these value definitions indicate
343    conformance requirements; the rest are OPTIONAL. Furthermore, when
344    implemented, the Printer MUST return these values when the reason
345    applies and MUST NOT return them when the reason no longer applies
346    whether the value of the Job's 'job-state' attribute changed or
347    not.  When the Job does not have any reasons for being in its
348    current state, the value of the Job's 'job-state-reasons'
349    attribute MUST be 'none'.
350
351    Note: While values cannot be added to the 'job-state' attribute
352    without impacting deployed clients that take actions upon
353    receiving 'job-state' values, it is the intent that additional
354    'job-state- reasons' values can be defined and registered without
355    impacting such deployed clients. In other words, the
356    'job-state-reasons' attribute is intended to be extensible.
357
358    """
359
360    return Attribute(
361        'job-state-reasons',
362        [Value(CharacterStringTags.KEYWORD, val) for val in vals])
363
364def JobStateMessage(val):
365    """4.3.9 job-state-message (text(MAX))
366
367    """
368
369    raise errors.ClientErrorAttributes, "job-state-message"
370
371def JobDetailedStatusMessages(val):
372    """4.3.10 job-detailed-status-messages (1setOf text(MAX))
373
374    """
375
376    raise errors.ClientErrorAttributes, "job-detailed-status-messages"
377
378def JobDocumentAccessErrors(val):
379    """4.3.11 job-document-access-errors (1setOf text(MAX))
380
381    """
382
383    raise errors.ClientErrorAttributes, "job-document-access-errors"
384
385def NumberOfDocuments(val):
386    """4.3.12 number-of-documents (integer(0:MAX))
387
388    """
389
390    raise errors.ClientErrorAttributes, "number-of-documents"
391
392def OutputDeviceAssigned(val):
393    """4.3.13 output-device-assigned (name(127))
394
395    """
396
397    raise errors.ClientErrorAttributes, "output-device-assigned"
398
399def TimeAtCreation(val):
400    """4.3.14.1 time-at-creation (integer(MIN:MAX))
401
402    This REQUIRED attribute indicates the time at which the Job object
403    was created.
404
405    """
406   
407    return Attribute(
408        "time-at-creation",
409        [Value(IntegerTags.INTEGER, val)])
410
411def TimeAtProcessing(val):
412    """4.3.14.2 time-at-processing (integer(MIN:MAX))
413
414    This REQUIRED attribute indicates the time at which the Job object
415    first began processing after the create operation or the most
416    recent Restart-Job operation. The out-of-band 'no-value' value is
417    returned if the job has not yet been in the 'processing' state
418    (see the beginning of Section 4.1).
419
420    """
421
422    return Attribute(
423        "time-at-processing",
424        [Value(IntegerTags.INTEGER, val)])
425
426def TimeAtCompleted(val):
427    """4.3.14.3 time-at-completed (integer(MIN:MAX))
428
429    This REQUIRED attribute indicates the time at which the Job object
430    completed (or was canceled or aborted). The out-of-band 'no-value'
431    value is returned if the job has not yet completed, been canceled,
432    or aborted (see the beginning of Section 4.1).
433
434    """
435
436    return Attribute(
437        "time-at-completed",
438        [Value(IntegerTags.INTEGER, val)])
439
440def JobPrinterUpTime(val):
441    """4.3.14.4 job-printer-up-time (integer(1:MAX))
442
443    This REQUIRED Job Description attribute indicates the amount of
444    time (in seconds) that the Printer implementation has been up and
445    running.  This attribute is an alias for the 'printer-up-time'
446    Printer Description attribute (see Section 4.4.29).
447
448    A client MAY request this attribute in a Get-Job-Attributes or
449    Get- Jobs request and use the value returned in combination with
450    other requested Event Time Job Description Attributes in order to
451    display time attributes to a user. The difference between this
452    attribute and the 'integer' value of a 'time-at-xxx' attribute is
453    the number of seconds ago that the 'time-at-xxx' event occurred. A
454    client can compute the wall-clock time at which the 'time-at-xxx'
455    event occurred by subtracting this difference from the client's
456    wall-clock time.
457   
458    """
459
460    return Attribute(
461        "job-printer-up-time",
462        [Value(IntegerTags.INTEGER, val)])
463
464
465def DateTimeAtCreation(val):
466    """4.3.14.5 date-time-at-creation (dateTime)
467
468    """
469
470    raise errors.ClientErrorAttributes, "date-time-at-creation"
471
472def DateTimeAtProcessing(val):
473    """4.3.14.6 date-time-at-processing (dateTime)
474
475    """
476
477    raise errors.ClientErrorAttributes, "date-time-at-processing"
478
479def DateTimeAtCompletion(val):
480    """4.3.14.7 date-time-at-completed (dateTime)
481
482    """
483
484    raise errors.ClientErrorAttributes, "date-time-at-completion"
485
486def NumberOfInterveningJobs(val):
487    """4.3.15 number-of-intervening-jobs (integer(0:MAX))
488
489    """
490
491    raise errors.ClientErrorAttributes, "number-of-intervening-jobs"
492
493def JobMessageFromOperator(val):
494    """4.3.16 job-message-from-operator (text(127))
495
496    """
497
498    raise errors.ClientErrorAttributes, "job-message-from-operator"
499
500def JobKOctets(val):
501    """4.3.17.1 job-k-octets (integer(0:MAX))
502
503    This attribute specifies the total size of the document(s) in K
504    octets, i.e., in units of 1024 octets requested to be processed in
505    the job. The value MUST be rounded up, so that a job between 1 and
506    1024 octets MUST be indicated as being 1, 1025 to 2048 MUST be 2,
507    etc.
508
509    This value MUST NOT include the multiplicative factors contributed
510    by the number of copies specified by the 'copies' attribute,
511    independent of whether the device can process multiple copies
512    without making multiple passes over the job or document data and
513    independent of whether the output is collated or not. Thus the
514    value is independent of the implementation and indicates the size
515    of the document(s) measured in K octets independent of the number
516    of copies.  This value MUST also not include the multiplicative
517    factor due to a copies instruction embedded in the document
518    data. If the document data actually includes replications of the
519    document data, this value will include such replication. In other
520    words, this value is always the size of the source document data,
521    rather than a measure of the hardcopy output to be produced.
522
523    """
524   
525    return Attribute(
526        'job-k-octets',
527        [Value(IntegerTags.INTEGER, val)])
528
529def JobImpressions(val):
530    """4.3.17.2 job-impressions (integer(0:MAX))
531
532    """
533
534    raise errors.ClientErrorAttributes, "job-impressions"
535
536def JobMediaSheets(val):
537    """4.3.17.3 job-media-sheets (integer(0:MAX))
538
539    """
540
541    raise errors.ClientErrorAttributes, "job-media-sheets"
542
543def JobKOctetsProcessed(val):
544    """4.3.18.1 job-k-octets-processed (integer(0:MAX))
545
546    """
547
548    raise errors.ClientErrorAttributes, "job-k-octets-processed"
549
550def JobImpressionsCompleted(val):
551    """4.3.18.2 job-impressions-completed (integer(0:MAX))
552
553    """
554
555    raise errors.ClientErrorAttributes, "job-impressions-completed"
556
557def JobMediaSheetsCompleted(val):
558    """4.3.18.3 job-media-sheets-completed (integer(0:MAX))
559
560    """
561
562    raise errors.ClientErrorAttributes, "job-media-sheets-completed"
563
564def AttributesCharset(val):
565    """4.3.19 attributes-charset (charset)
566
567    This REQUIRED attribute is populated using the value in the client
568    supplied 'attributes-charset' attribute in the create request. It
569    identifies the charset (coded character set and encoding method)
570    used by any Job attributes with attribute syntax 'text' and 'name'
571    that were supplied by the client in the create request. See
572    Section 3.1.4 for a complete description of the
573    'attributes-charset' operation attribute.
574
575    This attribute does not indicate the charset in which the 'text'
576    and 'name' values are stored internally in the Job object. The
577    internal charset is implementation-defined. The IPP object MUST
578    convert from whatever the internal charset is to that being
579    requested in an operation as specified in Section 3.1.4.
580
581    """
582   
583    return Attribute(
584        'attributes-charset',
585        [Value(CharacterStringTags.CHARSET, val)])
586
587def AttributesNaturalLanguage(val):
588    """4.3.20 attributes-natural-language (naturalLanguage)
589
590    This REQUIRED attribute is populated using the value in the client
591    supplied 'attributes-natural-language' attribute in the create
592    request. It identifies the natural language used for any Job
593    attributes with attribute syntax 'text' and 'name' that were
594    supplied by the client in the create request. See Section 3.1.4
595    for a complete description of the 'attributes-natural-language'
596    operation attribute. See Sections 4.1.1.2 and 4.1.2.2 for how a
597    Natural Language Override may be supplied explicitly for each
598    'text' and 'name' attribute value that differs from the value
599    identified by the 'attributes-natural-language' attribute.
600
601    """
602   
603    return Attribute(
604        'attributes-natural-language',
605        [Value(CharacterStringTags.NATURAL_LANGUAGE, val)])
Note: See TracBrowser for help on using the repository browser.