Show
Ignore:
Timestamp:
04/10/03 23:47:20 (21 years ago)
Author:
jalet
Message:

Job history added. Upgrade script neutralized for now !

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/edpykota

    r895 r900  
    2323# 
    2424# $Log$ 
     25# Revision 1.33  2003/04/10 21:47:20  jalet 
     26# Job history added. Upgrade script neutralized for now ! 
     27# 
    2528# Revision 1.32  2003/04/08 21:31:39  jalet 
    2629# (anything or 0) = anything !!! Go back to school Jerome ! 
     
    232235    def main(self, names, options) : 
    233236        """Edit user or group quotas.""" 
    234         printernames = self.storage.getMatchingPrinters(options["printer"]) 
    235         if not printernames : 
     237        printers = self.storage.getMatchingPrinters(options["printer"]) 
     238        if not printers : 
    236239            pname = options["printer"] 
    237240            if options["add"] and pname : 
    238241                if self.isValidName(pname) : 
    239                     self.storage.addPrinter(pname) 
    240                     printernames = [ (pname, 0) ] 
     242                    printerid = self.storage.addPrinter(pname) 
     243                    printers = [ (printerid, pname) ] 
    241244                else :     
    242245                    raise PyKotaToolError, _("Invalid printer name %s") % pname 
     
    263266            else :     
    264267                names = [ "*" ] # all users 
    265         for (printer, printerpagecounter) in printernames : 
     268        for (printerid, printer) in printers : 
    266269            if options["prototype"] : 
    267270                if options["groups"] : 
    268                     prototype = self.storage.getGroupPQuota(options["prototype"], printer) 
     271                    prototype = self.storage.getGroupPQuota(self.storage.getGroupId(options["prototype"]), printerid) 
    269272                else :      
    270273                    # default is user quota edition 
    271                     prototype = self.storage.getUserPQuota(options["prototype"], printer) 
     274                    prototype = self.storage.getUserPQuota(self.storage.getUserId(options["prototype"]), printerid) 
    272275                if prototype is None : 
    273276                    self.logger.log_message(_("Prototype %s not found in Quota Storage for printer %s.") % (options["prototype"], printer)) 
     
    283286                if softlimit is not None : 
    284287                    self.logger.log_message(_("Undefined soft limit set to hard limit (%s) on printer %s.") % (str(softlimit), printer)) 
    285             if (not options["reset"] and not options["noquota"]) and ((hardlimit is None) or (softlimit is None)) : 
     288            if (not options["reset"] and not options["noquota"] and not options["prototype"]) and ((hardlimit is None) or (softlimit is None)) : 
    286289                raise PyKotaToolError, _("Both hard and soft limits must be set ! Aborting.") 
    287290            if options["add"] :     
    288                 allnames = names 
     291                allidnames = [(None, n) for n in names] 
    289292            else :    
    290293                if options["groups"] :     
    291                     allnames = self.storage.getPrinterGroups(printer) 
     294                    allidnames = self.storage.getPrinterGroups(printerid) 
    292295                else :     
    293                     allnames = self.storage.getPrinterUsers(printer) 
    294             for name in [n for n in allnames if self.matchString(n, names)]: 
     296                    allidnames = self.storage.getPrinterUsers(printerid) 
     297            for (ident, name) in [(i, n) for (i, n) in allidnames if self.matchString(n, names)]: 
    295298                if options["groups"] : 
    296                     quota = self.storage.getGroupPQuota(name, printer) 
     299                    quota = self.storage.getGroupPQuota(ident, printerid) 
    297300                else : 
    298                     quota = self.storage.getUserPQuota(name, printer) 
     301                    quota = self.storage.getUserPQuota(ident, printerid) 
    299302                if quota is None : 
    300303                    # not found 
     
    306309                        if options["groups"] : 
    307310                            if self.isValidName(name) : 
    308                                 self.storage.addGroupPQuota(name, printer) 
    309                                 quota = self.storage.getGroupPQuota(name, printer) 
     311                                (ident, printerid) = self.storage.addGroupPQuota(name, printerid) 
     312                                quota = self.storage.getGroupPQuota(ident, printerid) 
    310313                            else :     
    311314                                self.logger.log_message(_("Invalid group name %s") % name) 
    312315                        else : 
    313316                            if self.isValidName(name) : 
    314                                 self.storage.addUserPQuota(name, printer) 
    315                                 quota = self.storage.getUserPQuota(name, printer) 
     317                                (ident, printerid) = self.storage.addUserPQuota(name, printerid) 
     318                                quota = self.storage.getUserPQuota(ident, printerid) 
    316319                            else :     
    317320                                self.logger.log_message(_("Invalid user name %s") % name) 
     
    320323                else :     
    321324                    if options["groups"] : 
    322                         if options["noquota"] or ((softlimit is not None) and (hardlimit is not None)) : 
    323                             self.storage.setGroupPQuota(name, printer, softlimit, hardlimit) 
     325                        if options["noquota"] or options["prototype"] or ((softlimit is not None) and (hardlimit is not None)) : 
     326                            self.storage.setGroupPQuota(ident, printerid, softlimit, hardlimit) 
    324327                        if options["reset"] : 
    325                             self.storage.resetGroupPQuota(name, printer) 
     328                            self.storage.resetGroupPQuota(ident, printerid) 
     329                        self.warnGroupPQuota(name, printer)     
    326330                    else : 
    327                         if options["noquota"] or ((softlimit is not None) and (hardlimit is not None)) : 
    328                             self.storage.setUserPQuota(name, printer, softlimit, hardlimit) 
     331                        if options["noquota"] or options["prototype"] or ((softlimit is not None) and (hardlimit is not None)) : 
     332                            self.storage.setUserPQuota(ident, printerid, softlimit, hardlimit) 
    329333                        if options["reset"] : 
    330                             self.storage.resetUserPQuota(name, printer) 
     334                            self.storage.resetUserPQuota(ident, printerid) 
     335                        self.warnUserPQuota(name, printer)     
    331336                      
    332337if __name__ == "__main__" :