Show
Ignore:
Timestamp:
02/04/04 14:24:41 (20 years ago)
Author:
jalet
Message:

pkprinters can now remove printers from printers groups.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pkprinters

    r1331 r1332  
    2424# 
    2525# $Log$ 
     26# Revision 1.3  2004/02/04 13:24:41  jalet 
     27# pkprinters can now remove printers from printers groups. 
     28# 
    2629# Revision 1.2  2004/02/04 12:52:37  jalet 
    2730# pkprinters' help 
     
    6265                       Floating point and negative values are allowed. 
    6366   
    64   -g | --groups pg1[,pg2...] Adds the printer(s) to the printer groups 
    65                        pg1, pg2, etc... which must already exist. 
     67  -g | --groups pg1[,pg2...] Adds or Remove the printer(s) to the printer  
     68                       groups pg1, pg2, etc... which must already exist. 
    6669                       A printer group is just like a normal printer, 
    6770                       only that it is usually unknown from the printing 
     
    7376                       is done on a printer and on all the printer groups 
    7477                       it belongs to. 
     78                       If the --remove option below is not used, the  
     79                       default action is to add printers to the specified 
     80                       printer groups. 
     81                        
     82  -r | --remove        In combination with the --groups option above,                        
     83                       remove printers from the specified printers groups. 
    7584   
    7685  printer1 through printerN can contain wildcards if the --add option  
     
    96105  This will put all printers which name matches "hp*" into printers groups  
    97106  Laser and HP, which MUST already exist. 
     107   
     108  $ pkprinters --groups LexMark --remove hp2200 
     109   
     110  This will remove the hp2200 printer from the LexMark printer group. 
    98111   
    99112This program is free software; you can redistribute it and/or modify 
     
    159172                if options["groups"] :     
    160173                    for pgroup in printersgroups : 
    161                         pgroup.addPrinterToGroup(printer)     
     174                        if options["remove"] : 
     175                            pgroup.delPrinterFromGroup(printer) 
     176                        else : 
     177                            pgroup.addPrinterToGroup(printer)     
    162178                      
    163179if __name__ == "__main__" :  
    164180    retcode = 0 
    165181    try : 
    166         short_options = "hvac:dg:" 
    167         long_options = ["help", "version", "add", "charge=", "delete", "groups="] 
     182        short_options = "hvac:dg:r" 
     183        long_options = ["help", "version", "add", "charge=", "delete", "groups=", "remove"] 
    168184         
    169185        # Initializes the command line tool 
     
    180196        options["delete"] = options["d"] or options["delete"]  
    181197        options["groups"] = options["g"] or options["groups"] 
     198        options["remove"] = options["r"] or options["remove"] 
    182199         
    183200        if options["help"] : 
     
    185202        elif options["version"] : 
    186203            manager.display_version_and_quit() 
    187         elif options["delete"] and (options["add"] or options["groups"] or options["charge"]) :     
     204        elif options["delete"] and (options["add"] or options["groups"] or options["charge"] or options["remove"]) :     
    188205            raise PyKotaToolError, _("incompatible options, see help.") 
     206        elif options["remove"] and not options["groups"] :     
     207            raise PyKotaToolError, _("You have to pass printer groups names on the command line") 
    189208        elif not args :     
    190209            raise PyKotaToolError, _("You have to pass printer names on the command line")