- Timestamp:
- 10/05/08 22:50:54 (16 years ago)
- Location:
- pykota/trunk
- Files:
-
- 1 added
- 7 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/edpykota
r3432 r3434 30 30 from pykota.commandline import PyKotaOptionParser 31 31 from pykota.errors import PyKotaCommandLineError 32 from pykota.tool import P ercent, PyKotaTool32 from pykota.tool import PyKotaTool 33 33 from pykota.storage import StorageUserPQuota, StorageGroupPQuota 34 from pykota.progressbar import Percent 34 35 35 36 class EdPyKota(PyKotaTool) : -
pykota/trunk/bin/pkbcodes
r3417 r3434 32 32 from pykota.commandline import PyKotaOptionParser 33 33 from pykota.errors import PyKotaCommandLineError 34 from pykota.tool import P ercent, PyKotaTool34 from pykota.tool import PyKotaTool 35 35 from pykota.storage import StorageBillingCode 36 from pykota.progressbar import Percent 36 37 37 38 class PKBcodes(PyKotaTool) : -
pykota/trunk/bin/pkinvoice
r3429 r3434 54 54 from pykota.pdfutils import getPageSize 55 55 from pykota.errors import PyKotaToolError, PyKotaCommandLineError 56 from pykota.tool import Percent, PyKotaTool 56 from pykota.tool import PyKotaTool 57 from pykota.progressbar import Percent 57 58 58 59 class PKInvoice(PyKotaTool) : -
pykota/trunk/bin/pkprinters
r3427 r3434 32 32 from pykota.commandline import PyKotaOptionParser 33 33 from pykota.errors import PyKotaCommandLineError 34 from pykota.tool import P ercent, PyKotaTool34 from pykota.tool import PyKotaTool 35 35 from pykota.storage import StoragePrinter 36 from pykota.progressbar import Percent 36 37 37 38 from pkipplib import pkipplib -
pykota/trunk/bin/pkrefund
r3429 r3434 53 53 from pykota.pdfutils import getPageSize 54 54 from pykota.errors import PyKotaToolError, PyKotaCommandLineError 55 from pykota.tool import Percent, PyKotaTool 55 from pykota.tool import PyKotaTool 56 from pykota.progressbar import Percent 56 57 57 58 class PKRefund(PyKotaTool) : -
pykota/trunk/bin/pkusers
r3432 r3434 33 33 from pykota.commandline import PyKotaOptionParser 34 34 from pykota.errors import PyKotaCommandLineError 35 from pykota.tool import P ercent, PyKotaTool35 from pykota.tool import PyKotaTool 36 36 from pykota.storage import StorageUser, StorageGroup 37 from pykota.progressbar import Percent 37 38 38 39 class PKUsers(PyKotaTool) : -
pykota/trunk/pykota/tool.py
r3432 r3434 42 42 from pykota import config, storage, logger 43 43 from pykota.version import __version__, __author__, __years__, __gplblurb__ 44 45 class Percent :46 """A class to display progress."""47 def __init__(self, app, size=None) :48 """Initializes the engine."""49 self.isatty = sys.stdout.isatty()50 self.app = app51 self.size = None52 if size :53 self.setSize(size)54 self.previous = None55 self.before = time.time()56 57 def setSize(self, size) :58 """Sets the total size."""59 self.number = 060 self.size = size61 if size :62 self.factor = 100.0 / float(size)63 64 def display(self, msg) :65 """Displays the value."""66 if self.isatty :67 self.app.display(msg)68 sys.stdout.flush()69 70 def oneMore(self) :71 """Increments internal counter."""72 if self.size :73 self.number += 174 percent = "%.02f" % (float(self.number) * self.factor)75 if percent != self.previous : # optimize for large number of items76 self.display("\r%s%%" % percent)77 self.previous = percent78 79 def done(self) :80 """Displays the 'done' message."""81 after = time.time()82 if self.size :83 try :84 speed = self.size / ((after - self.before) + 0.00000000001) # adds an epsilon to avoid an user's problem I can't reproduce...85 except ZeroDivisionError :86 speed = 1 # Fake value in case of division by zero, shouldn't happen anyway with the epsilon above...87 self.display("\r100.00%%\r \r%s. %s : %.2f %s.\n" \88 % (_("Done"), _("Average speed"), speed, _("entries per second")))89 else :90 self.display("\r100.00%%\r \r%s.\n" % _("Done"))91 44 92 45 class Tool : … … 342 295 for c in list(invalidchars) : 343 296 if c in name : 344 return 0345 return 1297 return False 298 return True 346 299 347 300 def _checkUserPQuota(self, userpquota) : … … 466 419 467 420 # indicates that a warning needs to be sent 468 warned = 0421 warned = False 469 422 470 423 # first we check any group the user is a member of … … 480 433 return action 481 434 elif action == "WARN" : 482 warned = 1435 warned = True 483 436 484 437 # Then we check the user's account balance … … 515 468 else : 516 469 # Then check the user quota on current printer and all its parents. 517 policyallowed = 0470 policyallowed = False 518 471 for upquota in [ userpquota ] + userpquota.ParentPrintersUserPQuota : 519 472 action = self._checkUserPQuota(upquota) … … 521 474 return action 522 475 elif action == "WARN" : 523 warned = 1476 warned = True 524 477 elif action == "POLICY_ALLOW" : 525 policyallowed = 1478 policyallowed = True 526 479 if warned : 527 480 return "WARN"