Changeset f6c6897 for server


Ignore:
Timestamp:
Dec 20, 2011, 1:47:11 PM (12 years ago)
Author:
Jessica B. Hamrick <jhamrick@…>
Branches:
no-cups
Children:
6effd50
Parents:
5fe360e
git-author:
Jessica B. Hamrick <jhamrick@…> (12/20/11 13:47:11)
git-committer:
Jessica B. Hamrick <jhamrick@…> (12/20/11 13:47:11)
Message:

Fix some errors in ipp/

Location:
server/lib/gutenbach/ipp
Files:
4 edited

Legend:

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

    r71bfce0 rf6c6897  
    33from request import Request
    44from value import Value
    5 from constants import Tags
     5from constants import Tags, StatusCodes
    66import operations as ops
    77import exceptions as errors
    88
    9 __all__ = ['Attribute', 'AttributeGroup', 'Request', 'Value', 'Tags', 'ops', 'errors']
     9__all__ = ['Attribute', 'AttributeGroup', 'Request', 'Value',
     10           'Tags', 'StatusCodes', 'ops', 'errors']
  • server/lib/gutenbach/ipp/attribute.py

    rd04a689 rf6c6897  
    6666        for value in values:
    6767            assert isinstance(value, Value), \
    68                    "Value %r must be of type Value" % (value)
     68                   "Value %s must be of type Value" % (value,)
    6969
    7070        self.name = name
     
    100100            logger.debug("dumping name : %s" % self.name)
    101101            logger.debug("dumping value_length : %i" % value_length)
    102             logger.debug("dumping value : %s" % v.value)
     102            logger.debug("dumping value (0x%x): %s" % (v.tag, v.value))
    103103
    104104            # the value tag in binary
    105             value_tag_bin = struct.pack('>b', v.value_tag)
     105            tag_bin = struct.pack('>b', v.tag)
    106106
    107107            # the name length in binary
     
    115115
    116116            if i == 0:
    117                 values.append(''.join([value_tag_bin,
     117                values.append(''.join([tag_bin,
    118118                                       name_length_bin,
    119119                                       name_bin,
     
    121121                                       value_bin]))
    122122            else:
    123                 values.append(''.join([value_tag_bin,
     123                values.append(''.join([tag_bin,
    124124                                       name_length_bin,
    125125                                       value_length_bin,
  • server/lib/gutenbach/ipp/exceptions.py

    r5b3a81e rf6c6897  
    2525
    2626class BadRequest(IPPClientException):
    27     ipp_error_code = ErrorCodes.BAD_REQUEST)
     27    ipp_error_code = ErrorCodes.BAD_REQUEST
    2828
    2929class Forbidden(IPPClientException):
    30     ipp_error_code = ErrorCodes.FORBIDDEN)
     30    ipp_error_code = ErrorCodes.FORBIDDEN
    3131
    3232class NotAuthenticated(IPPClientException):
    33     ipp_error_code = ErrorCodes.NOT_AUTHENTICATED)
     33    ipp_error_code = ErrorCodes.NOT_AUTHENTICATED
    3434
    3535class NotAuthorized(IPPClientException):
    36     ipp_error_code = ErrorCodes.NOT_AUTHORIZED)
     36    ipp_error_code = ErrorCodes.NOT_AUTHORIZED
    3737
    3838class NotPossible(IPPClientException):
    39     ipp_error_code = ErrorCodes.NOT_POSSIBLE)
     39    ipp_error_code = ErrorCodes.NOT_POSSIBLE
    4040
    4141class Timeout(IPPClientException):
    42     ipp_error_code = ErrorCodes.TIMEOUT)
     42    ipp_error_code = ErrorCodes.TIMEOUT
    4343
    4444class NotFound(IPPClientException):
    45     ipp_error_code = ErrorCodes.NOT_FOUND)
     45    ipp_error_code = ErrorCodes.NOT_FOUND
    4646
    4747class Gone(IPPClientException):
    48     ipp_error_code = ErrorCodes.GONE)
     48    ipp_error_code = ErrorCodes.GONE
    4949
    5050class RequestEntity(IPPClientException):
    51     ipp_error_code = ErrorCodes.REQUEST_ENTITY)
     51    ipp_error_code = ErrorCodes.REQUEST_ENTITY
    5252
    5353class RequestValue(IPPClientException):
    54     ipp_error_code = ErrorCodes.REQUEST_VALUE)
     54    ipp_error_code = ErrorCodes.REQUEST_VALUE
    5555
    5656class DocumentFormatNotSupported(IPPClientException):
    57     ipp_error_code = ErrorCodes.DOCUMENT_FORMAT)
     57    ipp_error_code = ErrorCodes.DOCUMENT_FORMAT
    5858
    5959class Attributes(IPPClientException):
    60     ipp_error_code = ErrorCodes.ATTRIBUTES)
     60    ipp_error_code = ErrorCodes.ATTRIBUTES
    6161
    6262    def __init__(self, message, attrs):
     
    6868
    6969class UriSchemeNotSupported(IPPClientException):
    70     ipp_error_code = ErrorCodes.URI_SCHEME)
     70    ipp_error_code = ErrorCodes.URI_SCHEME
    7171
    7272class CharsetNotSupported(IPPClientException):
    73     ipp_error_code = ErrorCodes.CHARSET)
     73    ipp_error_code = ErrorCodes.CHARSET
    7474
    7575class Conflict(IPPClientException):
    76     ipp_error_code = ErrorCodes.CONFLICT)
     76    ipp_error_code = ErrorCodes.CONFLICT
    7777
    7878class CompressionNotSupported(IPPClientException):
    79     ipp_error_code = ErrorCodes.COMPRESSION_NOT_SUPPORTED)
     79    ipp_error_code = ErrorCodes.COMPRESSION_NOT_SUPPORTED
    8080
    8181class CompressionError(IPPClientException):
    82     ipp_error_code = ErrorCodes.COMPRESSION_ERROR)
     82    ipp_error_code = ErrorCodes.COMPRESSION_ERROR
    8383
    8484class DocumentFormatError(IPPClientException):
    85     ipp_error_code = ErrorCodes.DOCUMENT_FORMAT_ERROR)
     85    ipp_error_code = ErrorCodes.DOCUMENT_FORMAT_ERROR
    8686
    8787class DocumentAccessError(IPPClientException):
    88     ipp_error_code = ErrorCodes.DOCUMENT_ACCESS_ERROR)
     88    ipp_error_code = ErrorCodes.DOCUMENT_ACCESS_ERROR
    8989
    9090class AttributesNotSettable(IPPClientException):
    91     ipp_error_code = ErrorCodes.ATTRIBUTES_NOT_SETTABLE)
     91    ipp_error_code = ErrorCodes.ATTRIBUTES_NOT_SETTABLE
    9292
    9393class IgnoredAllSubscriptions(IPPClientException):
    94     ipp_error_code = ErrorCodes.IGNORED_ALL_SUBSCRIPTIONS)
     94    ipp_error_code = ErrorCodes.IGNORED_ALL_SUBSCRIPTIONS
    9595
    9696class TooManySubscriptions(IPPClientException):
    97     ipp_error_code = ErrorCodes.TOO_MANY_SUBSCRIPTIONS)
     97    ipp_error_code = ErrorCodes.TOO_MANY_SUBSCRIPTIONS
    9898
    9999class IgnoredAllNotifications(IPPClientException):
    100     ipp_error_code = ErrorCodes.IGNORED_ALL_NOTIFICATIONS)
     100    ipp_error_code = ErrorCodes.IGNORED_ALL_NOTIFICATIONS
    101101
    102102class PrintSupportFileNotFound(IPPClientException):
    103     ipp_error_code = ErrorCodes.PRINT_SUPPORT_FILE_NOT_FOUND)
     103    ipp_error_code = ErrorCodes.PRINT_SUPPORT_FILE_NOT_FOUND
    104104
    105105### Server error codes
    106106
    107107class InternalError(IPPServerException):
    108     ipp_error_code = ErrorCodes.INTERNAL_ERROR)
     108    ipp_error_code = ErrorCodes.INTERNAL_ERROR
    109109
    110110class OperationNotSupported(IPPServerException):
    111     ipp_error_code = ErrorCodes.OPERATION_NOT_SUPPORTED)
     111    ipp_error_code = ErrorCodes.OPERATION_NOT_SUPPORTED
    112112
    113113class ServiceUnavailable(IPPServerException):
    114     ipp_error_code = ErrorCodes.SERVICE_UNAVAILABLE)
     114    ipp_error_code = ErrorCodes.SERVICE_UNAVAILABLE
    115115
    116116class VersionNotSupported(IPPServerException):
    117     ipp_error_code = ErrorCodes.VERSION_NOT_SUPPORTED)
     117    ipp_error_code = ErrorCodes.VERSION_NOT_SUPPORTED
    118118
    119119class DeviceError(IPPServerException):
    120     ipp_error_code = ErrorCodes.DEVICE_ERROR)
     120    ipp_error_code = ErrorCodes.DEVICE_ERROR
    121121
    122122class TemporaryError(IPPServerException):
    123     ipp_error_code = ErrorCodes.TEMPORARY_ERROR)
     123    ipp_error_code = ErrorCodes.TEMPORARY_ERROR
    124124
    125125class NotAccepting(IPPServerException):
    126     ipp_error_code = ErrorCodes.NOT_ACCEPTING)
     126    ipp_error_code = ErrorCodes.NOT_ACCEPTING
    127127
    128128class PrinterBusy(IPPServerException):
    129     ipp_error_code = ErrorCodes.PRINTER_BUSY)
     129    ipp_error_code = ErrorCodes.PRINTER_BUSY
    130130
    131131class ErrorJobCancelled(IPPServerException):
    132     ipp_error_code = ErrorCodes.ERROR_JOB_CANCELLED)
     132    ipp_error_code = ErrorCodes.ERROR_JOB_CANCELLED
    133133
    134134class MultipleJobsNotSupported(IPPServerException):
    135     ipp_error_code = ErrorCodes.MULTIPLE_JOBS_NOT_SUPPORTED)
     135    ipp_error_code = ErrorCodes.MULTIPLE_JOBS_NOT_SUPPORTED
    136136
    137137class PrinterIsDeactivated(IPPServerException):
    138     ipp_error_code = ErrorCodes.PRINTER_IS_DEACTIVATED)
     138    ipp_error_code = ErrorCodes.PRINTER_IS_DEACTIVATED
  • server/lib/gutenbach/ipp/operations.py

    r71bfce0 rf6c6897  
    33from .attributegroup import AttributeGroup
    44from .request import Request
    5 from .constants import AttributeTags, operations_attribute_value_tags
     5from .constants import AttributeTags, StatusCodes, operations_attribute_value_tags
    66import exceptions as err
    7 
    8 from collections import OrderedDictionary as odict
    97
    108def verify_operations(request):
     
    4341
    4442    # check charset
    45     charset attribute
    4643    charset_attr = op_attrs.attributes[0]
    4744    if charset_attr.name != 'attributes-charset':
     
    7370    if natlang_value.tag != operations_attribute_value_tags['attributes-natural-language']:
    7471        raise err.BadRequest(
    75             "Natural language value does not have NATURAL_LANGUAGE tag: 0x%x" natlang_value.tag)
     72            "Natural language value does not have NATURAL_LANGUAGE tag: 0x%x" % natlang_value.tag)
    7673    if natlang_value.value != 'en-us':
    7774        raise err.Attributes(
     
    115112    # Operation attributes -- typically the same for any request
    116113    attributes = [
    117         ipp.Attribute(
     114        Attribute(
    118115            'attributes-charset',
    119             [(operations_attribute_value_tags['attributes-charset'], 'utf-8')]),
    120         ipp.Attribute(
     116            [Value(operations_attribute_value_tags['attributes-charset'], 'utf-8')]),
     117        Attribute(
    121118            'attributes-natural-language',
    122             [(operations_attribute_value_tags['attributes-natural-language'], 'en-us')])
     119            [Value(operations_attribute_value_tags['attributes-natural-language'], 'en-us')])
    123120        ]
    124121    # Put the operation attributes in a group
    125     attribute_group = ipp.AttributeGroup(
    126         const.AttributeTags.OPERATION,
     122    attribute_group = AttributeGroup(
     123        AttributeTags.OPERATION,
    127124        attributes)
    128125
     
    131128    response_kwargs = {}
    132129    response_kwargs['version']          = request.version
    133     response_kwargs['operation_id']     = const.StatusCodes.OK
     130    response_kwargs['operation_id']     = StatusCodes.OK
    134131    response_kwargs['request_id']       = request.request_id
    135132    response_kwargs['attribute_groups'] = [attribute_group]
    136     response = ipp.Request(**response_kwargs)
     133    response = Request(**response_kwargs)
    137134
    138135    return response
     
    168165            if 'which-jobs' or 'my-jobs' constrain which jobs are
    169166            returned. The limit is a 'stateless limit' in that if
    170             the value supplied by the client is ’N’, then only the
    171             first ’N’ jobs are returned in the Get-Jobs Response.
    172             There is no mechanism to allow for the next ’M’ jobs
    173             after the first ’N’ jobs. If the client does not
     167            the value supplied by the client is 'N', then only the
     168            first 'N' jobs are returned in the Get-Jobs Response.
     169            There is no mechanism to allow for the next 'M' jobs
     170            after the first 'N' jobs. If the client does not
    174171            supply this attribute, the Printer object responds
    175172            with all applicable jobs.
     
    185182            the client does not supply this attribute, the Printer
    186183            MUST respond as if the client had supplied this
    187             attribute with two values: ’job-uri’ and ’job-id’.
     184            attribute with two values: 'job-uri' and 'job-id'.
    188185        'which-jobs' (type2 keyword):
    189186            The client OPTIONALLY supplies this attribute. The
     
    191188            indicates which Job objects MUST be returned by the
    192189            Printer object. The values for this attribute are:
    193              - ’completed’: This includes any Job object whose
    194                state is ’completed’, ’canceled’, or ’aborted’.
    195              - ’not-completed’: This includes any Job object whose
    196                state is ’pending’, ’processing’,
    197                ’processing-stopped’, or ’pending-held’.
     190             - 'completed': This includes any Job object whose
     191               state is 'completed', 'canceled', or 'aborted'.
     192             - 'not-completed': This includes any Job object whose
     193               state is 'pending', 'processing',
     194               'processing-stopped', or 'pending-held'.
    198195            A Printer object MUST support both values. However, if
    199196            the implementation does not keep jobs in the
    200             ’completed’, ’canceled’, and ’aborted’ states, then it
    201             returns no jobs when the ’completed’ value is
     197            'completed', 'canceled', and 'aborted' states, then it
     198            returns no jobs when the 'completed' value is
    202199            supplied.  If a client supplies some other value, the
    203200            Printer object MUST copy the attribute and the
    204201            unsupported value to the Unsupported Attributes
    205202            response group, reject the request, and return the
    206             ’client-error-attributes-or-values-not-supported’
     203            'client-error-attributes-or-values-not-supported'
    207204            status code.  If the client does not supply this
    208205            attribute, the Printer object MUST respond as if the
    209206            client had supplied the attribute with a value of
    210             ’not-completed’.
     207            'not-completed'.
    211208        'my-jobs' (boolean):
    212209            The client OPTIONALLY supplies this attribute. The
     
    218215            attribute, the Printer object MUST respond as if the
    219216            client had supplied the attribute with a value of
    220             ’false’, i.e., jobs from all users. The means for
     217            'false', i.e., jobs from all users. The means for
    221218            authenticating the requesting user and matching the
    222219            jobs is described in section 8.
     
    268265    response returns 0 jobs because there are no jobs matching the
    269266    criteria, and the request would have returned 1 or more jobs
    270     with a status code of ’successful-ok’ if there had been jobs
     267    with a status code of 'successful-ok' if there had been jobs
    271268    matching the criteria, then the status code for 0 jobs MUST be
    272     ’successful-ok’.
     269    'successful-ok'.
    273270
    274271    Group 1: Operation Attributes
     
    293290        referenced in the 'requested-attributes' operation
    294291        attribute and that attribute included group names, such as
    295         ’all’, the unsupported attributes MUST NOT include
     292        'all', the unsupported attributes MUST NOT include
    296293        attributes described in the standard but not supported by
    297294        the implementation.
     
    306303        job (job originating user) or not (see section
    307304        8). However, the Printer object MUST respond with the
    308         ’unknown’ value for any supported attribute (including all
     305        'unknown' value for any supported attribute (including all
    309306        REQUIRED attributes) for which the Printer object does not
    310307        know the value, unless it would violate the security
     
    313310
    314311        Jobs are returned in the following order:
    315         - If the client requests all ’completed’ Jobs (Jobs in the
    316           ’completed’, ’aborted’, or ’canceled’ states), then the
     312        - If the client requests all 'completed' Jobs (Jobs in the
     313          'completed', 'aborted', or 'canceled' states), then the
    317314          Jobs are returned newest to oldest (with respect to
    318315          actual completion time)
    319         - If the client requests all ’not-completed’ Jobs (Jobs in
    320           the ’pending’, ’processing’, ’pending-held’, and
    321           ’processing- stopped’ states), then Jobs are returned in
     316        - If the client requests all 'not-completed' Jobs (Jobs in
     317          the 'pending', 'processing', 'pending-held', and
     318          'processing- stopped' states), then Jobs are returned in
    322319          relative chronological order of expected time to
    323320          complete (based on whatever scheduling algorithm is
Note: See TracChangeset for help on using the changeset viewer.