Changeset b828a96


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

Use classes for standard IPP attributes

Location:
server/lib/gutenbach
Files:
11 edited

Legend:

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

    raded2d1 rb828a96  
    1818__all__.extend(constants.__all__)
    1919
    20 import exceptions as errors
     20import errors
    2121__all__.append('errors')
    2222
  • server/lib/gutenbach/ipp/attribute.py

    rcad7502 rb828a96  
    7070        self.name = name
    7171        self.values = values
     72
     73    def __cmp__(self, other):
     74        eq = self.name == other.name
     75        for v1, v2 in zip(self.values, other.values):
     76            eq = eq and (v1 == v2)
     77        return 0 if eq else 1
    7278
    7379    @property
  • server/lib/gutenbach/ipp/attributegroup.py

    rb2e077a rb828a96  
    4040        self.attributes = []
    4141        self.extend(attributes)
     42
     43    def __cmp__(self, other):
     44        eq = self.tag == other.tag
     45        for a1, a2 in zip(self.attributes, other.attributes):
     46            eq = eq and (a1 == a2)
     47        return 0 if eq else 1
    4248
    4349    def __getitem__(self, name):
  • server/lib/gutenbach/ipp/object_attributes/__init__.py

    raded2d1 rb828a96  
    22from job_description_attributes import *
    33from printer_description_attributes import *
     4from operation_attributes import *
    45
    56__all__ = ['job_template_attributes',
    67           'job_description_attributes',
    7            'printer_description_attributes']
     8           'printer_description_attributes',
     9           'operation_attributes']
    810__all__.extend(job_template_attributes.__all__)
    911__all__.extend(job_description_attributes.__all__)
    1012__all__.extend(printer_description_attributes.__all__)
     13__all__.extend(operation_attributes.__all__)
  • server/lib/gutenbach/ipp/object_attributes/job_description_attributes.py

    raded2d1 rb828a96  
    3737from ..constants import *
    3838
    39 class JobUri(Attribute):
     39def JobUri(val):
    4040    """4.3.1 job-uri (uri)
    4141
     
    6161    """
    6262
    63     def __init__(self, val):
    64         super(type(self), self).__init__(
    65             'job-uri',
    66             [Value(CharacterStringTags.URI, val)])
    67 
    68 class JobId(Attribute):
     63    return Attribute(
     64        'job-uri',
     65        [Value(CharacterStringTags.URI, val)])
     66
     67def JobId(val):
    6968    """4.3.2 job-id (integer(1:MAX))
    7069
     
    8281    """
    8382   
    84     def __init__(self, val):
    85         super(type(self), self).__init__(
    86             'job-id',
    87             [Value(IntegerTags.INTEGER, val)])
    88 
    89 class JobPrinterUri(Attribute):
     83    return Attribute(
     84        'job-id',
     85        [Value(IntegerTags.INTEGER, val)])
     86
     87def JobPrinterUri(val):
    9088    """4.3.3 job-printer-uri (uri)
    9189
     
    105103    """
    106104
    107     def __init__(self, val):
    108         super(type(self), self).__init__(
    109             'job-printer-uri',
    110             [Value(CharacterStringTags.URI, val)])
    111 
    112 class JobMoreInfo(Attribute):
     105    return Attribute(
     106        'job-printer-uri',
     107        [Value(CharacterStringTags.URI, val)])
     108
     109def JobMoreInfo(val):
    113110    """4.3.4 job-more-info (uri)
    114111
    115112    """
    116113
    117     def __init__(self, val):
    118         raise ClientErrorAttributes, "job-more-info"
    119 
    120 class JobName(Attribute):
     114    raise ClientErrorAttributes, "job-more-info"
     115
     116def JobName(val):
    121117    """4.3.5 job-name (name(MAX))
    122118   
     
    138134    """
    139135   
    140     def __init__(self, val):
    141         super(type(self), self).__init__(
    142             'job-name',
    143             [Value(CharacterStringTags.NAME_WITHOUT_LANGUAGE, val)])
    144 
    145 class JobOriginatingUserName(Attribute):
     136    return Attribute(
     137        'job-name',
     138        [Value(CharacterStringTags.NAME_WITHOUT_LANGUAGE, val)])
     139
     140def JobOriginatingUserName(val):
    146141    """4.3.6 job-originating-user-name (name(MAX))
    147142
     
    163158    """
    164159   
    165     def __init__(self, val):
    166         super(type(self), self).__init__(
    167             'job-originating-user-name',
    168             [Value(CharacterStringTags.NAME_WITHOUT_LANGUAGE, val)])
    169 
    170 class JobState(Attribute):
     160    return Attribute(
     161        'job-originating-user-name',
     162        [Value(CharacterStringTags.NAME_WITHOUT_LANGUAGE, val)])
     163
     164def JobState(val):
    171165    """4.3.7 job-state (type1 enum)
    172166
     
    181175    """
    182176   
    183     def __init__(self, val):
    184         super(type(self), self).__init__(
    185             'job-state',
    186             [Value(IntegerTags.ENUM, val)])
    187 
    188 class JobStateReasons(Attribute):
     177    return Attribute(
     178        'job-state',
     179        [Value(IntegerTags.ENUM, val)])
     180
     181def JobStateReasons(val):
    189182    """4.3.8 job-state-reasons (1setOf type2 keyword)
    190183
     
    212205    """
    213206
    214     def __init__(self, *vals):
    215         super(type(self), self).__init__(
    216             'job-state-reasons',
    217             [Value(CharacterStringTags.KEYWORD, val) for val in vals])
    218 
    219 class JobStateMessage(Attribute):
     207    return Attribute(
     208        'job-state-reasons',
     209        [Value(CharacterStringTags.KEYWORD, val) for val in vals])
     210
     211def JobStateMessage(val):
    220212    """4.3.9 job-state-message (text(MAX))
    221213
    222214    """
    223215
    224     def __init__(self, val):
    225         raise ClientErrorAttributes, "job-state-message"
    226 
    227 class JobDetailedStatusMessages(Attribute):
     216    raise ClientErrorAttributes, "job-state-message"
     217
     218def JobDetailedStatusMessages(val):
    228219    """4.3.10 job-detailed-status-messages (1setOf text(MAX))
    229220
    230221    """
    231222
    232     def __init__(self, *vals):
    233         raise ClientErrorAttributes, "job-detailed-status-messages"
    234 
    235 class JobDocumentAccessErrors(Attribute):
     223    raise ClientErrorAttributes, "job-detailed-status-messages"
     224
     225def JobDocumentAccessErrors(val):
    236226    """4.3.11 job-document-access-errors (1setOf text(MAX))
    237227
    238228    """
    239229
    240     def __init__(self, *vals):
    241         raise ClientErrorAttributes, "job-document-access-errors"
    242 
    243 class NumberOfDocuments(Attribute):
     230    raise ClientErrorAttributes, "job-document-access-errors"
     231
     232def NumberOfDocuments(val):
    244233    """4.3.12 number-of-documents (integer(0:MAX))
    245234
    246235    """
    247236
    248     def __init__(self, val):
    249         raise ClientErrorAttributes, "number-of-documents"
    250 
    251 class OutputDeviceAssigned(Attribute):
     237    raise ClientErrorAttributes, "number-of-documents"
     238
     239def OutputDeviceAssigned(val):
    252240    """4.3.13 output-device-assigned (name(127))
    253241
    254242    """
    255243
    256     def __init__(self, val):
    257         raise ClientErrorAttributes, "output-device-assigned"
    258 
    259 class TimeAtCreation(Attribute):
     244    raise ClientErrorAttributes, "output-device-assigned"
     245
     246def TimeAtCreation(val):
    260247    """4.3.14.1 time-at-creation (integer(MIN:MAX))
    261248
     
    265252    """
    266253   
    267     def __init__(self, val):
    268         super(type(self), self).__init__(
    269             "time-at-creation",
    270             [Value(IntegerTags.INTEGER, val)])
    271 
    272 class TimeAtProcessing(Attribute):
     254    return Attribute(
     255        "time-at-creation",
     256        [Value(IntegerTags.INTEGER, val)])
     257
     258def TimeAtProcessing(val):
    273259    """4.3.14.2 time-at-processing (integer(MIN:MAX))
    274260
     
    281267    """
    282268
    283     def __init__(self, val):
    284         super(type(self), self).__init__(
    285             "time-at-processing",
    286             [Value(IntegerTags.INTEGER, val)])
    287 
    288 class TimeAtCompleted(Attribute):
     269    return Attribute(
     270        "time-at-processing",
     271        [Value(IntegerTags.INTEGER, val)])
     272
     273def TimeAtCompleted(val):
    289274    """4.3.14.3 time-at-completed (integer(MIN:MAX))
    290275
     
    296281    """
    297282
    298     def __init__(self, val):
    299         super(type(self), self).__init__(
    300             "time-at-completed",
    301             [Value(IntegerTags.INTEGER, val)])
    302 
    303 class JobPrinterUpTime(Attribute):
     283    return Attribute(
     284        "time-at-completed",
     285        [Value(IntegerTags.INTEGER, val)])
     286
     287def JobPrinterUpTime(val):
    304288    """4.3.14.4 job-printer-up-time (integer(1:MAX))
    305289
     
    321305    """
    322306
    323     def __init__(self, val):
    324         super(type(self), self).__init__(
    325             "job-printer-up-time",
    326             [Value(IntegerTags.INTEGER, val)])
    327 
    328 
    329 class DateTimeAtCreation(Attribute):
     307    return Attribute(
     308        "job-printer-up-time",
     309        [Value(IntegerTags.INTEGER, val)])
     310
     311
     312def DateTimeAtCreation(val):
    330313    """4.3.14.5 date-time-at-creation (dateTime)
    331314
    332315    """
    333316
    334     def __init__(self, val):
    335         raise ClientErrorAttributes, "date-time-at-creation"
    336 
    337 class DateTimeAtProcessing(Attribute):
     317    raise ClientErrorAttributes, "date-time-at-creation"
     318
     319def DateTimeAtProcessing(val):
    338320    """4.3.14.6 date-time-at-processing (dateTime)
    339321
    340322    """
    341323
    342     def __init__(self, val):
    343         raise ClientErrorAttributes, "date-time-at-processing"
    344 
    345 class DateTimeAtCompletion(Attribute):
     324    raise ClientErrorAttributes, "date-time-at-processing"
     325
     326def DateTimeAtCompletion(val):
    346327    """4.3.14.7 date-time-at-completed (dateTime)
    347328
    348329    """
    349330
    350     def __init__(self, val):
    351         raise ClientErrorAttributes, "date-time-at-completion"
    352 
    353 class NumberOfInterveningJobs(Attribute):
     331    raise ClientErrorAttributes, "date-time-at-completion"
     332
     333def NumberOfInterveningJobs(val):
    354334    """4.3.15 number-of-intervening-jobs (integer(0:MAX))
    355335
    356336    """
    357337
    358     def __init__(self, val):
    359         raise ClientErrorAttributes, "number-of-intervening-jobs"
    360 
    361 class JobMessageFromOperator(Attribute):
     338    raise ClientErrorAttributes, "number-of-intervening-jobs"
     339
     340def JobMessageFromOperator(val):
    362341    """4.3.16 job-message-from-operator (text(127))
    363342
    364343    """
    365344
    366     def __init__(self, val):
    367         raise ClientErrorAttributes, "job-message-from-operator"
    368 
    369 class JobKOctets(Attribute):
     345    raise ClientErrorAttributes, "job-message-from-operator"
     346
     347def JobKOctets(val):
    370348    """4.3.17.1 job-k-octets (integer(0:MAX))
    371349
     
    392370    """
    393371   
    394     def __init__(self, val):
    395         super(type(self), self).__init__(
    396             'job-k-octets',
    397             [Value(IntegerTags.INTEGER, val)])
    398 
    399 class JobImpressions(Attribute):
     372    return Attribute(
     373        'job-k-octets',
     374        [Value(IntegerTags.INTEGER, val)])
     375
     376def JobImpressions(val):
    400377    """4.3.17.2 job-impressions (integer(0:MAX))
    401378
    402379    """
    403380
    404     def __init__(self, val):
    405         raise ClientErrorAttributes, "job-impressions"
    406 
    407 class JobMediaSheets(Attribute):
     381    raise ClientErrorAttributes, "job-impressions"
     382
     383def JobMediaSheets(val):
    408384    """4.3.17.3 job-media-sheets (integer(0:MAX))
    409385
    410386    """
    411387
    412     def __init__(self, val):
    413         raise ClientErrorAttributes, "job-media-sheets"
    414 
    415 class JobKOctetsProcessed(Attribute):
     388    raise ClientErrorAttributes, "job-media-sheets"
     389
     390def JobKOctetsProcessed(val):
    416391    """4.3.18.1 job-k-octets-processed (integer(0:MAX))
    417392
    418393    """
    419394
    420     def __init__(self, val):
    421         raise ClientErrorAttributes, "job-k-octets-processed"
    422 
    423 class JobImpressionsCompleted(Attribute):
     395    raise ClientErrorAttributes, "job-k-octets-processed"
     396
     397def JobImpressionsCompleted(val):
    424398    """4.3.18.2 job-impressions-completed (integer(0:MAX))
    425399
    426400    """
    427401
    428     def __init__(self, val):
    429         raise ClientErrorAttributes, "job-impressions-completed"
    430 
    431 class JobMediaSheetsCompleted(Attribute):
     402    raise ClientErrorAttributes, "job-impressions-completed"
     403
     404def JobMediaSheetsCompleted(val):
    432405    """4.3.18.3 job-media-sheets-completed (integer(0:MAX))
    433406
    434407    """
    435408
    436     def __init__(self, val):
    437         raise ClientErrorAttributes, "job-media-sheets-completed"
    438 
    439 class AttributesCharset(Attribute):
     409    raise ClientErrorAttributes, "job-media-sheets-completed"
     410
     411def AttributesCharset(val):
    440412    """4.3.19 attributes-charset (charset)
    441413
     
    456428    """
    457429   
    458     def __init__(self, val):
    459         super(type(self), self).__init__(
    460             'attributes-charset',
    461             [Value(CharacterStringTags.CHARSET, val)])
    462 
    463 class AttributesNaturalLanguage(Attribute):
     430    return Attribute(
     431        'attributes-charset',
     432        [Value(CharacterStringTags.CHARSET, val)])
     433
     434def AttributesNaturalLanguage(val):
    464435    """4.3.20 attributes-natural-language (naturalLanguage)
    465436
     
    477448    """
    478449   
    479     def __init__(self, val):
    480         super(type(self), self).__init__(
    481             'attributes-natural-language',
    482             [Value(CharacterStringTags.NATURAL_LANGUAGE, val)])
     450    return Attribute(
     451        'attributes-natural-language',
     452        [Value(CharacterStringTags.NATURAL_LANGUAGE, val)])
  • server/lib/gutenbach/ipp/object_attributes/job_template_attributes.py

    raded2d1 rb828a96  
    1919from ..exceptions import ClientErrorAttributes
    2020
    21 class JobPriority(Attribute):
     21def JobPriority(val):
    2222    """4.2.1 job-priority (integer(1:100))
    2323
     
    6969   
    7070   
    71     def __init__(self, val):
    72         super(type(self), self).__init__(
    73             'job-priority',
    74             [Value(IntegerTags.INTEGER), val])
     71    return Attribute(
     72        'job-priority',
     73        [Value(IntegerTags.INTEGER), val])
    7574
    76 class JobHoldUntil(Attribute):
     75def JobHoldUntil(val):
    7776    """4.2.2 job-hold-until (type3 keyword | name (MAX))
    7877   
    7978    """
    8079
    81     def __init__(self, val):
    82         raise ClientErrorAttributes, "job-hold-until"
    83 
    84 class JobSheets(Attribute):
     80    raise ClientErrorAttributes, "job-hold-until"
     81   
     82def JobSheets(val):
    8583    """4.2.3 job-sheets (type3 keyword | name(MAX))
    8684
    8785    """
     86   
     87    raise ClientErrorAttributes, "job-sheets"
    8888
    89     def __init__(self, val):
    90         raise ClientErrorAttributes, "job-sheets"
    91 
    92 class MultipleDocumentHandling(Attribute):
     89def MultipleDocumentHandling(val):
    9390    """4.2.4 multiple-document-handling (type2 keyword)
    9491
    9592    """
    9693
    97     def __init__(self, val):
    98         raise ClientErrorAttributes, "multiple-document-handling"
     94    raise ClientErrorAttributes, "multiple-document-handling"
    9995
    100 class Copies(Attribute):
     96def Copies(val):
    10197    """4.2.5 copies (integer(1:MAX))
    10298
    10399    """
     100   
     101    raise ClientErrorAttributes, "copies"
    104102
    105     def __init__(self, val):
    106         raise ClientErrorAttributes, "copies"
    107 
    108 class Finishings(Attribute):
     103def Finishings(*vals):
    109104    """4.2.6 finishings (1setOf type2 enum)
    110105
    111106    """
    112107
    113     def __init__(self, *vals):
    114         raise ClientErrorAttributes, "finishings"
     108    raise ClientErrorAttributes, "finishings"
    115109
    116 class PageRanges(Attribute):
     110def PageRanges(*vals):
    117111    """4.2.7 page-ranges (1setOf rangeOfInteger (1:MAX))
    118112
    119113    """
    120114
    121     def __init__(self, *vals):
    122         raise ClientErrorAttributes, "page-ranges"
     115    raise ClientErrorAttributes, "page-ranges"
    123116
    124 class Sides(Attribute):
     117def Sides(val):
    125118    """4.2.8 sides (type2 keyword)
    126119
    127120    """
    128121
    129     def __init__(self, val):
    130         raise ClientErrorAttributes, "sides"
     122    raise ClientErrorAttributes, "sides"
    131123
    132 class NumberUp(Attribute):
     124def NumberUp(val):
    133125    """4.2.9 number-up (integer(1:MAX))
    134126
    135127    """
    136128
    137     def __init__(self, val):
    138         raise ClientErrorAttributes, "number-up"
     129    raise ClientErrorAttributes, "number-up"
    139130
    140 class OrientationRequested(Attribute):
     131def OrientationRequested(val):
    141132    """4.2.10 orientation-requested (type2 enum)
    142133
    143134    """
    144135
    145     def __init__(self, val):
    146         raise ClientErrorAttributes, "orientation-requested"
     136    raise ClientErrorAttributes, "orientation-requested"
    147137
    148 class Media(Attribute):
     138def Media(val):
    149139    """4.2.11 media (type3 keyword | name(MAX))
    150140
    151141    """
    152142
    153     def __init__(self, val):
    154         raise ClientErrorAttributes, "media"
     143    raise ClientErrorAttributes, "media"
    155144
    156145### XXX: we may want to repurpose this for bitrate?
    157 class PrinterResolution(Attribute):
     146def PrinterResolution(val):
    158147    """4.2.12 printer-resolution (resolution)
    159148
    160149    """
    161150
    162     def __init__(self, val):
    163         raise ClientErrorAttributes, "printer-resolution"
     151    raise ClientErrorAttributes, "printer-resolution"
    164152
    165 class PrintQuality(Attribute):
     153def PrintQuality(val):
    166154    """4.2.13 print-quality (type2 enum)
    167155
    168156    """
    169157
    170     def __init__(self, val):
    171         raise ClientErrorAttributes, "print-quality"
     158    raise ClientErrorAttributes, "print-quality"
  • server/lib/gutenbach/ipp/object_attributes/operation_attributes.py

    raded2d1 rb828a96  
    99from ..constants import *
    1010
    11 class PrinterUri(Attribute):
    12     def __init__(self, val):
    13         super(type(self), self).__init__(
    14             'printer-uri',
    15             [Value(CharacterStringTags.URI, val)])
     11def PrinterUri(val):
     12    return Attribute(
     13        'printer-uri',
     14        [Value(CharacterStringTags.URI, val)])
    1615
    17 class RequestingUserName(Attribute):
    18     def __init__(self, val):
    19         super(type(self), self).__init__(
    20             'requesting-user-name',
    21             [Value(CharacterStringTags.NAME_WITHOUT_LANGUAGE, val)])
     16def RequestingUserName(val):
     17    return Attribute(
     18        'requesting-user-name',
     19        [Value(CharacterStringTags.NAME_WITHOUT_LANGUAGE, val)])
  • server/lib/gutenbach/ipp/object_attributes/printer_description_attributes.py

    raded2d1 rb828a96  
    4444from ..constants import *
    4545
    46 class PrinterUriSupported(Attribute):
     46def PrinterUriSupported(*vals):
    4747    """4.4.1 printer-uri-supported (1setOf uri)
    4848
     
    6363    """
    6464   
    65     def __init__(self, *vals):
    66         super(type(self), self).__init__(
    67             'printer-uri-supported',
    68             [Value(CharacterStringTags.URI, val) for val in vals])
    69 
    70 
    71 class UriAuthenticationSupported(Attribute):
     65    return Attribute(
     66        'printer-uri-supported',
     67        [Value(CharacterStringTags.URI, val) for val in vals])
     68
     69
     70def UriAuthenticationSupported(*vals):
    7271    """4.4.2 uri-authentication-supported (1setOf type2 keyword)
    7372
     
    8685    """
    8786   
    88     def __init__(self, val):
    89         super(type(self), self).__init__(
    90             'uri-authentication-supported',
    91             [Value(CharacterStringTags.KEYWORD, val)])
    92 
    93 class UriSecuritySupported(Attribute):
     87    return Attribute(
     88        'uri-authentication-supported',
     89        [Value(CharacterStringTags.KEYWORD, val) for val in vals])
     90
     91def UriSecuritySupported(*vals):
    9492    """4.4.3 uri-security-supported (1setOf type2 keyword)
    9593
     
    117115    """
    118116   
    119     def __init__(self, val):
    120         super(type(self), self).__init__(
    121             'uri-security-supported',
    122             [Value(CharacterStringTags.KEYWORD, val)])
    123 
    124 class PrinterName(Attribute):
     117    return Attribute(
     118        'uri-security-supported',
     119        [Value(CharacterStringTags.KEYWORD, val) for val in vals])
     120
     121def PrinterName(val):
    125122    """4.4.4 printer-name (name(127))
    126123
     
    134131    """
    135132   
    136     def __init__(self, val):
    137         super(type(self), self).__init__(
    138             'printer-name',
    139             [Value(CharacterStringTags.NAME_WITHOUT_LANGUAGE, val)])
    140 
    141 class PrinterLocation(Attribute):
     133    return Attribute(
     134        'printer-name',
     135        [Value(CharacterStringTags.NAME_WITHOUT_LANGUAGE, val)])
     136
     137def PrinterLocation(val):
    142138    """4.4.5 printer-location (text(127))
    143139
    144140    """
    145141
    146     def __init__(self, val):
    147         raise ClientErrorAttributes, "printer-location"
    148 
    149 class PrinterInfo(Attribute):
     142    raise ClientErrorAttributes, "printer-location"
     143
     144def PrinterInfo(val):
    150145    """4.4.6 printer-info (text(127))
    151146
    152147    """
    153148
    154     def __init__(self, val):
    155         raise ClientErrorAttributes, "printer-info"
    156 
    157 class PrinterMoreInfo(Attribute):
     149    raise ClientErrorAttributes, "printer-info"
     150
     151def PrinterMoreInfo(val):
    158152    """4.4.7 printer-more-info (uri)
    159153
    160154    """
    161155
    162     def __init__(self, val):
    163         raise ClientErrorAttributes, "printer-more-info"
    164 
    165 class PrinterDriverInstaller(Attribute):
     156    raise ClientErrorAttributes, "printer-more-info"
     157
     158def PrinterDriverInstaller(val):
    166159    """4.4.8 printer-driver-installer (uri)
    167160
    168161    """
    169162
    170     def __init__(self, val):
    171         raise ClientErrorAttributes, "printer-driver-installer"
    172 
    173 class PrinterMakeAndModel(Attribute):
     163    raise ClientErrorAttributes, "printer-driver-installer"
     164
     165def PrinterMakeAndModel(val):
    174166    """4.4.9 printer-make-and-model (text(127))
    175167
    176168    """
    177169
    178     def __init__(self, val):
    179         raise ClientErrorAttributes, "printer-make-and-model"
    180 
    181 class PrinterMoreInfoManufacturer(Attribute):
     170    raise ClientErrorAttributes, "printer-make-and-model"
     171
     172def PrinterMoreInfoManufacturer(val):
    182173    """4.4.10 printer-more-info-manufacturer (uri)
    183174
    184175    """
    185176
    186     def __init__(self, val):
    187         raise ClientErrorAttributes, "printer-more-info-manufacturer"
    188 
    189 class PrinterState(Attribute):
     177    raise ClientErrorAttributes, "printer-more-info-manufacturer"
     178
     179def PrinterState(val):
    190180    """4.4.11 printer-state (type1 enum)
    191181
     
    203193    """
    204194   
    205     def __init__(self, val):
    206         super(type(self), self).__init__(
    207             'printer-state',
    208             [Value(IntegerTags.ENUM, val)])
    209 
    210 class PrinterStateReasons(Attribute):
     195    return Attribute(
     196        'printer-state',
     197        [Value(IntegerTags.ENUM, val)])
     198
     199def PrinterStateReasons(*vals):
    211200    """4.4.12 printer-state-reasons (1setOf type2 keyword)
    212201
     
    221210    """
    222211   
    223     def __init__(self, val):
    224         super(type(self), self).__init__(
    225             'printer-state-reasons',
    226             [Value(CharacterStringTags.KEYWORD, val)])
    227 
    228 class PrinterStateMessage(Attribute):
     212    return Attribute(
     213        'printer-state-reasons',
     214        [Value(CharacterStringTags.KEYWORD, val) for val in vals])
     215
     216def PrinterStateMessage(val):
    229217    """4.4.13 printer-state-message (text(MAX))
    230218
    231219    """
    232220
    233     def __init__(self, val):
    234         raise ClientErrorAttributes, "printer-state-message"
    235 
    236 class IppVersionsSupported(Attribute):
     221    raise ClientErrorAttributes, "printer-state-message"
     222
     223def IppVersionsSupported(*vals):
    237224    """4.4.14 ipp-versions-supported (1setOf type2 keyword)
    238225
     
    266253    """
    267254   
    268     def __init__(self, *vals):
    269         super(type(self), self).__init__(
    270             'ipp-versions-supported',
    271             [Value(CharacterStringTags.KEYWORD, val) for val in vals])
    272 
    273 class OperationsSupported(Attribute):
     255    return Attribute(
     256        'ipp-versions-supported',
     257        [Value(CharacterStringTags.KEYWORD, val) for val in vals])
     258
     259def OperationsSupported(*vals):
    274260    """4.4.15 operations-supported (1setOf type2 enum)
    275261
     
    286272    """
    287273   
    288     def __init__(self, *vals):
    289         super(type(self), self).__init__(
    290             'operations-supported',
    291             [Value(IntegerTags.ENUM, val) for val in vals])
    292 
    293 class MultipleDocumentJobsSupported(Attribute):
     274    return Attribute(
     275        'operations-supported',
     276        [Value(IntegerTags.ENUM, val) for val in vals])
     277
     278def MultipleDocumentJobsSupported(val):
    294279    """4.4.16 multiple-document-jobs-supported (boolean)
    295280
     
    302287    """
    303288   
    304     def __init__(self, val):
    305         super(type(self), self).__init__(
    306             'multiple-document-jobs-supported',
    307             [Value(IntegerTags.BOOLEAN, val)])
    308 
    309 class CharsetConfigured(Attribute):
     289    return Attribute(
     290        'multiple-document-jobs-supported',
     291        [Value(IntegerTags.BOOLEAN, val)])
     292
     293def CharsetConfigured(val):
    310294    """4.4.17 charset-configured (charset)
    311295
     
    321305    """
    322306   
    323     def __init__(self, val):
    324         super(type(self), self).__init__(
    325             'charset-configured',
    326             [Value(CharacterStringTags.CHARSET, val)])
    327 
    328 class CharsetSupported(Attribute):
     307    return Attribute(
     308        'charset-configured',
     309        [Value(CharacterStringTags.CHARSET, val)])
     310
     311def CharsetSupported(*vals):
    329312    """4.4.18 charset-supported (1setOf charset)
    330313
     
    344327    """
    345328   
    346     def __init__(self, *vals):
    347         super(type(self), self).__init__(
    348             'charset-supported',
    349             [Value(CharacterStringTags.CHARSET, val) for val in vals])
    350 
    351 class NaturalLanguageConfigured(Attribute):
     329    return Attribute(
     330        'charset-supported',
     331        [Value(CharacterStringTags.CHARSET, val) for val in vals])
     332
     333def NaturalLanguageConfigured(val):
    352334    """4.4.19 natural-language-configured (naturalLanguage)
    353335
     
    370352    """
    371353   
    372     def __init__(self, val):
    373         super(type(self), self).__init__(
    374             'natural-language-configured',
    375             [Value(CharacterStringTags.NATURAL_LANGUAGE, val)])
    376 
    377 class GeneratedNaturalLanguageSupported(Attribute):
     354    return Attribute(
     355        'natural-language-configured',
     356        [Value(CharacterStringTags.NATURAL_LANGUAGE, val)])
     357
     358def GeneratedNaturalLanguageSupported(*vals):
    378359    """4.4.20 generated-natural-language-supported (1setOf naturalLanguage)
    379360
     
    402383    """
    403384   
    404     def __init__(self, *vals):
    405         super(type(self), self).__init__(
    406             'generated-natural-language-supported',
    407             [Value(CharacterStringTags.NATURAL_LANGUAGE, val) for val in vals])
    408 
    409 class DocumentFormatDefault(Attribute):
     385    return Attribute(
     386        'generated-natural-language-supported',
     387        [Value(CharacterStringTags.NATURAL_LANGUAGE, val) for val in vals])
     388
     389def DocumentFormatDefault(val):
    410390    """4.4.21 document-format-default (mimeMediaType)
    411391
     
    421401    """
    422402   
    423     def __init__(self, val):
    424         super(type(self), self).__init__(
    425             'document-format-default',
    426             [Value(CharacterStringTags.MIME_MEDIA_TYPE, val)])
    427 
    428 class DocumentFormatSupported(Attribute):
     403    return Attribute(
     404        'document-format-default',
     405        [Value(CharacterStringTags.MIME_MEDIA_TYPE, val)])
     406
     407def DocumentFormatSupported(*vals):
    429408    """4.4.22 document-format-supported (1setOf mimeMediaType)
    430409
     
    436415    """
    437416   
    438     def __init__(self, *vals):
    439         super(type(self), self).__init__(
    440             'document-format-supported',
    441             [Value(CharacterStringTags.MIME_MEDIA_TYPE, val) for val in vals])
    442 
    443 class PrinterIsAcceptingJobs(Attribute):
     417    return Attribute(
     418        'document-format-supported',
     419        [Value(CharacterStringTags.MIME_MEDIA_TYPE, val) for val in vals])
     420
     421def PrinterIsAcceptingJobs(val):
    444422    """4.4.23 printer-is-accepting-jobs (boolean)
    445423
     
    462440    """
    463441   
    464     def __init__(self, val):
    465         super(type(self), self).__init__(
    466             'printer-is-accepting-jobs',
    467             [Value(IntegerTags.BOOLEAN, val)])
    468 
    469 class QueuedJobCount(Attribute):
     442    return Attribute(
     443        'printer-is-accepting-jobs',
     444        [Value(IntegerTags.BOOLEAN, val)])
     445
     446def QueuedJobCount(val):
    470447    """4.4.24 queued-job-count (integer(0:MAX))
    471448
     
    476453    """
    477454   
    478     def __init__(self, val):
    479         super(type(self), self).__init__(
    480             'queued-job-count',
    481             [Value(IntegerTags.INTEGER, val)])
    482 
    483 class PrinterMessageFromOperator(Attribute):
     455    return Attribute(
     456        'queued-job-count',
     457        [Value(IntegerTags.INTEGER, val)])
     458
     459def PrinterMessageFromOperator(val):
    484460    """4.4.25 printer-message-from-operator (text(127))
    485461
    486462    """
    487463
    488     def __init__(self, val):
    489         raise ClientErrorAttributes, "printer-message-from-operator"
    490 
    491 class ColorSupported(Attribute):
     464    raise ClientErrorAttributes, "printer-message-from-operator"
     465
     466def ColorSupported(val):
    492467    """4.4.26 color-supported (boolean)
    493468
    494469    """
    495470
    496     def __init__(self, val):
    497         raise ClientErrorAttributes, "color-supported"
    498 
    499 class ReferenceUriSchemeSupported(Attribute):
     471    raise ClientErrorAttributes, "color-supported"
     472   
     473def ReferenceUriSchemeSupported(val):
    500474    """4.4.27 reference-uri-schemes-supported (1setOf uriScheme)
    501475
    502476    """
    503477
    504     def __init__(self, *vals):
    505         raise ClientErrorAttributes, "reference-uri-scheme-supported"
    506 
    507 class PdlOverrideSupported(Attribute):
     478    raise ClientErrorAttributes, "reference-uri-scheme-supported"
     479
     480def PdlOverrideSupported(val):
    508481    """4.4.28 pdl-override-supported (type2 keyword)
    509482
     
    528501    """
    529502   
    530     def __init__(self, val):
    531         super(type(self), self).__init__(
    532             'pdl-override-supported',
    533             [Value(CharacterStringTags.KEYWORD, val)])
    534 
    535 class PrinterUpTime(Attribute):
     503    return Attribute(
     504        'pdl-override-supported',
     505        [Value(CharacterStringTags.KEYWORD, val)])
     506
     507def PrinterUpTime(val):
    536508    """4.4.29 printer-up-time (integer(1:MAX))
    537509
     
    566538    """
    567539   
    568     def __init__(self, val):
    569         super(type(self), self).__init__(
    570             'printer-up-time',
    571             [Value(IntegerTags.INTEGER, val)])
    572 
    573 class PrinterCurrentTime(Attribute):
     540    return Attribute(
     541        'printer-up-time',
     542        [Value(IntegerTags.INTEGER, val)])
     543
     544def PrinterCurrentTime(val):
    574545    """4.4.30 printer-current-time (dateTime)
    575546
    576547    """
    577548
    578     def __init__(self, val):
    579         raise ClientErrorAttributes, "printer-current-time"
    580 
    581 class MultipleOperationTimeOut(Attribute):
     549    raise ClientErrorAttributes, "printer-current-time"
     550
     551def MultipleOperationTimeOut(val):
    582552    """4.4.31 multiple-operation-time-out (integer(1:MAX))
    583553
     
    598568    """
    599569   
    600     def __init__(self, val):
    601         super(type(self), self).__init__(
    602             'multiple-operation-time-out',
    603             [Value(IntegerTags.INTEGER, val)])
    604 
    605 class CompressionSupported(Attribute):
     570    return Attribute(
     571        'multiple-operation-time-out',
     572        [Value(IntegerTags.INTEGER, val)])
     573
     574def CompressionSupported(*vals):
    606575    """4.4.32 compression-supported (1setOf type3 keyword)
    607576
     
    623592    """
    624593   
    625     def __init__(self, *vals):
    626         super(type(self), self).__init__(
    627             'compression-supported',
    628             [Value(CharacterStringTags.KEYWORD, val) for val in vals])
    629 
    630 class JobKOctetsSupported(Attribute):
     594    return Attribute(
     595        'compression-supported',
     596        [Value(CharacterStringTags.KEYWORD, val) for val in vals])
     597
     598def JobKOctetsSupported(val):
    631599    """4.4.33 job-k-octets-supported (rangeOfInteger(0:MAX))
    632600
    633601    """
    634602
    635     def __init__(self, val):
    636         raise ClientErrorAttributes, "job-k-octets-supported"
    637 
    638 class JobImpressionsSupported(Attribute):
     603    raise ClientErrorAttributes, "job-k-octets-supported"
     604
     605def JobImpressionsSupported(val):
    639606    """4.4.34 job-impressions-supported (rangeOfInteger(0:MAX))
    640607
    641608    """
    642609
    643     def __init__(self, val):
    644         raise ClientErrorAttributes, "job-impressions-supported"
    645 
    646 class JobMediaSheetsSupported(Attribute):
     610    raise ClientErrorAttributes, "job-impressions-supported"
     611
     612def JobMediaSheetsSupported(val):
    647613    """4.4.35 job-media-sheets-supported (rangeOfInteger(0:MAX))
    648614
    649615    """
    650616
    651     def __init__(self, val):
    652         raise ClientErrorAttributes, "job-media-sheets-supported"
    653 
    654 class PagesPerMinute(Attribute):
     617    raise ClientErrorAttributes, "job-media-sheets-supported"
     618
     619def PagesPerMinute(val):
    655620    """4.4.36 pages-per-minute (integer(0:MAX))
    656621
    657622    """
    658623
    659     def __init__(self, val):
    660         raise ClientErrorAttributes, "pages-per-minute"
    661 
    662 class PagesPerMinuteColor(Attribute):
     624    raise ClientErrorAttributes, "pages-per-minute"
     625
     626def PagesPerMinuteColor(val):
    663627    """4.4.37 pages-per-minute-color (integer(0:MAX))
    664628
    665629    """
    666630
    667     def __init__(self, val):
    668         raise ClientErrorAttributes, "pages-per-minute-color"
    669    
     631    raise ClientErrorAttributes, "pages-per-minute-color"
     632   
  • server/lib/gutenbach/ipp/operations/__init__.py

    raded2d1 rb828a96  
    4545    # check charset
    4646    charset_attr = op_attrs.attributes[0]
    47     if charset_attr != object_attributes.AttributesCharset('utf-8'):
    48         raise errors.ClientErrorBadRequest
     47    expected = object_attributes.AttributesCharset('utf-8')
     48    if charset_attr != expected:
     49        raise errors.ClientErrorBadRequest("%s != %s" % (charset_attr, expected))
    4950
    5051    # check for attributes-natural-language
    5152    natlang_attr = op_attrs.attributes[1]
    52     if natlang_attr != object_attributes.AttributesNaturalLanguage('en-us'):
    53         raise errors.ClientErrorBadRequest
     53    expected = object_attributes.AttributesNaturalLanguage('en-us')
     54    if natlang_attr != expected:
     55        raise errors.ClientErrorBadRequest("%s != %s" % (natlang_attr, expected))
    5456
    5557    return dict([(attr.name, attr) for attr in op_attrs.attributes])
    5658
    5759def verify_printer_uri(uri_attr):
    58     if uri_attr != object_attributes.PrinterUri(uri_attr.values[0].value):
    59         raise errors.ClientErrorBadRequest
     60    expected = object_attributes.PrinterUri(uri_attr.values[0].value)
     61    if uri_attr != expected:
     62        raise errors.ClientErrorBadRequest("%s != %s" % (uri_attr, expected))
    6063   
    6164    # actually get the printer name
     
    6770
    6871def verify_requesting_username(username_attr):
    69     if username_attr != object_attributes.RequestingUserName(username_attr.values[0].value):
    70         raise errors.ClientErrorBadRequest
     72    expected = object_attributes.RequestingUserName(username_attr.values[0].value)
     73    if username_attr != expected:
     74        raise errors.ClientErrorBadRequest("%s != %s" % (username_attr, expected))
    7175    return username_attr.values[0].value
    7276
     
    121125from validate_job import verify_validate_job_request, make_validate_job_response
    122126
    123 
    124 
    125127__all__ = ['verify_cups_get_classes_request', 'make_cups_get_classes_response'
    126128           'verify_cups_get_default_request', 'make_cups_get_default_response'
  • server/lib/gutenbach/ipp/value.py

    r0c4f3bf rb828a96  
    5454        self.tag = tag # one byte, the type of value
    5555        self.value     = value     # non-binary value of self.value
     56
     57    def __cmp__(self, other):
     58        eq = (self.value == other.value) and (self.tag == other.tag)
     59        return 0 if eq else 1
    5660
    5761    @classmethod
  • server/lib/gutenbach/server/requests.py

    raded2d1 rb828a96  
    5353        except ipp.errors.IPPException:
    5454            exctype, excval, exctb = sys.exc_info()
    55             logger.error(traceback.format_exc())
     55            logger.error("%s: %s" % (exctype.__name__, excval.message))
    5656            response = ipp.ops.make_empty_response(request)
    5757            excval.update_response(response)
     
    8686        """
    8787       
    88         raise NotImplementedError
     88        raise ipp.errors.ServerErrorOperationNotSupported
    8989
    9090    @handler_for(consts.Operations.VALIDATE_JOB)
    9191    def validate_job(self, request):
    9292
    93         raise NotImplementedError
     93        raise ipp.errors.ServerErrorOperationNotSupported
    9494
    9595    @handler_for(consts.Operations.GET_JOBS)
     
    129129    @handler_for(consts.Operations.PRINT_URI)
    130130    def print_uri(self, request):
    131         raise NotImplementedError
     131        raise ipp.errors.ServerErrorOperationNotSupported
    132132
    133133    @handler_for(consts.Operations.CREATE_JOB)
     
    181181        """
    182182
    183         raise NotImplementedError
     183        raise ipp.errors.ServerErrorOperationNotSupported
    184184   
    185185    @handler_for(consts.Operations.PAUSE_PRINTER)
    186186    def pause_printer(self, request):
    187         raise NotImplementedError
     187        raise ipp.errors.ServerErrorOperationNotSupported
    188188
    189189    @handler_for(consts.Operations.RESUME_PRINTER)
    190190    def resume_printer(self, request):
    191         raise NotImplementedError
     191        raise ipp.errors.ServerErrorOperationNotSupported
    192192
    193193    @handler_for(consts.Operations.GET_PRINTER_ATTRIBUTES)
     
    252252    @handler_for(consts.Operations.SET_PRINTER_ATTRIBUTES)
    253253    def set_printer_attributes(self, request):
    254         raise NotImplementedError
     254        raise ipp.errors.ServerErrorOperationNotSupported
    255255
    256256    ##### Job Commands
     
    258258    @handler_for(consts.Operations.CANCEL_JOB)
    259259    def cancel_job(self, request):
    260         raise NotImplementedError
     260        raise ipp.errors.ServerErrorOperationNotSupported
    261261
    262262    @handler_for(consts.Operations.SEND_DOCUMENT)
    263263    def send_document(self, request):
    264         raise NotImplementedError
     264        raise ipp.errors.ServerErrorOperationNotSupported
    265265
    266266    @handler_for(consts.Operations.SEND_URI)
    267267    def send_uri(self, request):
    268         raise NotImplementedError
     268        raise ipp.errors.ServerErrorOperationNotSupported
    269269
    270270    @handler_for(consts.Operations.GET_JOB_ATTRIBUTES)
     
    297297    @handler_for(consts.Operations.SET_JOB_ATTRIBUTES)
    298298    def set_job_attributes(self, request):
    299         raise NotImplementedError
     299        raise ipp.errors.ServerErrorOperationNotSupported
    300300
    301301    @handler_for(consts.Operations.RESTART_JOB)
    302302    def restart_job(self, request):
    303         raise NotImplementedError
     303        raise ipp.errors.ServerErrorOperationNotSupported
    304304
    305305    @handler_for(consts.Operations.PROMOTE_JOB)
    306306    def promote_job(self, request):
    307         raise NotImplementedError
     307        raise ipp.errors.ServerErrorOperationNotSupported
    308308
    309309    ##### CUPS Specific Commands
     
    311311    @handler_for(consts.Operations.CUPS_GET_DOCUMENT)
    312312    def cups_get_document(self, request):
    313         raise NotImplementedError
     313        raise ipp.errors.ServerErrorOperationNotSupported
    314314
    315315    @handler_for(consts.Operations.CUPS_GET_DEFAULT)
Note: See TracChangeset for help on using the changeset viewer.