Changeset 1582 for pykota/trunk/bin

Show
Ignore:
Timestamp:
07/01/04 19:45:49 (20 years ago)
Author:
jalet
Message:

Added code to handle the description field for printers

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pkprinters

    r1546 r1582  
    2424# 
    2525# $Log$ 
     26# Revision 1.12  2004/07/01 17:45:47  jalet 
     27# Added code to handle the description field for printers 
     28# 
    2629# Revision 1.11  2004/06/18 13:34:48  jalet 
    2730# Now all tracebacks include PyKota's version number 
     
    8790                        
    8891  -d | --delete        Deletes printers from the quota storage. 
     92   
     93  -D | --description   Adds a textual description to printers. 
    8994                        
    9095  -c | --charge p[,j]  Sets the price per page and per job to charge. 
     
    122127examples :                               
    123128 
    124   $ pkprinters --add --charge 0.05,0.1 hp2100 hp2200 hp8000 
     129  $ pkprinters --add -D "HP Printer" --charge 0.05,0.1 hp2100 hp2200 hp8000 
    125130   
    126131  Will create three printers named hp2100, hp2200 and hp8000. 
     
    128133  per job will be set at 0.1 unit. Units are in your own currency, 
    129134  or whatever you want them to mean. 
    130   If any of these printers already exists, it is not modified at 
    131   all. 
     135  All of their descriptions will be set to the string "HP Printer". 
     136  If any of these printers already exists, it will also be modified  
     137  unless the -s|--skipexisting command line option is also used. 
    132138             
    133139  $ pkprinters --delete "*" 
     
    191197                if printer.Exists : 
    192198                    if options["skipexisting"] : 
    193                         self.logger.log_message(_("Printer %s already exists, skipping.") % printer.Name, "warn") 
     199                        self.printError(_("Printer %s already exists, skipping.") % printer.Name) 
    194200                    else :     
    195                         self.logger.log_message(_("Printer %s already exists, will be modified.") % printer.Name, "warn") 
     201                        self.printError(_("Printer %s already exists, will be modified.") % printer.Name) 
    196202                        printers.append(printer) 
    197203                else : 
     
    216222                if parents :  
    217223                    parents = "%s %s" % (_("in"), parents) 
    218                 print "%s (%s + #*%s) %s" % \ 
    219                       (printer.Name, printer.PricePerJob, \ 
     224                print "%s [%s] (%s + #*%s) %s" % \ 
     225                      (printer.Name, printer.Description, printer.PricePerJob, \ 
    220226                       printer.PricePerPage, parents) 
    221227            else :     
    222228                if options["charge"] : 
    223229                    printer.setPrices(perpage, perjob)     
     230                if options["description"] is not None : 
     231                    printer.setDescription(options["description"].strip()) 
    224232                if options["groups"] :     
    225233                    for pgroup in printersgroups : 
     
    232240    retcode = 0 
    233241    try : 
    234         short_options = "hvac:dg:lrs" 
    235         long_options = ["help", "version", "add", "charge=", "delete", "groups=", "list", "remove", "skipexisting"] 
     242        short_options = "hvac:D:dg:lrs" 
     243        long_options = ["help", "version", "add", "charge=", "description=", "delete", "groups=", "list", "remove", "skipexisting"] 
    236244         
    237245        # Initializes the command line tool 
     
    246254        options["add"] = options["a"] or options["add"] 
    247255        options["charge"] = options["c"] or options["charge"] 
     256        options["description"] = options["D"] or options["description"] 
    248257        options["delete"] = options["d"] or options["delete"]  
    249258        options["groups"] = options["g"] or options["groups"] 
     
    256265        elif options["version"] : 
    257266            manager.display_version_and_quit() 
    258         elif (options["delete"] and (options["add"] or options["groups"] or options["charge"] or options["remove"])) \ 
     267        elif (options["delete"] and (options["add"] or options["groups"] or options["charge"] or options["remove"] or options["description"])) \ 
    259268           or (options["skipexisting"] and not options["add"]) \ 
    260            or (options["list"] and (options["add"] or options["delete"] or options["groups"] or options["charge"] or options["remove"])) : 
     269           or (options["list"] and (options["add"] or options["delete"] or options["groups"] or options["charge"] or options["remove"] or options["description"])) : 
    261270            raise PyKotaToolError, _("incompatible options, see help.") 
    262271        elif options["remove"] and not options["groups"] :