Changeset aded2d1


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

Checkpoint, creating classes for specific IPP attributes

Location:
server/lib/gutenbach
Files:
5 added
7 edited
1 moved

Legend:

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

    rf6e2532 raded2d1  
     1__all__ = []
     2
    13from attribute import Attribute
     4__all__.append('Attribute')
     5
    26from attributegroup import AttributeGroup
     7__all__.append('AttributeGroup')
     8
    39from request import Request
     10__all__.append('Request')
     11
    412from value import Value
     13__all__.append('Value')
    514
    615import constants
    716from constants import *
     17__all__.append('constants')
     18__all__.extend(constants.__all__)
    819
    920import exceptions as errors
     21__all__.append('errors')
     22
     23import object_attributes
     24from object_attributes import *
     25__all__.append('object_attributes')
     26__all__.extend(object_attributes.__all__)
    1027
    1128# this import needs to come last
    12 import operations as ops
    13 
    14 __all__ = ['Attribute', 'AttributeGroup', 'Request', 'Value',
    15            'ops', 'errors', 'constants']
    16 __all__.extend(constants.__all__)
     29import operations as ops
     30__all__.append('ops')
  • server/lib/gutenbach/ipp/constants.py

    rf6e2532 raded2d1  
    1515    'OctetStringTags',
    1616    'CharacterStringTags',
    17     'operations_attribute_value_tags',
    18     'job_attribute_value_tags',
    19     'printer_attribute_value_tags',
    2017]
    2118
     
    331328    MIME_MEDIA_TYPE       = 0x49                                   
    332329    MEMBER_ATTR_NAME      = 0x4a
    333 
    334 operations_attribute_value_tags = {
    335     'attributes-charset': CharacterStringTags.CHARSET,
    336     'attributes-natural-language': CharacterStringTags.NATURAL_LANGUAGE,
    337     'printer-uri': CharacterStringTags.URI,
    338     'requesting-user-name': CharacterStringTags.NAME_WITHOUT_LANGUAGE
    339     }
    340 
    341 job_attribute_value_tags = {
    342     'job-id': IntegerTags.INTEGER,
    343     'job-name': CharacterStringTags.NAME_WITHOUT_LANGUAGE,
    344     'job-originating-user-name': CharacterStringTags.NAME_WITHOUT_LANGUAGE,
    345     'job-k-octets': IntegerTags.INTEGER,
    346     'job-state': IntegerTags.ENUM,
    347     'job-printer-uri': CharacterStringTags.URI
    348     }
    349 
    350 printer_attribute_value_tags = {
    351     "printer-uri-supported": CharacterStringTags.URI,
    352     "uri-authentication-supported": CharacterStringTags.KEYWORD,
    353     "uri-security-supported": CharacterStringTags.KEYWORD,
    354     "printer-name": CharacterStringTags.NAME_WITHOUT_LANGUAGE,
    355     "printer-state": IntegerTags.ENUM,
    356     "printer-state-reasons": CharacterStringTags.KEYWORD,
    357     "ipp-versions-supported": CharacterStringTags.KEYWORD,
    358     "operations-supported": IntegerTags.ENUM,
    359     "charset-configured": CharacterStringTags.CHARSET,
    360     "charset-supported": CharacterStringTags.CHARSET,
    361     "natural-language-configured": CharacterStringTags.NATURAL_LANGUAGE,
    362     "generated-natural-language-supported": CharacterStringTags.NATURAL_LANGUAGE,
    363     "document-format-default": CharacterStringTags.MIME_MEDIA_TYPE,
    364     "document-format-supported": CharacterStringTags.MIME_MEDIA_TYPE,
    365     "printer-is-accepting-jobs": IntegerTags.BOOLEAN,
    366     "queued-job-count": IntegerTags.INTEGER,
    367     "pdl-override-supported": CharacterStringTags.KEYWORD,
    368     "printer-up-time": IntegerTags.INTEGER,
    369     "compression-supported": CharacterStringTags.KEYWORD,
    370     "multiple-operation-time-out": IntegerTags.INTEGER,
    371     "multiple-document-jobs-supported": IntegerTags.BOOLEAN
    372     }
    373    
  • server/lib/gutenbach/ipp/errors.py

    rf6c6897 raded2d1  
    22
    33class IPPException(Exception):
    4     def __init__(self, message):
     4    def __init__(self, message=""):
    55        self.message = message
    66
     
    2424### Client error codes
    2525
    26 class BadRequest(IPPClientException):
     26class ClientErrorBadRequest(IPPClientException):
    2727    ipp_error_code = ErrorCodes.BAD_REQUEST
    2828
    29 class Forbidden(IPPClientException):
     29class ClientErrorForbidden(IPPClientException):
    3030    ipp_error_code = ErrorCodes.FORBIDDEN
    3131
    32 class NotAuthenticated(IPPClientException):
     32class ClientErrorNotAuthenticated(IPPClientException):
    3333    ipp_error_code = ErrorCodes.NOT_AUTHENTICATED
    3434
    35 class NotAuthorized(IPPClientException):
     35class ClientErrorNotAuthorized(IPPClientException):
    3636    ipp_error_code = ErrorCodes.NOT_AUTHORIZED
    3737
    38 class NotPossible(IPPClientException):
     38class ClientErrorNotPossible(IPPClientException):
    3939    ipp_error_code = ErrorCodes.NOT_POSSIBLE
    4040
    41 class Timeout(IPPClientException):
     41class ClientErrorTimeout(IPPClientException):
    4242    ipp_error_code = ErrorCodes.TIMEOUT
    4343
    44 class NotFound(IPPClientException):
     44class ClientErrorNotFound(IPPClientException):
    4545    ipp_error_code = ErrorCodes.NOT_FOUND
    4646
    47 class Gone(IPPClientException):
     47class ClientErrorGone(IPPClientException):
    4848    ipp_error_code = ErrorCodes.GONE
    4949
    50 class RequestEntity(IPPClientException):
     50class ClientErrorRequestEntity(IPPClientException):
    5151    ipp_error_code = ErrorCodes.REQUEST_ENTITY
    5252
    53 class RequestValue(IPPClientException):
     53class ClientErrorRequestValue(IPPClientException):
    5454    ipp_error_code = ErrorCodes.REQUEST_VALUE
    5555
    56 class DocumentFormatNotSupported(IPPClientException):
     56class ClientErrorDocumentFormatNotSupported(IPPClientException):
    5757    ipp_error_code = ErrorCodes.DOCUMENT_FORMAT
    5858
    59 class Attributes(IPPClientException):
     59class ClientErrorAttributes(IPPClientException):
    6060    ipp_error_code = ErrorCodes.ATTRIBUTES
    6161
     
    6767        pass
    6868
    69 class UriSchemeNotSupported(IPPClientException):
     69class ClientErrorUriSchemeNotSupported(IPPClientException):
    7070    ipp_error_code = ErrorCodes.URI_SCHEME
    7171
    72 class CharsetNotSupported(IPPClientException):
     72class ClientErrorCharsetNotSupported(IPPClientException):
    7373    ipp_error_code = ErrorCodes.CHARSET
    7474
    75 class Conflict(IPPClientException):
     75class ClientErrorConflict(IPPClientException):
    7676    ipp_error_code = ErrorCodes.CONFLICT
    7777
    78 class CompressionNotSupported(IPPClientException):
     78class ClientErrorCompressionNotSupported(IPPClientException):
    7979    ipp_error_code = ErrorCodes.COMPRESSION_NOT_SUPPORTED
    8080
    81 class CompressionError(IPPClientException):
     81class ClientErrorCompressionError(IPPClientException):
    8282    ipp_error_code = ErrorCodes.COMPRESSION_ERROR
    8383
    84 class DocumentFormatError(IPPClientException):
     84class ClientErrorDocumentFormatError(IPPClientException):
    8585    ipp_error_code = ErrorCodes.DOCUMENT_FORMAT_ERROR
    8686
    87 class DocumentAccessError(IPPClientException):
     87class ClientErrorDocumentAccessError(IPPClientException):
    8888    ipp_error_code = ErrorCodes.DOCUMENT_ACCESS_ERROR
    8989
    90 class AttributesNotSettable(IPPClientException):
     90class ClientErrorAttributesNotSettable(IPPClientException):
    9191    ipp_error_code = ErrorCodes.ATTRIBUTES_NOT_SETTABLE
    9292
    93 class IgnoredAllSubscriptions(IPPClientException):
     93class ClientErrorIgnoredAllSubscriptions(IPPClientException):
    9494    ipp_error_code = ErrorCodes.IGNORED_ALL_SUBSCRIPTIONS
    9595
    96 class TooManySubscriptions(IPPClientException):
     96class ClientErrorTooManySubscriptions(IPPClientException):
    9797    ipp_error_code = ErrorCodes.TOO_MANY_SUBSCRIPTIONS
    9898
    99 class IgnoredAllNotifications(IPPClientException):
     99class ClientErrorIgnoredAllNotifications(IPPClientException):
    100100    ipp_error_code = ErrorCodes.IGNORED_ALL_NOTIFICATIONS
    101101
    102 class PrintSupportFileNotFound(IPPClientException):
     102class ClientErrorPrintSupportFileNotFound(IPPClientException):
    103103    ipp_error_code = ErrorCodes.PRINT_SUPPORT_FILE_NOT_FOUND
    104104
    105105### Server error codes
    106106
    107 class InternalError(IPPServerException):
     107class ServerErrorInternalError(IPPServerException):
    108108    ipp_error_code = ErrorCodes.INTERNAL_ERROR
    109109
    110 class OperationNotSupported(IPPServerException):
     110class ServerErrorOperationNotSupported(IPPServerException):
    111111    ipp_error_code = ErrorCodes.OPERATION_NOT_SUPPORTED
    112112
    113 class ServiceUnavailable(IPPServerException):
     113class ServerErrorServiceUnavailable(IPPServerException):
    114114    ipp_error_code = ErrorCodes.SERVICE_UNAVAILABLE
    115115
    116 class VersionNotSupported(IPPServerException):
     116class ServerErrorVersionNotSupported(IPPServerException):
    117117    ipp_error_code = ErrorCodes.VERSION_NOT_SUPPORTED
    118118
    119 class DeviceError(IPPServerException):
     119class ServerErrorDeviceError(IPPServerException):
    120120    ipp_error_code = ErrorCodes.DEVICE_ERROR
    121121
    122 class TemporaryError(IPPServerException):
     122class ServerErrorTemporaryError(IPPServerException):
    123123    ipp_error_code = ErrorCodes.TEMPORARY_ERROR
    124124
    125 class NotAccepting(IPPServerException):
     125class ServerErrorNotAccepting(IPPServerException):
    126126    ipp_error_code = ErrorCodes.NOT_ACCEPTING
    127127
    128 class PrinterBusy(IPPServerException):
     128class ServerErrorPrinterBusy(IPPServerException):
    129129    ipp_error_code = ErrorCodes.PRINTER_BUSY
    130130
    131 class ErrorJobCancelled(IPPServerException):
     131class ServerErrorErrorJobCancelled(IPPServerException):
    132132    ipp_error_code = ErrorCodes.ERROR_JOB_CANCELLED
    133133
    134 class MultipleJobsNotSupported(IPPServerException):
     134class ServerErrorMultipleJobsNotSupported(IPPServerException):
    135135    ipp_error_code = ErrorCodes.MULTIPLE_JOBS_NOT_SUPPORTED
    136136
    137 class PrinterIsDeactivated(IPPServerException):
     137class ServerErrorPrinterIsDeactivated(IPPServerException):
    138138    ipp_error_code = ErrorCodes.PRINTER_IS_DEACTIVATED
  • server/lib/gutenbach/ipp/operations/__init__.py

    re70c020 raded2d1  
    55from .. import errors
    66from .. import constants as consts
     7from .. import object_attributes
    78
    89def verify_operations(request):
     
    1617    # XXX: check version
    1718    if False:
    18         raise errors.VersionNotSupported(str(request.version))
     19        raise errors.ClientErrorVersionNotSupported(str(request.version))
    1920
    2021    # XXX: check operation id
    2122    if False:
    22         raise errors.OperationNotSupported(str(request.operation_id))
     23        raise errors.ClientErrorOperationNotSupported(str(request.operation_id))
    2324
    2425    # check operation attributes tag
    2526    op_attrs = request.attribute_groups[0]
    2627    if op_attrs.tag != consts.AttributeTags.OPERATION:
    27         raise errors.BadRequest(
     28        raise errors.ClientErrorBadRequest(
    2829            "Attribute group does not have OPERATION tag: 0x%x" % op_attrs.tag)
    2930
     
    3233    # # check compression
    3334    # if False:
    34     #     raise errors.CompressionNotSupported
     35    #     raise errors.ClientErrorCompressionNotSupported
    3536
    3637    # # check document format
    3738    # if False:
    38     #     raise errors.DocumentFormatNotSupported
     39    #     raise errors.ClientErrorDocumentFormatNotSupported
    3940
    4041    # # check document uri
    4142    # if False:
    42     #     raise errors.UriSchemeNotSupported
     43    #     raise errors.ClientErrorUriSchemeNotSupported
    4344
    4445    # check charset
    4546    charset_attr = op_attrs.attributes[0]
    46     if charset_attr.name != 'attributes-charset':
    47         raise errors.BadRequest(
    48             "Attribute is not attributes-charset: %s" % charset_attr.name)
    49     if len(charset_attr.values) != 1:
    50         raise errors.BadRequest(
    51             "Too many values for attributes-charset: %d" % len(charset_attr.values))
    52     # check charset value
    53     charset_value = charset_attr.values[0]
    54     if charset_value.tag != consts.operations_attribute_value_tags['attributes-charset']:
    55         raise errors.BadRequest(
    56             "Wrong tag for charset value: 0x%x" % charset_value.tag)
    57     if charset_value.value != 'utf-8':
    58         raise errors.CharsetNotSupported(str(charset_value.value))
     47    if charset_attr != object_attributes.AttributesCharset('utf-8'):
     48        raise errors.ClientErrorBadRequest
    5949
    6050    # check for attributes-natural-language
    6151    natlang_attr = op_attrs.attributes[1]
    62     if natlang_attr.name != 'attributes-natural-language':
    63         raise errors.BadRequest(
    64             "Attribute is not attributes-natural-language: %s" % natlang_attr.name)
    65     if len(charset_attr.values) != 1:
    66         raise errors.BadRequest(
    67             "Too many values for attributes-natural-language: %s" % len(natlang_attr.values))
    68     # check natural language value
    69     natlang_value = natlang_attr.values[0]
    70     if natlang_value.tag != consts.operations_attribute_value_tags['attributes-natural-language']:
    71         raise errors.BadRequest(
    72             "Natural language value does not have NATURAL_LANGUAGE tag: 0x%x" % natlang_value.tag)
    73     if natlang_value.value != 'en-us':
    74         raise errors.Attributes(
    75             "Invalid natural language value: %s" % natlang_value.value, [natlang_attr])
     52    if natlang_attr != object_attributes.AttributesNaturalLanguage('en-us'):
     53        raise errors.ClientErrorBadRequest
    7654
    77     return dict([(attr.name, attr.values) for attr in op_attrs.attributes])
     55    return dict([(attr.name, attr) for attr in op_attrs.attributes])
    7856
    79 def verify_printer_uri(values):
    80     if len(values) != 1:
    81         raise errors.BadRequest(
    82             "Requesting printer uri attribute has too many values: %d" % len(values))
    83     uri_value = values[0]
    84     if uri_value.tag != consts.operations_attribute_value_tags['printer-uri']:
    85         raise errors.BadRequest(
    86             "Bad value tag (expected URI): 0x%x" % uri_value_tag)
     57def verify_printer_uri(uri_attr):
     58    if uri_attr != object_attributes.PrinterUri(uri_attr.values[0].value):
     59        raise errors.ClientErrorBadRequest
    8760   
    8861    # actually get the printer name
     
    9063    # we can't do an exact comparison (also the hostname might be
    9164    # different, depending on the CNAME or whether it's localhost)
    92     uri = uri_value.value.split("/")[-1]
     65    uri = uri_attr.values[0].value.split("/")[-1]
    9366    return uri
    9467
    95 def verify_requesting_username(values):
    96     if len(values) != 1:
    97         raise errors.BadRequest(
    98             "Requesting user name attribute has too many values: %d" % len(values))
    99     requser_value = values[0]
    100     if requser_value.tag != consts.operations_attribute_value_tags['requesting-user-name']:
    101         raise errors.BadRequest(
    102             "Bad value tag (expected NAME_WITHOUT_LANGUAGE): 0x%x" % requser_value.tag)
    103    
    104     return requser_value.value
     68def verify_requesting_username(username_attr):
     69    if username_attr != object_attributes.RequestingUserName(username_attr.values[0].value):
     70        raise errors.ClientErrorBadRequest
     71    return username_attr.values[0].value
    10572
    10673def make_empty_response(request):
    10774    # Operation attributes -- typically the same for any request
    108     attributes = [
    109         Attribute(
    110             'attributes-charset',
    111             [Value(consts.operations_attribute_value_tags['attributes-charset'], 'utf-8')]),
    112         Attribute(
    113             'attributes-natural-language',
    114             [Value(consts.operations_attribute_value_tags['attributes-natural-language'],
    115                    'en-us')])
    116         ]
    117     # Put the operation attributes in a group
    118     attribute_group = AttributeGroup(
     75    attributes = AttributeGroup(
    11976        consts.AttributeTags.OPERATION,
    120         attributes)
     77        [object_attributes.AttributesCharset('utf-8'),
     78         object_attributes.AttributesNaturalLanguage('en-us')])
    12179
    12280    # Set up the default response -- handlers will override these
     
    12684    response_kwargs['operation_id']     = consts.StatusCodes.OK
    12785    response_kwargs['request_id']       = request.request_id
    128     response_kwargs['attribute_groups'] = [attribute_group]
     86    response_kwargs['attribute_groups'] = [attributes]
    12987    response = Request(**response_kwargs)
    13088
     
    13290
    13391def make_job_attributes(attrs, request, response):
    134     ipp_attrs = []
    135     for attr, vals in attrs:
    136         ipp_vals = [Value(
    137             tag=consts.job_attribute_value_tags[attr],
    138             value=val) for val in vals]
    139         ipp_attrs.append(Attribute(name=attr, values=ipp_vals))
    14092    response.attribute_groups.append(AttributeGroup(
    141         consts.AttributeTags.JOB, ipp_attrs))
     93        consts.AttributeTags.JOB, attrs))
    14294
    14395def make_printer_attributes(attrs, request, response):
    144     ipp_attrs = []
    145     for attr, vals in attrs:
    146         ipp_vals = [Value(
    147             tag=consts.printer_attribute_value_tags[attr],
    148             value=val) for val in vals]
    149         ipp_attrs.append(Attribute(name=attr, values=ipp_vals))
    15096    response.attribute_groups.append(AttributeGroup(
    151         consts.AttributeTags.PRINTER, ipp_attrs))
     97        consts.AttributeTags.PRINTER, attrs))
    15298
    15399from cups_get_classes import verify_cups_get_classes_request, make_cups_get_classes_response
  • server/lib/gutenbach/ipp/operations/get_jobs.py

    r5e44432 raded2d1  
    9999    # requested printer uri
    100100    if 'printer-uri' not in attrs:
    101         raise err.BadRequest("Missing 'printer-uri' attribute")
     101        raise err.ClientErrorBadRequest("Missing 'printer-uri' attribute")
    102102    out['printer-uri'] = verify_printer_uri(attrs['printer-uri'])
    103103   
  • server/lib/gutenbach/server/job.py

    r5fe360e raded2d1  
    11from exceptions import InvalidJobException, InvalidPrinterStateException
    22import os
     3import gutenbach.ipp.object_attributes.job_description_attributes as jda
    34
    45# initialize logger
     
    5051    @property
    5152    def job_id(self):
    52         return self.jid
     53        return jda.JobId(self.jid)
    5354
    5455    @property
    5556    def job_name(self):
    56         return self.name
     57        return jda.JobName(self.name)
    5758
    5859    # XXX: we need to actually calculate this!
    5960    @property
    6061    def job_originating_user_name(self):
    61         return "jhamrick"
     62        return jda.JobOriginatingUserName("jhamrick")
    6263
    6364    # XXX: we need to actually calculate this!
    6465    @property
    6566    def job_k_octets(self):
    66         return 1
     67        return jda.JobKOctets(1)
    6768
    6869    @property
    6970    def job_state(self):
    70         return self.status
     71        return jda.JobState(self.status)
    7172
    7273    @property
    7374    def job_printer_uri(self):
    74         return self.printer.uri
     75        return jda.JobPrinterUri(self.printer.uri)
    7576
    7677    def get_job_attributes(self, request):
    77         attributes = [(attr, getattr(self, attr)) for attr in self.attributes]
    78         attributes = map(lambda x: x if isinstance(x, (tuple, list)) else [x], attributes)
     78        attributes = [getattr(self, attr) for attr in self.attributes]
    7979        return attributes
    8080   
  • server/lib/gutenbach/server/printer.py

    rf6e2532 raded2d1  
    44import gutenbach.ipp as ipp
    55import gutenbach.ipp.constants as const
     6import gutenbach.ipp.object_attributes.printer_description_attributes as pda
    67import logging
    78import time
     
    8889    @property
    8990    def printer_uri_supported(self):
    90         return self.uri
     91        return pda.PrinterUriSupported(self.uri)
    9192
    9293    @property
    9394    def uri_authentication_supported(self):
    94         return "none"
     95        return pda.UriAuthenticationSupported("none")
    9596
    9697    @property
    9798    def uri_security_supported(self):
    98         return "none"
     99        return pda.UriSecuritySupported("none")
    99100
    100101    @property
    101102    def printer_name(self):
    102         return self.name
     103        return pda.PrinterName(self.name)
    103104
    104105    @property
    105106    def printer_state(self):
    106         return 3 # idle
     107        return pda.PrinterState(ipp.constants.PrinterStates.IDLE)
    107108
    108109    @property
    109110    def printer_state_reasons(self):
    110         return "none"
     111        return pda.PrinterStateReasons("none")
    111112
    112113    @property
    113114    def ipp_versions_supported(self):
    114         return ("1.0", "1.1")
     115        return pda.IppVersionsSupported("1.0", "1.1")
    115116
    116117    # XXX: We should query ourself for the supported operations
    117118    @property
    118119    def operations_supported(self):
    119         return ipp.Operations.GET_JOBS # get-jobs
     120        return pda.OperationsSupported(ipp.Operations.GET_JOBS)
    120121
    121122    @property
    122123    def charset_configured(self):
    123         return "utf-8"
     124        return pda.CharsetConfigured("utf-8")
    124125
    125126    @property
    126127    def charset_supported(self):
    127         return "utf-8"
     128        return pda.CharsetSupported("utf-8")
    128129
    129130    @property
    130131    def natural_language_configured(self):
    131         return "en-us"
     132        return pda.NaturalLanguageConfigured("en-us")
    132133
    133134    @property
    134135    def generated_natural_language_supported(self):
    135         return "en-us"
     136        return pda.GeneratedNaturalLanguageSupported("en-us")
    136137
    137138    @property
    138139    def document_format_default(self):
    139         return "application/octet-stream"
     140        return pda.DocumentFormatDefault("application/octet-stream")
    140141
    141142    @property
    142143    def document_format_supported(self):
    143         return ("application/octet-stream", "audio/mp3")
     144        return pda.DocumentFormatSupported("application/octet-stream", "audio/mp3")
    144145
    145146    @property
    146147    def printer_is_accepting_jobs(self):
    147         return True
     148        return pda.PrinterIsAcceptingJobs(True)
    148149
    149150    @property
    150151    def queued_job_count(self):
    151         return len(self.active_jobs)
     152        return pda.QueuedJobCount(len(self.active_jobs))
    152153
    153154    @property
    154155    def pdl_override_supported(self):
    155         return "not-attempted"
     156        return pda.PdlOverrideSupported("not-attempted")
    156157
    157158    @property
    158159    def printer_up_time(self):
    159         return int(time.time()) - self.time_created
     160        return pda.PrinterUpTime(int(time.time()) - self.time_created)
    160161
    161162    @property
    162163    def compression_supported(self):
    163         return "none"
     164        return pda.CompressionSupported("none")
    164165
    165166    @property
    166167    def multiple_operation_time_out(self):
    167         return 240
     168        return pda.MultipleOperationTimeOut(240)
    168169
    169170    @property
    170171    def multiple_document_jobs_supported(self):
    171         return False
     172        return pda.MultipleDocumentJobsSupported(False)
    172173
    173174    def get_printer_attributes(self, request):
    174         attributes = [(attr, getattr(self, attr)) for attr in self.attributes]
    175         attributes = map(lambda x: x if isinstance(x[1], (tuple, list)) else (x[0], [x[1]]),
    176                          attributes)
     175        attributes = [getattr(self, attr) for attr in self.attributes]
    177176        return attributes
    178177
  • server/lib/gutenbach/server/requests.py

    r94a4825 raded2d1  
    44import logging
    55import traceback
     6import sys
    67
    78# initialize logger
     
    114115        printer_name = req_dict['printer-uri']
    115116        if printer_name not in self.printers:
    116             raise ipp.errors.Attributes(
     117            raise ipp.errors.ClientErrorAttributes(
    117118                "Invalid printer uri: %s" % printer_name,
    118119                [request.attribute_groups[0].attributes[2]])
     
    240241        printer_name = req_dict['printer-uri']
    241242        if printer_name not in self.printers:
    242             raise ipp.errors.Attributes(
     243            raise ipp.errors.ClientErrorAttributes(
    243244                "Invalid printer uri: %s" % printer_name,
    244245                [request.attribute_groups[0].attributes[2]])
     
    276277        printer_name = req_dict['printer-uri']
    277278        if printer_name not in self.printers:
    278             raise ipp.errors.Attributes(
     279            raise ipp.errors.ClientErrorAttributes(
    279280                "Invalid printer uri: %s" % printer_name,
    280281                [request.attribute_groups[0].attributes[2]])
     
    284285        try: job = self.printers[printer_name].get_job(job_id)
    285286        except InvalidJobException:
    286             raise ipp.errors.Attributes(
     287            raise ipp.errors.ClientErrorAttributes(
    287288                "Invalid job id: %d" % job_id,
    288289                [request.attribute_groups[0].attributes[2]]) # XXX: this is wrong
Note: See TracChangeset for help on using the changeset viewer.