Changeset 890

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

Checks --groups option presence instead of --users because --users is the default.

Location:
pykota/trunk/bin
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/edpykota

    r886 r890  
    2323# 
    2424# $Log$ 
     25# Revision 1.30  2003/04/08 21:10:18  jalet 
     26# Checks --groups option presence instead of --users because --users is the default. 
     27# 
    2528# Revision 1.29  2003/04/05 09:28:56  jalet 
    2629# Unnecessary message was logged 
     
    256259        for (printer, printerpagecounter) in printernames : 
    257260            if options["prototype"] : 
    258                 if options["users"] : 
     261                if options["groups"] : 
     262                    prototype = self.storage.getGroupPQuota(options["prototype"], printer) 
     263                else :      
     264                    # default is user quota edition 
    259265                    prototype = self.storage.getUserPQuota(options["prototype"], printer) 
    260                 else :      
    261                     prototype = self.storage.getGroupPQuota(options["prototype"], printer) 
    262266                if prototype is None : 
    263267                    self.logger.log_message(_("Prototype %s not found in Quota Storage for printer %s.") % (options["prototype"], printer)) 
     
    278282                allnames = names 
    279283            else :    
    280                 if options["users"] :     
     284                if options["groups"] :     
     285                    allnames = self.storage.getPrinterGroups(printer) 
     286                else :     
    281287                    allnames = self.storage.getPrinterUsers(printer) 
    282                 else :     
    283                     allnames = self.storage.getPrinterGroups(printer) 
    284288            for name in [n for n in allnames if self.matchString(n, names)]: 
    285                 if options["users"] : 
     289                if options["groups"] : 
     290                    quota = self.storage.getGroupPQuota(name, printer) 
     291                else : 
    286292                    quota = self.storage.getUserPQuota(name, printer) 
    287                 else : 
    288                     quota = self.storage.getGroupPQuota(name, printer) 
    289293                if quota is None : 
    290294                    # not found 
     
    294298                        # like /etc/passwd because users may be defined  
    295299                        # only remotely 
    296                         if options["users"] : 
     300                        if options["groups"] : 
     301                            if self.isValidName(name) : 
     302                                self.storage.addGroupPQuota(name, printer) 
     303                                quota = self.storage.getGroupPQuota(name, printer) 
     304                            else :     
     305                                self.logger.log_message(_("Invalid group name %s") % name) 
     306                        else : 
    297307                            if self.isValidName(name) : 
    298308                                self.storage.addUserPQuota(name, printer) 
     
    300310                            else :     
    301311                                self.logger.log_message(_("Invalid user name %s") % name) 
    302                         else : 
    303                             if self.isValidName(name) : 
    304                                 self.storage.addGroupPQuota(name, printer) 
    305                                 quota = self.storage.getGroupPQuota(name, printer) 
    306                             else :     
    307                                 self.logger.log_message(_("Invalid group name %s") % name) 
    308312                if quota is None :      
    309313                    self.logger.log_message(_("Quota not found for object %s on printer %s.") % (name, printer)) 
    310314                else :     
    311                     if options["users"] : 
     315                    if options["groups"] : 
     316                        if options["noquota"] or ((softlimit is not None) and (hardlimit is not None)) : 
     317                            self.storage.setGroupPQuota(name, printer, softlimit, hardlimit) 
     318                        if options["reset"] : 
     319                            self.storage.resetGroupPQuota(name, printer) 
     320                    else : 
    312321                        if options["noquota"] or ((softlimit is not None) and (hardlimit is not None)) : 
    313322                            self.storage.setUserPQuota(name, printer, softlimit, hardlimit) 
    314323                        if options["reset"] : 
    315324                            self.storage.resetUserPQuota(name, printer) 
    316                     else : 
    317                         if options["noquota"] or ((softlimit is not None) and (hardlimit is not None)) : 
    318                             self.storage.setGroupPQuota(name, printer, softlimit, hardlimit) 
    319                         if options["reset"] : 
    320                             self.storage.resetGroupPQuota(name, printer) 
    321325                      
    322326if __name__ == "__main__" :  
  • pykota/trunk/bin/repykota

    r873 r890  
    2323# 
    2424# $Log$ 
     25# Revision 1.18  2003/04/08 21:10:18  jalet 
     26# Checks --groups option presence instead of --users because --users is the default. 
     27# 
    2528# Revision 1.17  2003/03/29 13:45:27  jalet 
    2629# GPL paragraphs were incorrectly (from memory) copied into the sources. 
     
    147150            print _("Pages grace time: %idays") % self.config.getGraceDelay(printer) 
    148151            total = 0 
    149             if options["users"] : 
     152            if options["groups"] : 
     153                print _("Group            used     soft     hard   grace        total") 
     154                print "------------------------------------------------------------" 
     155                for name in self.storage.getPrinterGroups(printer) : 
     156                    quota = self.storage.getGroupPQuota(name, printer)  
     157                    total += self.printQuota(name, quota) 
     158            else : 
     159                # default is user quota report 
    150160                print _("User             used     soft     hard   grace        total") 
    151161                print "------------------------------------------------------------" 
    152162                for name in self.storage.getPrinterUsers(printer) : 
    153163                    quota = self.storage.getUserPQuota(name, printer) 
    154                     total += self.printQuota(name, quota) 
    155             else : 
    156                 print _("Group            used     soft     hard   grace        total") 
    157                 print "------------------------------------------------------------" 
    158                 for name in self.storage.getPrinterGroups(printer) : 
    159                     quota = self.storage.getGroupPQuota(name, printer)  
    160164                    total += self.printQuota(name, quota) 
    161165            if total :         
  • pykota/trunk/bin/warnpykota

    r873 r890  
    2323# 
    2424# $Log$ 
     25# Revision 1.12  2003/04/08 21:10:18  jalet 
     26# Checks --groups option presence instead of --users because --users is the default. 
     27# 
    2528# Revision 1.11  2003/03/29 13:45:27  jalet 
    2629# GPL paragraphs were incorrectly (from memory) copied into the sources. 
     
    129132            raise PyKotaToolError, _("There's no printer matching %s") % options["printer"] 
    130133        for (printer, printerpagecounter) in printernames : 
    131             if options["users"] : 
     134            if options["groups"] : 
     135                for name in self.storage.getPrinterGroups(printer) : 
     136                    self.warnGroupPQuota(name, printer) 
     137            else : 
    132138                for name in self.storage.getPrinterUsers(printer) : 
    133139                    self.warnUserPQuota(name, printer) 
    134             else : 
    135                 for name in self.storage.getPrinterGroups(printer) : 
    136                     self.warnGroupPQuota(name, printer) 
    137140                      
    138141if __name__ == "__main__" :