Changeset 917
- Timestamp:
- 04/15/03 15:55:28 (22 years ago)
- Location:
- pykota/trunk
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/edpykota
r916 r917 23 23 # 24 24 # $Log$ 25 # Revision 1.36 2003/04/15 13:55:28 jalet 26 # Options --limitby and --balance added to edpykota 27 # 25 28 # Revision 1.35 2003/04/15 13:06:39 jalet 26 29 # Allow to add a printer without any user … … 174 177 or group to zero. The life time page counter 175 178 is kept unchanged. 179 180 -l | --limitby l Choose if the user/group is limited in printing 181 by its account balance or by its page quota. 182 The default value is 'quota'. Allowed values 183 are 'quota' and 'balance'. 184 185 -b | --balance b Sets the user's account balance to b. 186 Account balance may be increase or decreased 187 if b is prefixed with + or -. 188 WARNING : when decreasing account balance, 189 the total paid so far by the user is decreased 190 too. 191 Groups don't have a real balance, but the 192 sum of their users' account balance. 176 193 177 194 -S | --softlimit sl Sets the quota soft limit to sl pages. … … 220 237 accounting of the pages he prints will still be kept. 221 238 Print Quotas for jerome on other printers are unchanged. 239 240 $ edpykota --limitby balance jerome 241 242 This will tell PyKota to limit jerome by his account's balance 243 when printing. 244 245 $ edpykota --balance +10.0 jerome 246 247 This will increase jerome's account balance by 10.0 (in your 248 own currency). You can decrease the account balance with a 249 dash prefix, and set it to a fixed amount with no prefix. 222 250 223 251 This program is free software; you can redistribute it and/or modify … … 294 322 if softlimit is not None : 295 323 self.logger.log_message(_("Undefined soft limit set to hard limit (%s) on printer %s.") % (str(softlimit), printer)) 296 if (not options["reset"] and not options["noquota"] and not options["prototype"] ) and ((hardlimit is None) or (softlimit is None)) :324 if (not options["reset"] and not options["noquota"] and not options["prototype"] and not options["limitby"] and not options["balance"]) and ((hardlimit is None) or (softlimit is None)) : 297 325 raise PyKotaToolError, _("Both hard and soft limits must be set ! Aborting.") 298 326 if options["add"] : … … 330 358 self.logger.log_message(_("Quota not found for object %s on printer %s.") % (name, printer)) 331 359 else : 360 limitby = options["limitby"] 361 if limitby : 362 limitby = limitby.lower() 363 if limitby and (limitby not in ('quota', 'balance')) : 364 limitby = 'quota' 332 365 if options["groups"] : 333 366 if options["noquota"] or options["prototype"] or ((softlimit is not None) and (hardlimit is not None)) : … … 335 368 if options["reset"] : 336 369 self.storage.resetGroupPQuota(ident, printerid) 370 if limitby : 371 self.storage.limitGroupBy(ident, limitby) 337 372 self.warnGroupPQuota(name, printer) 338 373 else : … … 341 376 if options["reset"] : 342 377 self.storage.resetUserPQuota(ident, printerid) 378 if limitby : 379 self.storage.limitUserBy(ident, limitby) 380 balance = options["balance"] 381 if balance : 382 balance = balance.strip() 383 try : 384 balancevalue = float(balance) 385 except ValueError : 386 pass # TODO : log something when incorrect balance value 387 else : 388 if balance.startswith("+") or balance.startswith("-") : 389 self.storage.increaseUserBalance(ident, balancevalue) 390 else : 391 self.storage.setUserBalance(ident, balancevalue) 343 392 self.warnUserPQuota(name, printer) 344 393 … … 348 397 "printer" : "*", \ 349 398 } 350 short_options = "vh naugrp:P:S:H:"351 long_options = ["help", "version", " noquota", "add", "users", "groups", "reset", "prototype=", "printer=", "softlimit=", "hardlimit="]399 short_options = "vhl:b:naugrp:P:S:H:" 400 long_options = ["help", "version", "limitby=", "balance=", "noquota", "add", "users", "groups", "reset", "prototype=", "printer=", "softlimit=", "hardlimit="] 352 401 353 402 # Initializes the command line tool … … 369 418 options["reset"] = options["r"] or options["reset"] 370 419 options["noquota"] = options["n"] or options["noquota"] 420 options["limitby"] = options["l"] or options["limitby"] 421 options["balance"] = options["b"] or options["balance"] 371 422 372 423 if options["help"] : … … 380 431 elif options["noquota"] and (options["prototype"] or options["hardlimit"] or options["softlimit"]) : 381 432 raise PyKotaToolError, _("incompatible options, see help.") 433 elif options["groups"] and options["balance"] : 434 raise PyKotaToolError, _("incompatible options, see help.") 382 435 elif options["groups"] : 383 436 raise PyKotaToolError, _("option --groups is currently not implemented.") -
pykota/trunk/NEWS
r915 r917 32 32 jobs as well as charge users per page and/or per job, 33 33 and track users' account balance. 34 35 - edpykota now accepts much more command line options to 36 use the new functionnalities. See edpykota --help for 37 details. 34 38 35 39 - The installation script now allows to install the sample -
pykota/trunk/pykota/storages/sql.py
r915 r917 21 21 # 22 22 # $Log$ 23 # Revision 1.24 2003/04/15 13:55:28 jalet 24 # Options --limitby and --balance added to edpykota 25 # 23 26 # Revision 1.23 2003/04/15 11:30:57 jalet 24 27 # More work done on money print charging. … … 232 235 self.increaseUserBalance(userid, difference) 233 236 234 def limitUserBy Quota(self, userid) :235 """Limits a given user based on print quota."""236 self.doQuery("UPDATE users SET limitby= 'quota' WHERE id=%s" % self.doQuote(userid))237 238 def limit UserByBalance(self, userid) :239 """Limits a given user based on account balance."""240 self.doQuery("UPDATE users SET limitby='balance' WHERE id=%s" % self.doQuote(userid))237 def limitUserBy(self, userid, limitby) : 238 """Limits a given user based either on print quota or on account balance.""" 239 self.doQuery("UPDATE users SET limitby=%s WHERE id=%s" % (self.doQuote(limitby), self.doQuote(userid))) 240 241 def limitGroupBy(self, groupid, limitby) : 242 """Limits a given group based either on print quota or on sum of its users' account balances.""" 243 self.doQuery("UPDATE groups SET limitby=%s WHERE id=%s" % (self.doQuote(limitby), self.doQuote(groupid))) 241 244 242 245 def setUserPQuota(self, userid, printerid, softlimit, hardlimit) :