Changeset 2452 for pykota/trunk/bin
- Timestamp:
- 09/17/05 16:29:43 (19 years ago)
- Location:
- pykota/trunk/bin
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r2449 r2452 823 823 824 824 if self.Action != "DENY" : 825 if self.User.LimitBy == "noprint" : 826 self.printInfo(_("User %s is not allowed to print at this time.") % self.UserName, "warn") 827 self.Action = "DENY" 828 829 if self.Action != "DENY" : 825 830 # If printing is still allowed at this time, we 826 831 # need to extract the billing code information from the database. … … 841 846 # No need to do this if the job is denied, this way we 842 847 # save some database queries. 843 self.logdebug("Checking user %s print quota entry on printer %s" \ 848 if self.User.LimitBy in ('noquota', 'nochange') : 849 self.logdebug("User %s is allowed to print with no limit, no need to check quota." % self.UserName) 850 else : 851 self.logdebug("Checking user %s print quota entry on printer %s" \ 844 852 % (self.UserName, self.PrinterName)) 845 self.Action = self.warnUserPQuota(self.UserPQuota)853 self.Action = self.warnUserPQuota(self.UserPQuota) 846 854 847 855 # exports some new environment variables … … 912 920 self.printInfo(_("Job size : %i") % self.JobSize) 913 921 914 # update the quota for the current user on this printer 915 self.printInfo(_("Updating user %s's quota on printer %s") % (self.UserName, self.PrinterName)) 916 self.JobPrice = self.UserPQuota.increasePagesUsage(self.JobSize) 922 if self.User.LimitBy == "nochange" : 923 # no need to update the quota for the current user on this printer 924 self.printInfo(_("User %s's quota on printer %s won't be modified") % (self.UserName, self.PrinterName)) 925 self.JobPrice = self.UserPQuota.computeJobPrice(self.JobSize) 926 else : 927 # update the quota for the current user on this printer 928 self.printInfo(_("Updating user %s's quota on printer %s") % (self.UserName, self.PrinterName)) 929 self.JobPrice = self.UserPQuota.increasePagesUsage(self.JobSize) 917 930 918 931 # adds the current job to history -
pykota/trunk/bin/edpykota
r2344 r2452 100 100 101 101 -n | --noquota Doesn't set a quota but only does accounting. 102 This is the same as --limitby noquota. 102 103 103 104 -r | --reset Resets the actual page counter for the user … … 112 113 by its account balance or by its page quota. 113 114 The default value is 'quota'. Allowed values 114 are 'quota' 'balance' 'quota-then-balance' and 115 'balance-then-quota'. 116 WARNING : quota-then-balance and balance-then-quota 117 are not yet implemented. 115 are 'quota' 'balance' 'noquota' 'noprint' 116 and 'nochange' : 117 118 - quota : limit by number of pages per printer. 119 - balance : limit by number of credits in account. 120 - noquota : no limit, accounting still done. 121 - nochange : no limit, accounting not done. 122 - noprint : printing is denied. 123 NB : nochange and noprint are not supported for groups. 118 124 119 125 -b | --balance b Sets the user's account balance to b. … … 125 131 Groups don't have a real balance, but the 126 132 sum of their users' account balance. 133 134 -C | --comment txt Defines some informational text to be associated 135 with a change to an user's account balance. 136 Only meaningful if -b | --balance is also used. 127 137 128 138 -S | --softlimit sl Sets the quota soft limit to sl pages. … … 237 247 238 248 softlimit = hardlimit = None 249 250 if options["noquota"] : 251 options["limitby"] = "noquota" 252 253 limitby = options["limitby"] 254 if limitby : 255 limitby = limitby.strip().lower() 256 if limitby : 257 if limitby not in ('quota', 'balance', 'noquota', \ 258 'noprint', 'nochange') : 259 raise PyKotaToolError, _("Invalid limitby value %s") % options["limitby"] 260 if limitby in ('noquota', 'nochange') : 261 options["noquota"] = 1 262 if (limitby in ('nochange', 'noprint')) and options["groups"] : 263 raise PyKotaToolError, _("Invalid limitby value %s") % options["limitby"] 239 264 240 265 used = options["used"] … … 288 313 charges = [charges[0], None] 289 314 290 limitby = options["limitby"]291 if limitby :292 limitby = limitby.strip().lower()293 if limitby and (limitby not in ('quota', 'balance', 'quota-then-balance', 'balance-then-quota')) :294 raise PyKotaToolError, _("Invalid limitby value %s") % options["limitby"]295 296 315 if options["ingroups"] : 297 316 groupnames = [gname.strip() for gname in options["ingroups"].split(',')] … … 474 493 newbalance = float(entry.AccountBalance or 0.0) + balancevalue 475 494 newlifetimepaid = float(entry.LifeTimePaid or 0.0) + balancevalue 476 entry.setAccountBalance(newbalance, newlifetimepaid )495 entry.setAccountBalance(newbalance, newlifetimepaid, options["comment"]) 477 496 else : 478 497 diff = balancevalue - float(entry.AccountBalance or 0.0) 479 498 newlifetimepaid = float(entry.LifeTimePaid or 0.0) + diff 480 entry.setAccountBalance(balancevalue, newlifetimepaid )499 entry.setAccountBalance(balancevalue, newlifetimepaid, options["comment"]) 481 500 changed[entry.Name]["balance"] = balance 482 501 … … 506 525 defaults = { \ 507 526 "printer" : "*", \ 527 "comment" : "", \ 508 528 } 509 short_options = "vhdo:c:l:b:i:naugrp:P:S:H:G:RU:" 510 long_options = ["help", "version", "overcharge=", "charge=", "delete", "limitby=", "balance=", "ingroups=", "noquota", "add", "users", "groups", "reset", "hardreset", "prototype=", "printer=", "softlimit=", "hardlimit=", "pgroups=", "used="] 529 short_options = "vhdo:c:C:l:b:i:naugrp:P:S:H:G:RU:" 530 long_options = ["help", "version", "comment=", \ 531 "overcharge=", "charge=", "delete", "limitby=", \ 532 "balance=", "ingroups=", "noquota", "add", "users", \ 533 "groups", "reset", "hardreset", "prototype=", \ 534 "printer=", "softlimit=", "hardlimit=", "pgroups=", \ 535 "used="] 511 536 512 537 # Initializes the command line tool … … 538 563 options["used"] = options["U"] or options["used"] 539 564 options["overcharge"] = options["o"] or options["overcharge"] 565 options["comment"] = options["C"] or options["comment"] or defaults["comment"] 540 566 541 567 if options["help"] : … … 553 579 elif options["groups"] and (options["balance"] or options["ingroups"] or options["used"] or options["overcharge"]) : 554 580 raise PyKotaToolError, _("incompatible options, see help.") 581 elif options["comment"] and not options["balance"] : 582 raise PyKotaToolError, _("incompatible options, see help.") 555 583 else : 556 584 retcode = editor.main(args, options) -
pykota/trunk/bin/repykota
r2344 r2452 55 55 -g | --groups Generates a report on group quota instead of users. 56 56 57 -i | --ingroups g1[,g2...] Only lists users who are members of these 58 groups. Reserved to PyKota Administrators. 59 57 60 -P | --printer p Report quotas on this printer only. Actually p can 58 61 use wildcards characters to select only … … 92 95 # no username, means all usernames 93 96 ugnames = [ "*" ] 97 98 if options["ingroups"] : 99 groupsnames = options["ingroups"].split(",") 100 groups = [self.storage.getGroup(gname) for gname in groupsnames] 101 members = {} 102 for group in groups : 103 if not group.Exists : 104 self.printInfo("Group %s doesn't exist." % group.Name, "warn") 105 else : 106 for user in self.storage.getGroupMembers(group) : 107 members[user.Name] = user 108 ugnames = [ m for m in members.keys() if self.matchString(m, ugnames) ] 94 109 else : 95 # not the root user96 110 # reports only the current user 111 if options["ingroups"] : 112 raise PyKotaToolError, _("Option --ingroups is reserved to PyKota Administrators.") 113 97 114 username = pwd.getpwuid(os.geteuid())[0] 98 115 if options["groups"] : … … 118 135 "printer" : "*", \ 119 136 } 120 short_options = "vhug P:"121 long_options = ["help", "version", "users", "groups", " printer="]137 short_options = "vhugi:P:" 138 long_options = ["help", "version", "users", "groups", "ingroups=", "printer="] 122 139 123 140 # Initializes the command line tool … … 134 151 options["groups"] = options["g"] or options["groups"] 135 152 options["printer"] = options["P"] or options["printer"] or defaults["printer"] 153 options["ingroups"] = options["i"] or options["ingroups"] 136 154 137 155 if options["help"] :