Show
Ignore:
Timestamp:
09/19/05 18:59:00 (19 years ago)
Author:
jerome
Message:

Added support for --maxjobsize, --passthrough and --nopassthrough
in pkprinters.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pkprinters

    r2463 r2465  
    8080  -s | --skipexisting  In combination with the --add option above, tells 
    8181                       pkprinters to not modify existing printers. 
     82                        
     83  -m | --maxjobsize s  Sets the maximum job size allowed on the printer 
     84                       to s pages. 
     85                        
     86  -p | --passthrough   Activate passthrough mode for the printer. In this 
     87                       mode, users are allowed to print without any impact 
     88                       on their quota or account balance. 
     89                        
     90  -n | --nopassthrough Deactivate passthrough mode for the printer. 
     91                       Without -p or -n, printers are created in  
     92                       normal mode, i.e. no passthrough. 
    8293   
    8394  printer1 through printerN can contain wildcards if the --add option  
     
    137148                    charges = [charges[0], None] 
    138149                (perpage, perjob) = charges 
     150                 
     151        if options["maxjobsize"] :         
     152            try : 
     153                maxjobsize = int(options["maxjobsize"]) 
     154                if maxjobsize < 0 : 
     155                    raise ValueError 
     156            except ValueError :     
     157                raise PyKotaToolError, _("Invalid maximum job size value %s") % options["maxjobsize"] 
     158        else :         
     159            maxjobsize = None 
     160                 
    139161                 
    140162        if options["add"] :     
     
    181203                if options["description"] is not None : 
    182204                    printer.setDescription(options["description"].strip()) 
     205                if options["nopassthrough"] and printer.PassThrough :     
     206                    self.storage.setPrinterPassThroughMode(printer, 0) 
     207                if options["passthrough"] and not printer.PassThrough :     
     208                    self.storage.setPrinterPassThroughMode(printer, 1) 
     209                if (maxjobsize is not None) and (printer.MaxJobSize != maxjobsize) :     
     210                    self.storage.setPrinterMaxJobSize(printer, maxjobsize) 
    183211                if options["groups"] :     
    184212                    for pgroup in printersgroups : 
     
    191219    retcode = 0 
    192220    try : 
    193         short_options = "hvac:D:dg:lrs" 
    194         long_options = ["help", "version", "add", "charge=", "description=", "delete", "groups=", "list", "remove", "skipexisting"] 
     221        short_options = "hvac:D:dg:lrsnpm:" 
     222        long_options = ["help", "version", "add", "charge=", "description=", \ 
     223                        "delete", "groups=", "list", "remove", \ 
     224                        "skipexisting", "passthrough", "nopassthrough", \ 
     225                        "maxjobsize="] 
    195226         
    196227        # Initializes the command line tool 
     
    212243        options["remove"] = options["r"] or options["remove"] 
    213244        options["skipexisting"] = options["s"] or options["skipexisting"] 
     245        options["maxjobsize"] = options["m"] or options["maxjobsize"] 
     246        options["passthrough"] = options["p"] or options["passthrough"] 
     247        options["nopassthrough"] = options["n"] or options["nopassthrough"] 
    214248         
    215249        if options["help"] : 
     
    219253        elif (options["delete"] and (options["add"] or options["groups"] or options["charge"] or options["remove"] or options["description"])) \ 
    220254           or (options["skipexisting"] and not options["add"]) \ 
    221            or (options["list"] and (options["add"] or options["delete"] or options["groups"] or options["charge"] or options["remove"] or options["description"])) : 
     255           or (options["list"] and (options["add"] or options["delete"] or options["groups"] or options["charge"] or options["remove"] or options["description"])) \ 
     256           or (options["passthrough"] and options["nopassthrough"]) : 
    222257            raise PyKotaToolError, _("incompatible options, see help.") 
    223258        elif options["remove"] and not options["groups"] :