Changeset 793432f


Ignore:
Timestamp:
Dec 23, 2011, 9:37:39 PM (12 years ago)
Author:
Jessica B. Hamrick <jhamrick@…>
Branches:
no-cups
Children:
1037115
Parents:
b828a96
git-author:
Jessica B. Hamrick <jhamrick@…> (12/23/11 21:37:39)
git-committer:
Jessica B. Hamrick <jhamrick@…> (12/23/11 21:37:39)
Message:

Reorganization

Location:
server/lib/gutenbach
Files:
2 added
2 deleted
5 edited
9 moved

Legend:

Unmodified
Added
Removed
  • server/lib/gutenbach/ipp/__init__.py

    rb828a96 r793432f  
    1 __all__ = []
     1import core
     2from core import *
     3__all__ = ['core']
     4__all__.extend(core.__all__)
     5print __all__
    26
    3 from attribute import Attribute
    4 __all__.append('Attribute')
    5 
    6 from attributegroup import AttributeGroup
    7 __all__.append('AttributeGroup')
    8 
    9 from request import Request
    10 __all__.append('Request')
    11 
    12 from value import Value
    13 __all__.append('Value')
    14 
    15 import constants
    16 from constants import *
    17 __all__.append('constants')
    18 __all__.extend(constants.__all__)
    19 
    20 import errors
    21 __all__.append('errors')
    22 
    23 import object_attributes
    24 from object_attributes import *
    25 __all__.append('object_attributes')
    26 __all__.extend(object_attributes.__all__)
     7import attributes
     8from attributes import *
     9__all__.append('attributes')
     10__all__.extend(attributes.__all__)
    2711
    2812# this import needs to come last
    29 import operations as ops
    30 __all__.append('ops')
     13import operations
     14from operations import *
     15__all__.append('operations')
     16__all__.extend(operations.__all__)
  • server/lib/gutenbach/ipp/attributes/job.py

    rb828a96 r793432f  
    11__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
    216    'JobUri',
    317    'JobId',
     
    3246]
    3347
    34 from ..attribute import Attribute
    35 from ..value import Value
    36 from ..exceptions import ClientErrorAttributes
    37 from ..constants import *
     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"
    38191
    39192def JobUri(val):
     
    112265    """
    113266
    114     raise ClientErrorAttributes, "job-more-info"
     267    raise errors.ClientErrorAttributes, "job-more-info"
    115268
    116269def JobName(val):
     
    214367    """
    215368
    216     raise ClientErrorAttributes, "job-state-message"
     369    raise errors.ClientErrorAttributes, "job-state-message"
    217370
    218371def JobDetailedStatusMessages(val):
     
    221374    """
    222375
    223     raise ClientErrorAttributes, "job-detailed-status-messages"
     376    raise errors.ClientErrorAttributes, "job-detailed-status-messages"
    224377
    225378def JobDocumentAccessErrors(val):
     
    228381    """
    229382
    230     raise ClientErrorAttributes, "job-document-access-errors"
     383    raise errors.ClientErrorAttributes, "job-document-access-errors"
    231384
    232385def NumberOfDocuments(val):
     
    235388    """
    236389
    237     raise ClientErrorAttributes, "number-of-documents"
     390    raise errors.ClientErrorAttributes, "number-of-documents"
    238391
    239392def OutputDeviceAssigned(val):
     
    242395    """
    243396
    244     raise ClientErrorAttributes, "output-device-assigned"
     397    raise errors.ClientErrorAttributes, "output-device-assigned"
    245398
    246399def TimeAtCreation(val):
     
    315468    """
    316469
    317     raise ClientErrorAttributes, "date-time-at-creation"
     470    raise errors.ClientErrorAttributes, "date-time-at-creation"
    318471
    319472def DateTimeAtProcessing(val):
     
    322475    """
    323476
    324     raise ClientErrorAttributes, "date-time-at-processing"
     477    raise errors.ClientErrorAttributes, "date-time-at-processing"
    325478
    326479def DateTimeAtCompletion(val):
     
    329482    """
    330483
    331     raise ClientErrorAttributes, "date-time-at-completion"
     484    raise errors.ClientErrorAttributes, "date-time-at-completion"
    332485
    333486def NumberOfInterveningJobs(val):
     
    336489    """
    337490
    338     raise ClientErrorAttributes, "number-of-intervening-jobs"
     491    raise errors.ClientErrorAttributes, "number-of-intervening-jobs"
    339492
    340493def JobMessageFromOperator(val):
     
    343496    """
    344497
    345     raise ClientErrorAttributes, "job-message-from-operator"
     498    raise errors.ClientErrorAttributes, "job-message-from-operator"
    346499
    347500def JobKOctets(val):
     
    379532    """
    380533
    381     raise ClientErrorAttributes, "job-impressions"
     534    raise errors.ClientErrorAttributes, "job-impressions"
    382535
    383536def JobMediaSheets(val):
     
    386539    """
    387540
    388     raise ClientErrorAttributes, "job-media-sheets"
     541    raise errors.ClientErrorAttributes, "job-media-sheets"
    389542
    390543def JobKOctetsProcessed(val):
     
    393546    """
    394547
    395     raise ClientErrorAttributes, "job-k-octets-processed"
     548    raise errors.ClientErrorAttributes, "job-k-octets-processed"
    396549
    397550def JobImpressionsCompleted(val):
     
    400553    """
    401554
    402     raise ClientErrorAttributes, "job-impressions-completed"
     555    raise errors.ClientErrorAttributes, "job-impressions-completed"
    403556
    404557def JobMediaSheetsCompleted(val):
     
    407560    """
    408561
    409     raise ClientErrorAttributes, "job-media-sheets-completed"
     562    raise errors.ClientErrorAttributes, "job-media-sheets-completed"
    410563
    411564def AttributesCharset(val):
  • server/lib/gutenbach/ipp/attributes/operation.py

    rb828a96 r793432f  
    44]
    55
    6 from ..attribute import Attribute
    7 from ..value import Value
    8 from ..exceptions import ClientErrorAttributes
    9 from ..constants import *
     6from .. import Attribute
     7from .. import Value
     8from .. import errors
     9from .. import CharacterStringTags
    1010
    1111def PrinterUri(val):
  • server/lib/gutenbach/ipp/attributes/printer.py

    rb828a96 r793432f  
    3939]
    4040
    41 from ..attribute import Attribute
    42 from ..value import Value
    43 from ..exceptions import ClientErrorAttributes
    44 from ..constants import *
     41from .. import Attribute
     42from .. import Value
     43from .. import errors
     44from .. import IntegerTags, CharacterStringTags
    4545
    4646def PrinterUriSupported(*vals):
     
    140140    """
    141141
    142     raise ClientErrorAttributes, "printer-location"
     142    raise errors.ClientErrorAttributes, "printer-location"
    143143
    144144def PrinterInfo(val):
     
    147147    """
    148148
    149     raise ClientErrorAttributes, "printer-info"
     149    raise errors.ClientErrorAttributes, "printer-info"
    150150
    151151def PrinterMoreInfo(val):
     
    154154    """
    155155
    156     raise ClientErrorAttributes, "printer-more-info"
     156    raise errors.ClientErrorAttributes, "printer-more-info"
    157157
    158158def PrinterDriverInstaller(val):
     
    161161    """
    162162
    163     raise ClientErrorAttributes, "printer-driver-installer"
     163    raise errors.ClientErrorAttributes, "printer-driver-installer"
    164164
    165165def PrinterMakeAndModel(val):
     
    168168    """
    169169
    170     raise ClientErrorAttributes, "printer-make-and-model"
     170    raise errors.ClientErrorAttributes, "printer-make-and-model"
    171171
    172172def PrinterMoreInfoManufacturer(val):
     
    175175    """
    176176
    177     raise ClientErrorAttributes, "printer-more-info-manufacturer"
     177    raise errors.ClientErrorAttributes, "printer-more-info-manufacturer"
    178178
    179179def PrinterState(val):
     
    219219    """
    220220
    221     raise ClientErrorAttributes, "printer-state-message"
     221    raise errors.ClientErrorAttributes, "printer-state-message"
    222222
    223223def IppVersionsSupported(*vals):
     
    462462    """
    463463
    464     raise ClientErrorAttributes, "printer-message-from-operator"
     464    raise errors.ClientErrorAttributes, "printer-message-from-operator"
    465465
    466466def ColorSupported(val):
     
    469469    """
    470470
    471     raise ClientErrorAttributes, "color-supported"
     471    raise errors.ClientErrorAttributes, "color-supported"
    472472   
    473473def ReferenceUriSchemeSupported(val):
     
    476476    """
    477477
    478     raise ClientErrorAttributes, "reference-uri-scheme-supported"
     478    raise errors.ClientErrorAttributes, "reference-uri-scheme-supported"
    479479
    480480def PdlOverrideSupported(val):
     
    547547    """
    548548
    549     raise ClientErrorAttributes, "printer-current-time"
     549    raise errors.ClientErrorAttributes, "printer-current-time"
    550550
    551551def MultipleOperationTimeOut(val):
     
    601601    """
    602602
    603     raise ClientErrorAttributes, "job-k-octets-supported"
     603    raise errors.ClientErrorAttributes, "job-k-octets-supported"
    604604
    605605def JobImpressionsSupported(val):
     
    608608    """
    609609
    610     raise ClientErrorAttributes, "job-impressions-supported"
     610    raise errors.ClientErrorAttributes, "job-impressions-supported"
    611611
    612612def JobMediaSheetsSupported(val):
     
    615615    """
    616616
    617     raise ClientErrorAttributes, "job-media-sheets-supported"
     617    raise errors.ClientErrorAttributes, "job-media-sheets-supported"
    618618
    619619def PagesPerMinute(val):
     
    622622    """
    623623
    624     raise ClientErrorAttributes, "pages-per-minute"
     624    raise errors.ClientErrorAttributes, "pages-per-minute"
    625625
    626626def PagesPerMinuteColor(val):
     
    629629    """
    630630
    631     raise ClientErrorAttributes, "pages-per-minute-color"
    632    
     631    raise errors.ClientErrorAttributes, "pages-per-minute-color"
     632   
  • server/lib/gutenbach/ipp/core/constants.py

    raded2d1 r793432f  
    11__all__ = [
    2     'Misc',
     2    'MiscConstants',
    33    'JobStates',
    44    'PrinterStates',
    5     'Operations',
     5    'OperationCodes',
    66    'SuccessCodes',
    77    'ClientErrorCodes',
     
    1717]
    1818
    19 class Misc():
     19class MiscConstants():
    2020    """Miscellaneous config options for the IPP server.
    2121   
     
    5353    def __init__(self): pass
    5454
    55 class Operations():
     55class OperationCodes():
    5656    """IPP and CUPS IPP Operations, as defined in various RFCs:
    5757
  • server/lib/gutenbach/ipp/operations/__init__.py

    rb828a96 r793432f  
    1 from ..attribute import Attribute
    2 from ..attributegroup import AttributeGroup
    3 from ..request import Request
    4 from ..value import Value
     1from .. import Attribute
     2from .. import AttributeGroup
     3from .. import Request
     4from .. import Value
    55from .. import errors
    6 from .. import constants as consts
    7 from .. import object_attributes
     6from .. import constants
     7from .. import attributes
    88
    99def verify_operations(request):
     
    2525    # check operation attributes tag
    2626    op_attrs = request.attribute_groups[0]
    27     if op_attrs.tag != consts.AttributeTags.OPERATION:
     27    if op_attrs.tag != constants.AttributeTags.OPERATION:
    2828        raise errors.ClientErrorBadRequest(
    2929            "Attribute group does not have OPERATION tag: 0x%x" % op_attrs.tag)
     
    4545    # check charset
    4646    charset_attr = op_attrs.attributes[0]
    47     expected = object_attributes.AttributesCharset('utf-8')
     47    expected = attributes.AttributesCharset('utf-8')
    4848    if charset_attr != expected:
    4949        raise errors.ClientErrorBadRequest("%s != %s" % (charset_attr, expected))
     
    5151    # check for attributes-natural-language
    5252    natlang_attr = op_attrs.attributes[1]
    53     expected = object_attributes.AttributesNaturalLanguage('en-us')
     53    expected = attributes.AttributesNaturalLanguage('en-us')
    5454    if natlang_attr != expected:
    5555        raise errors.ClientErrorBadRequest("%s != %s" % (natlang_attr, expected))
     
    5858
    5959def verify_printer_uri(uri_attr):
    60     expected = object_attributes.PrinterUri(uri_attr.values[0].value)
     60    expected = attributes.PrinterUri(uri_attr.values[0].value)
    6161    if uri_attr != expected:
    6262        raise errors.ClientErrorBadRequest("%s != %s" % (uri_attr, expected))
     
    7070
    7171def verify_requesting_username(username_attr):
    72     expected = object_attributes.RequestingUserName(username_attr.values[0].value)
     72    expected = attributes.RequestingUserName(username_attr.values[0].value)
    7373    if username_attr != expected:
    7474        raise errors.ClientErrorBadRequest("%s != %s" % (username_attr, expected))
     
    7777def make_empty_response(request):
    7878    # Operation attributes -- typically the same for any request
    79     attributes = AttributeGroup(
    80         consts.AttributeTags.OPERATION,
    81         [object_attributes.AttributesCharset('utf-8'),
    82          object_attributes.AttributesNaturalLanguage('en-us')])
     79    attribute_group = AttributeGroup(
     80        constants.AttributeTags.OPERATION,
     81        [attributes.AttributesCharset('utf-8'),
     82         attributes.AttributesNaturalLanguage('en-us')])
    8383
    8484    # Set up the default response -- handlers will override these
     
    8686    response_kwargs = {}
    8787    response_kwargs['version']          = request.version
    88     response_kwargs['operation_id']     = consts.StatusCodes.OK
     88    response_kwargs['operation_id']     = constants.StatusCodes.OK
    8989    response_kwargs['request_id']       = request.request_id
    90     response_kwargs['attribute_groups'] = [attributes]
     90    response_kwargs['attribute_groups'] = [attribute_group]
    9191    response = Request(**response_kwargs)
    9292
     
    9595def make_job_attributes(attrs, request, response):
    9696    response.attribute_groups.append(AttributeGroup(
    97         consts.AttributeTags.JOB, attrs))
     97        constants.AttributeTags.JOB, attrs))
    9898
    9999def make_printer_attributes(attrs, request, response):
    100100    response.attribute_groups.append(AttributeGroup(
    101         consts.AttributeTags.PRINTER, attrs))
     101        constants.AttributeTags.PRINTER, attrs))
    102102
    103103from cups_get_classes import verify_cups_get_classes_request, make_cups_get_classes_response
     
    125125from validate_job import verify_validate_job_request, make_validate_job_response
    126126
    127 __all__ = ['verify_cups_get_classes_request', 'make_cups_get_classes_response'
    128            'verify_cups_get_default_request', 'make_cups_get_default_response'
    129            'verify_cups_get_document_request', 'make_cups_get_document_response'
    130            'verify_cups_get_printers_request', 'make_cups_get_printers_response'
     127__all__ = ['verify_cups_get_classes_request', 'make_cups_get_classes_response',
     128           'verify_cups_get_default_request', 'make_cups_get_default_response',
     129           'verify_cups_get_document_request', 'make_cups_get_document_response',
     130           'verify_cups_get_printers_request', 'make_cups_get_printers_response',
    131131
    132            'verify_cancel_job_request', 'make_cancel_job_response'
    133            'verify_create_job_request', 'make_create_job_response'
    134            'verify_get_jobs_request', 'make_get_jobs_response'
    135            'make_get_printer_attributes_response'
    136            'verify_get_printer_attributes_request'
    137            'verify_pause_printer_request', 'make_pause_printer_response'
    138            'verify_print_job_request', 'make_print_job_response'
    139            'verify_print_uri_request', 'make_print_uri_response'
    140            'verify_promote_job_request', 'make_promote_job_response'
    141            'verify_restart_job_request', 'make_restart_job_response'
    142            'verify_resume_printer_request', 'make_resume_printer_response'
    143            'verify_send_document_request', 'make_send_document_response'
    144            'verify_send_uri_request', 'make_send_uri_response'
    145            'make_set_job_attributes_response'
    146            'verify_set_job_attributes_request'
    147            'make_set_printer_attributes_response'
    148            'verify_set_printer_attributes_request'
    149            'verify_validate_job_request', 'make_validate_job_response'
     132           'verify_cancel_job_request', 'make_cancel_job_response',
     133           'verify_create_job_request', 'make_create_job_response',
     134           'verify_get_jobs_request', 'make_get_jobs_response',
     135           'make_get_printer_attributes_response',
     136           'verify_get_printer_attributes_request',
     137           'verify_pause_printer_request', 'make_pause_printer_response',
     138           'verify_print_job_request', 'make_print_job_response',
     139           'verify_print_uri_request', 'make_print_uri_response',
     140           'verify_promote_job_request', 'make_promote_job_response',
     141           'verify_restart_job_request', 'make_restart_job_response',
     142           'verify_resume_printer_request', 'make_resume_printer_response',
     143           'verify_send_document_request', 'make_send_document_response',
     144           'verify_send_uri_request', 'make_send_uri_response',
     145           'make_set_job_attributes_response',
     146           'verify_set_job_attributes_request',
     147           'make_set_printer_attributes_response',
     148           'verify_set_printer_attributes_request',
     149           'verify_validate_job_request', 'make_validate_job_response',
    150150
    151151           'verify_operations',
  • server/lib/gutenbach/server/job.py

    raded2d1 r793432f  
    11from exceptions import InvalidJobException, InvalidPrinterStateException
    22import os
    3 import gutenbach.ipp.object_attributes.job_description_attributes as jda
     3import gutenbach.ipp as ipp
    44
    55# initialize logger
     
    5151    @property
    5252    def job_id(self):
    53         return jda.JobId(self.jid)
     53        return ipp.JobId(self.jid)
    5454
    5555    @property
    5656    def job_name(self):
    57         return jda.JobName(self.name)
     57        return ipp.JobName(self.name)
    5858
    5959    # XXX: we need to actually calculate this!
    6060    @property
    6161    def job_originating_user_name(self):
    62         return jda.JobOriginatingUserName("jhamrick")
     62        return ipp.JobOriginatingUserName("jhamrick")
    6363
    6464    # XXX: we need to actually calculate this!
    6565    @property
    6666    def job_k_octets(self):
    67         return jda.JobKOctets(1)
     67        return ipp.JobKOctets(1)
    6868
    6969    @property
    7070    def job_state(self):
    71         return jda.JobState(self.status)
     71        return ipp.JobState(self.status)
    7272
    7373    @property
    7474    def job_printer_uri(self):
    75         return jda.JobPrinterUri(self.printer.uri)
     75        return ipp.JobPrinterUri(self.printer.uri)
    7676
    7777    def get_job_attributes(self, request):
  • server/lib/gutenbach/server/printer.py

    raded2d1 r793432f  
    11#import alsaaudio as aa
    22from .exceptions import InvalidJobException, InvalidPrinterStateException
    3 from gutenbach.ipp.attribute import Attribute
    43import gutenbach.ipp as ipp
    5 import gutenbach.ipp.constants as const
    6 import gutenbach.ipp.object_attributes.printer_description_attributes as pda
    74import logging
    85import time
     
    8986    @property
    9087    def printer_uri_supported(self):
    91         return pda.PrinterUriSupported(self.uri)
     88        return ipp.PrinterUriSupported(self.uri)
    9289
    9390    @property
    9491    def uri_authentication_supported(self):
    95         return pda.UriAuthenticationSupported("none")
     92        return ipp.UriAuthenticationSupported("none")
    9693
    9794    @property
    9895    def uri_security_supported(self):
    99         return pda.UriSecuritySupported("none")
     96        return ipp.UriSecuritySupported("none")
    10097
    10198    @property
    10299    def printer_name(self):
    103         return pda.PrinterName(self.name)
     100        return ipp.PrinterName(self.name)
    104101
    105102    @property
    106103    def printer_state(self):
    107         return pda.PrinterState(ipp.constants.PrinterStates.IDLE)
     104        return ipp.PrinterState(ipp.constants.PrinterStates.IDLE)
    108105
    109106    @property
    110107    def printer_state_reasons(self):
    111         return pda.PrinterStateReasons("none")
     108        return ipp.PrinterStateReasons("none")
    112109
    113110    @property
    114111    def ipp_versions_supported(self):
    115         return pda.IppVersionsSupported("1.0", "1.1")
     112        return ipp.IppVersionsSupported("1.0", "1.1")
    116113
    117114    # XXX: We should query ourself for the supported operations
    118115    @property
    119116    def operations_supported(self):
    120         return pda.OperationsSupported(ipp.Operations.GET_JOBS)
     117        return ipp.OperationsSupported(ipp.OperationCodes.GET_JOBS)
    121118
    122119    @property
    123120    def charset_configured(self):
    124         return pda.CharsetConfigured("utf-8")
     121        return ipp.CharsetConfigured("utf-8")
    125122
    126123    @property
    127124    def charset_supported(self):
    128         return pda.CharsetSupported("utf-8")
     125        return ipp.CharsetSupported("utf-8")
    129126
    130127    @property
    131128    def natural_language_configured(self):
    132         return pda.NaturalLanguageConfigured("en-us")
     129        return ipp.NaturalLanguageConfigured("en-us")
    133130
    134131    @property
    135132    def generated_natural_language_supported(self):
    136         return pda.GeneratedNaturalLanguageSupported("en-us")
     133        return ipp.GeneratedNaturalLanguageSupported("en-us")
    137134
    138135    @property
    139136    def document_format_default(self):
    140         return pda.DocumentFormatDefault("application/octet-stream")
     137        return ipp.DocumentFormatDefault("application/octet-stream")
    141138
    142139    @property
    143140    def document_format_supported(self):
    144         return pda.DocumentFormatSupported("application/octet-stream", "audio/mp3")
     141        return ipp.DocumentFormatSupported("application/octet-stream", "audio/mp3")
    145142
    146143    @property
    147144    def printer_is_accepting_jobs(self):
    148         return pda.PrinterIsAcceptingJobs(True)
     145        return ipp.PrinterIsAcceptingJobs(True)
    149146
    150147    @property
    151148    def queued_job_count(self):
    152         return pda.QueuedJobCount(len(self.active_jobs))
     149        return ipp.QueuedJobCount(len(self.active_jobs))
    153150
    154151    @property
    155152    def pdl_override_supported(self):
    156         return pda.PdlOverrideSupported("not-attempted")
     153        return ipp.PdlOverrideSupported("not-attempted")
    157154
    158155    @property
    159156    def printer_up_time(self):
    160         return pda.PrinterUpTime(int(time.time()) - self.time_created)
     157        return ipp.PrinterUpTime(int(time.time()) - self.time_created)
    161158
    162159    @property
    163160    def compression_supported(self):
    164         return pda.CompressionSupported("none")
     161        return ipp.CompressionSupported("none")
    165162
    166163    @property
    167164    def multiple_operation_time_out(self):
    168         return pda.MultipleOperationTimeOut(240)
     165        return ipp.MultipleOperationTimeOut(240)
    169166
    170167    @property
    171168    def multiple_document_jobs_supported(self):
    172         return pda.MultipleDocumentJobsSupported(False)
     169        return ipp.MultipleDocumentJobsSupported(False)
    173170
    174171    def get_printer_attributes(self, request):
  • server/lib/gutenbach/server/requests.py

    rb828a96 r793432f  
    11from gutenbach.server.printer import GutenbachPrinter
    22import gutenbach.ipp as ipp
    3 import gutenbach.ipp.constants as consts
    43import logging
    54import traceback
     
    5453            exctype, excval, exctb = sys.exc_info()
    5554            logger.error("%s: %s" % (exctype.__name__, excval.message))
    56             response = ipp.ops.make_empty_response(request)
     55            response = ipp.operations.make_empty_response(request)
    5756            excval.update_response(response)
    5857
     
    6160        except Exception:
    6261            logger.error(traceback.format_exc())
    63             response = ipp.ops.make_empty_response(request)
     62            response = ipp.operations.make_empty_response(request)
    6463            response.operation_id = ipp.StatusCodes.INTERNAL_ERROR
    6564
     
    6867    def unknown_operation(self, request):
    6968        logger.warning("Received unknown operation 0x%x" % request.operation_id)
    70         response = ipp.ops.make_empty_response(request)
    71         response.operation_id = consts.StatusCodes.OPERATION_NOT_SUPPORTED
     69        response = ipp.operations.make_empty_response(request)
     70        response.operation_id = ipp.StatusCodes.OPERATION_NOT_SUPPORTED
    7271        return response
    7372       
    7473    ##### Printer Commands
    7574
    76     @handler_for(consts.Operations.PRINT_JOB)
     75    @handler_for(ipp.OperationCodes.PRINT_JOB)
    7776    def print_job(self, request):
    7877        """RFC 2911: 3.2.1 Print-Job Operation
     
    8887        raise ipp.errors.ServerErrorOperationNotSupported
    8988
    90     @handler_for(consts.Operations.VALIDATE_JOB)
     89    @handler_for(ipp.OperationCodes.VALIDATE_JOB)
    9190    def validate_job(self, request):
    9291
    9392        raise ipp.errors.ServerErrorOperationNotSupported
    9493
    95     @handler_for(consts.Operations.GET_JOBS)
     94    @handler_for(ipp.OperationCodes.GET_JOBS)
    9695    def get_jobs(self, request):
    9796        """RFC 2911: 3.2.6 Get-Jobs Operation
     
    110109
    111110        # verify the request and get an attribute dictionary
    112         req_dict = ipp.ops.verify_get_jobs_request(request)
     111        req_dict = ipp.operations.verify_get_jobs_request(request)
    113112
    114113        # lookup printer name
     
    124123
    125124        # build the response
    126         response = ipp.ops.make_get_jobs_response(jobs, request)
    127         return response
    128 
    129     @handler_for(consts.Operations.PRINT_URI)
     125        response = ipp.operations.make_get_jobs_response(jobs, request)
     126        return response
     127
     128    @handler_for(ipp.OperationCodes.PRINT_URI)
    130129    def print_uri(self, request):
    131130        raise ipp.errors.ServerErrorOperationNotSupported
    132131
    133     @handler_for(consts.Operations.CREATE_JOB)
     132    @handler_for(ipp.OperationCodes.CREATE_JOB)
    134133    def create_job(self, request):
    135134        """RFC 2911: 3.2.4 Create-Job Operation
     
    183182        raise ipp.errors.ServerErrorOperationNotSupported
    184183   
    185     @handler_for(consts.Operations.PAUSE_PRINTER)
     184    @handler_for(ipp.OperationCodes.PAUSE_PRINTER)
    186185    def pause_printer(self, request):
    187186        raise ipp.errors.ServerErrorOperationNotSupported
    188187
    189     @handler_for(consts.Operations.RESUME_PRINTER)
     188    @handler_for(ipp.OperationCodes.RESUME_PRINTER)
    190189    def resume_printer(self, request):
    191190        raise ipp.errors.ServerErrorOperationNotSupported
    192191
    193     @handler_for(consts.Operations.GET_PRINTER_ATTRIBUTES)
     192    @handler_for(ipp.OperationCodes.GET_PRINTER_ATTRIBUTES)
    194193    def get_printer_attributes(self, request):
    195194        """RFC 2911: 3.2.5 Get-Printer-Attributes Operation
     
    236235
    237236        # verify the request and get the attributes dictionary
    238         req_dict = ipp.ops.verify_get_printer_attributes_request(request)
     237        req_dict = ipp.operations.verify_get_printer_attributes_request(request)
    239238
    240239        # lookup the printer name
     
    246245
    247246        # bulid response
    248         response = ipp.ops.make_get_printer_attributes_response(
     247        response = ipp.operations.make_get_printer_attributes_response(
    249248            self.printers[printer_name].get_printer_attributes(request), request)
    250249        return response
    251250
    252     @handler_for(consts.Operations.SET_PRINTER_ATTRIBUTES)
     251    @handler_for(ipp.OperationCodes.SET_PRINTER_ATTRIBUTES)
    253252    def set_printer_attributes(self, request):
    254253        raise ipp.errors.ServerErrorOperationNotSupported
     
    256255    ##### Job Commands
    257256
    258     @handler_for(consts.Operations.CANCEL_JOB)
     257    @handler_for(ipp.OperationCodes.CANCEL_JOB)
    259258    def cancel_job(self, request):
    260259        raise ipp.errors.ServerErrorOperationNotSupported
    261260
    262     @handler_for(consts.Operations.SEND_DOCUMENT)
     261    @handler_for(ipp.OperationCodes.SEND_DOCUMENT)
    263262    def send_document(self, request):
    264263        raise ipp.errors.ServerErrorOperationNotSupported
    265264
    266     @handler_for(consts.Operations.SEND_URI)
     265    @handler_for(ipp.OperationCodes.SEND_URI)
    267266    def send_uri(self, request):
    268267        raise ipp.errors.ServerErrorOperationNotSupported
    269268
    270     @handler_for(consts.Operations.GET_JOB_ATTRIBUTES)
     269    @handler_for(ipp.OperationCodes.GET_JOB_ATTRIBUTES)
    271270    def get_job_attributes(self, request):
    272271       
    273272        # verify the request and get the attributes dictionary
    274         req_dict = ipp.ops.verify_get_jobs_request(request)
     273        req_dict = ipp.operations.verify_get_jobs_request(request)
    275274       
    276275        # lookup the printer name
     
    291290        # XXX: we need to honor the things that the request actually asks for
    292291        # build the response
    293         response = ipp.ops.make_get_job_attributes_response(
     292        response = ipp.operations.make_get_job_attributes_response(
    294293            job.get_job_attributes(request), request)
    295294        return response
    296295
    297     @handler_for(consts.Operations.SET_JOB_ATTRIBUTES)
     296    @handler_for(ipp.OperationCodes.SET_JOB_ATTRIBUTES)
    298297    def set_job_attributes(self, request):
    299298        raise ipp.errors.ServerErrorOperationNotSupported
    300299
    301     @handler_for(consts.Operations.RESTART_JOB)
     300    @handler_for(ipp.OperationCodes.RESTART_JOB)
    302301    def restart_job(self, request):
    303302        raise ipp.errors.ServerErrorOperationNotSupported
    304303
    305     @handler_for(consts.Operations.PROMOTE_JOB)
     304    @handler_for(ipp.OperationCodes.PROMOTE_JOB)
    306305    def promote_job(self, request):
    307306        raise ipp.errors.ServerErrorOperationNotSupported
     
    309308    ##### CUPS Specific Commands
    310309
    311     @handler_for(consts.Operations.CUPS_GET_DOCUMENT)
     310    @handler_for(ipp.OperationCodes.CUPS_GET_DOCUMENT)
    312311    def cups_get_document(self, request):
    313312        raise ipp.errors.ServerErrorOperationNotSupported
    314313
    315     @handler_for(consts.Operations.CUPS_GET_DEFAULT)
     314    @handler_for(ipp.OperationCodes.CUPS_GET_DEFAULT)
    316315    def cups_get_default(self, request):
    317316        """The CUPS-Get-Default operation (0x4001) returns the default
     
    323322
    324323        # verify the request and get the attributes dictionary
    325         req_dict = ipp.ops.verify_cups_get_default_request(request)
    326         # build the response
    327         response = ipp.ops.make_get_printer_attributes_response(
     324        req_dict = ipp.operations.verify_cups_get_default_request(request)
     325        # build the response
     326        response = ipp.operations.make_get_printer_attributes_response(
    328327            self.printers[self.default].get_printer_attributes(request), request)
    329328        return response
    330329
    331     @handler_for(consts.Operations.CUPS_GET_PRINTERS)
     330    @handler_for(ipp.OperationCodes.CUPS_GET_PRINTERS)
    332331    def cups_get_printers(self, request):
    333332        """The CUPS-Get-Printers operation (0x4002) returns the
     
    341340
    342341        # verify the request and get the attributes dictionary
    343         req_dict = ipp.ops.verify_cups_get_printers_request(request)
     342        req_dict = ipp.operations.verify_cups_get_printers_request(request)
    344343        # get the printer attributes
    345344        attrs = [self.printers[printer].get_printer_attributes(request) \
    346345                 for printer in self.printers]
    347346        # build the response
    348         response = ipp.ops.make_cups_get_printers_response(attrs, request)
    349         return response
    350 
    351     @handler_for(consts.Operations.CUPS_GET_CLASSES)
     347        response = ipp.operations.make_cups_get_printers_response(attrs, request)
     348        return response
     349
     350    @handler_for(ipp.OperationCodes.CUPS_GET_CLASSES)
    352351    def cups_get_classes(self, request):
    353352        """The CUPS-Get-Classes operation (0x4005) returns the printer
     
    361360
    362361        # verify the request and get the attributes dictionaryu
    363         req_dict = ipp.ops.verify_cups_get_classes_request(request)
    364         # build the response
    365         response = ipp.ops.make_cups_get_classes_response(request)
    366         return response
     362        req_dict = ipp.operations.verify_cups_get_classes_request(request)
     363        # build the response
     364        response = ipp.operations.make_cups_get_classes_response(request)
     365        return response
Note: See TracChangeset for help on using the changeset viewer.