Changeset 1967 for pykota

Show
Ignore:
Timestamp:
12/02/04 22:24:51 (20 years ago)
Author:
jalet
Message:

Integrated the patch by Wilson Roberto Afonso and Matt Hyclak to allow
edpykota to accept the -U | --used value command line option.

Location:
pykota/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/edpykota

    r1956 r1967  
    2424# 
    2525# $Log$ 
     26# Revision 1.83  2004/12/02 21:24:50  jalet 
     27# Integrated the patch by Wilson Roberto Afonso and Matt Hyclak to allow 
     28# edpykota to accept the -U | --used value command line option. 
     29# 
    2630# Revision 1.82  2004/11/22 21:53:38  jalet 
    2731# Added the reject_unknown directive to pykota.conf to reject user/group 
     
    362366  -R | --hardreset     Resets the actual and life time page counters 
    363367                       for the user or group to zero on the specified  
    364                        printers.  
     368                       printers. This is a shortcut for '--used 0'. 
    365369                        
    366370  -l | --limitby l     Choose if the user/group is limited in printing                      
     
    384388   
    385389  -H | --hardlimit hl  Sets the quota hard limit to hl pages. 
    386    
     390 
     391  -U | --used usage    Sets the pagecounters for the user to usage pages; 
     392                       useful for migrating users from a different system 
     393                       where they have already used some pages. Actual 
     394                       and Life Time page counters may be increased or decreased 
     395                       if usage is prefixed with + or -. 
     396                       WARNING : BOTH page counters are modified in all cases, 
     397                       so be careful. 
     398                       NB : if 'usage' equals '0', then the action taken is 
     399                       the same as if --hardreset was used. 
     400 
    387401  user1 through userN and group1 through groupN can use wildcards 
    388402  if the --add option is not set. 
     
    482496        suffix = (options["groups"] and "Group") or "User"         
    483497         
    484         softlimit = hardlimit = None     
     498        softlimit = hardlimit = None 
     499 
     500        used = options["used"] 
     501        if used : 
     502            used = used.strip() 
     503            try : 
     504                int(used) 
     505            except ValueError : 
     506                raise PyKotaToolError, _("Invalid used value %s.") % used 
     507 
    485508        if not options["noquota"] : 
    486509            if options["softlimit"] : 
     
    668691                        if options["reset"] : 
    669692                            entrypquota.reset() 
    670                         elif options["hardreset"] :     
     693                        if options["hardreset"] :     
    671694                            entrypquota.hardreset() 
     695                        if options["used"] : 
     696                            entrypquota.setUsage(used) 
    672697                             
    673698                        if balance : 
     
    692717                                else : 
    693718                                    self.printInfo(_("Group %s not found in the PyKota Storage.") % groupname) 
    694                                      
    695                     # This line disabled to prevent sending of unwanted email                  
    696                     # messages if quota is reached at creation/modification time. 
    697                     # The check will be done at print time anyway. 
    698                     # getattr(self, "warn%sPQuota" % suffix)(entrypquota)     
    699719                         
    700720        # Now delete what has to be deleted                 
     
    708728                     "printer" : "*", \ 
    709729                   } 
    710         short_options = "vhdc:l:b:i:naugrp:P:S:H:G:R" 
    711         long_options = ["help", "version", "charge=", "delete", "limitby=", "balance=", "ingroups=", "noquota", "add", "users", "groups", "reset", "hardreset", "prototype=", "printer=", "softlimit=", "hardlimit=", "pgroups="] 
     730        short_options = "vhdc:l:b:i:naugrp:P:S:H:G:RU:" 
     731        long_options = ["help", "version", "charge=", "delete", "limitby=", "balance=", "ingroups=", "noquota", "add", "users", "groups", "reset", "hardreset", "prototype=", "printer=", "softlimit=", "hardlimit=", "pgroups=", "used="] 
    712732         
    713733        # Initializes the command line tool 
     
    736756        options["pgroups"] = options["G"] or options["pgroups"] 
    737757        options["hardreset"] = options["R"] or options["hardreset"]  
     758        options["used"] = options["U"] or options["used"] 
    738759         
    739760        if options["help"] : 
     
    749770        elif options["noquota"] and (options["prototype"] or options["hardlimit"] or options["softlimit"]) : 
    750771            raise PyKotaToolError, _("incompatible options, see help.") 
    751         elif options["groups"] and (options["balance"] or options["ingroups"]) : 
     772        elif options["groups"] and (options["balance"] or options["ingroups"] or options["used"] or options["reset"] or options["hardreset"]) : 
    752773            raise PyKotaToolError, _("incompatible options, see help.") 
    753774        else : 
  • pykota/trunk/NEWS

    r1966 r1967  
    2222PyKota NEWS : 
    2323 
     24    - 1.21alpha11 : 
     25     
     26        - edpkota now accepts the -U | --used value command line argument 
     27          to preset the page counters to an initial value. Thanks to 
     28          Wilson Roberto Afonso and Matt Hyclak for the patch. 
     29           
    2430    - 1.21alpha10 : 
    2531     
  • pykota/trunk/pykota/storage.py

    r1875 r1967  
    2222# 
    2323# $Log$ 
     24# Revision 1.66  2004/12/02 21:24:50  jalet 
     25# Integrated the patch by Wilson Roberto Afonso and Matt Hyclak to allow 
     26# edpykota to accept the -U | --used value command line option. 
     27# 
    2428# Revision 1.65  2004/10/25 14:12:25  jalet 
    2529# For URGENT legal reasons (Italy), a new "privacy" directive was added to pykota.conf 
     
    439443        self.DateLimit = None 
    440444         
     445    def setUsage(self, used) : 
     446        """Sets the PageCounter and LifePageCounter to used, or if used is + or - prefixed, changes the values of {Life,}PageCounter by that amount.""" 
     447        vused = int(used) 
     448        if used.startswith("+") or used.startswith("-") : 
     449           self.parent.increaseUserPQuotaPagesCounters(self, vused) 
     450           self.PageCounter += vused 
     451           self.LifePageCounter += vused 
     452        else : 
     453           self.parent.writeUserPQuotaPagesCounters(self, vused, vused) 
     454           self.PageCounter = self.LifePageCounter = vused 
     455 
    441456    def reset(self) :     
    442457        """Resets page counter to 0.""" 
  • pykota/trunk/pykota/version.py

    r1966 r1967  
    2222# 
    2323 
    24 __version__ = "1.21alpha10_unofficial" 
     24__version__ = "1.21alpha11_unofficial" 
    2525 
    2626__doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""