Changeset 768

Show
Ignore:
Timestamp:
02/08/03 23:39:46 (21 years ago)
Author:
jalet
Message:

--reset command line option added

Location:
pykota/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/edpykota

    r767 r768  
    1717# 
    1818# $Log$ 
     19# Revision 1.16  2003/02/08 22:39:46  jalet 
     20# --reset command line option added 
     21# 
    1922# Revision 1.15  2003/02/08 22:20:01  jalet 
    2023# Clarification on why we don't check with /etc/passwd to see if the user 
     
    98101  -p | --prototype u|g Uses user u or group g as a prototype to set 
    99102                       print quotas 
     103                        
     104  -r | --reset         Resets the printed page counter for the user 
     105                       or group to zero. The life time page counter  
     106                       is kept unchanged. 
    100107                        
    101108  -S | --softlimit sl  Sets the quota soft limit to sl pages.                        
     
    223230                    if options["users"] : 
    224231                        self.storage.setUserPQuota(name, printer, softlimit, hardlimit) 
     232                        if options["reset"] : 
     233                            self.storage.resetUserPQuota(name, printer) 
    225234                    else : 
    226235                        self.storage.setGroupPQuota(name, printer, softlimit, hardlimit) 
     236                        if options["reset"] : 
     237                            self.storage.resetGroupPQuota(name, printer) 
    227238                      
    228239if __name__ == "__main__" :  
     
    233244                     "printer" : "*", \ 
    234245                   } 
    235         short_options = "vhaugp:P:S:H:" 
    236         long_options = ["help", "version", "add", "users", "groups", "prototype=", "printer=", "softlimit=", "hardlimit="] 
     246        short_options = "vhaugrp:P:S:H:" 
     247        long_options = ["help", "version", "add", "users", "groups", "reset", "prototype=", "printer=", "softlimit=", "hardlimit="] 
    237248         
    238249        # Initializes the command line tool 
     
    252263        options["softlimit"] = options["S"] or options["softlimit"] 
    253264        options["hardlimit"] = options["H"] or options["hardlimit"]  
     265        options["reset"] = options["r"] or options["reset"]  
    254266         
    255267        if options["help"] : 
  • pykota/trunk/pykota/storage.py

    r759 r768  
    1515# 
    1616# $Log$ 
     17# Revision 1.5  2003/02/08 22:39:46  jalet 
     18# --reset command line option added 
     19# 
    1720# Revision 1.4  2003/02/08 09:59:59  jalet 
    1821# Added preliminary base class for all storages 
     
    6669         
    6770    def addUserPQuota(self, username, printername) : 
    68         """Adds a tuple (user, printer) to the Quota Storage, both are also added individually if needed.""" 
     71        """Initializes a user print quota on a printer, adds the printer and the user to the quota storage if needed.""" 
    6972        pass 
    7073         
     
    7982    def setUserPQuota(self, username, printername, softlimit, hardlimit) : 
    8083        """Sets soft and hard limits for a user quota on a specific printer given (username, printername).""" 
     84        pass 
     85         
     86    def resetUserPQuota(self, username, printername) :     
     87        """Resets the page counter to zero. Life time page counter is kept unchanged.""" 
    8188        pass 
    8289         
  • pykota/trunk/pykota/storages/sql.py

    r765 r768  
    1515# 
    1616# $Log$ 
     17# Revision 1.16  2003/02/08 22:39:46  jalet 
     18# --reset command line option added 
     19# 
    1720# Revision 1.15  2003/02/08 22:12:09  jalet 
    1821# Life time counter for users and groups added. 
     
    135138         
    136139    def addUserPQuota(self, username, printername) : 
     140        """Initializes a user print quota on a printer, adds the printer and the user to the quota storage if needed.""" 
    137141        (userid, printerid) = self.getUPIds(username, printername) 
    138142        if printerid is None :     
     
    152156        (userid, printerid) = self.getUPIds(username, printername) 
    153157        if (userid is not None) and (printerid is not None) : 
    154             result = self.doQuery("SELECT pagecounter, softlimit, hardlimit, datelimit FROM userpquota WHERE userid=%s AND printerid=%s;" % (self.doQuote(userid), self.doQuote(printerid))) 
     158            result = self.doQuery("SELECT lifepagecounter, pagecounter, softlimit, hardlimit, datelimit FROM userpquota WHERE userid=%s AND printerid=%s;" % (self.doQuote(userid), self.doQuote(printerid))) 
    155159            try : 
    156160                return self.doParseResult(result)[0] 
     
    163167        if (userid is not None) and (printerid is not None) : 
    164168            self.doQuery("UPDATE userpquota SET softlimit=%s, hardlimit=%s, datelimit=NULL WHERE userid=%s AND printerid=%s;" % (self.doQuote(softlimit), self.doQuote(hardlimit), self.doQuote(userid), self.doQuote(printerid))) 
     169         
     170    def resetUserPQuota(self, username, printername) :     
     171        """Resets the page counter to zero. Life time page counter is kept unchanged.""" 
     172        (userid, printerid) = self.getUPIds(username, printername) 
     173        if (userid is not None) and (printerid is not None) : 
     174            self.doQuery("UPDATE userpquota SET pagecounter=0 WHERE userid=%s AND printerid=%s;" % (self.doQuote(userid), self.doQuote(printerid))) 
    165175         
    166176    def setDateLimit(self, username, printername, datelimit) :