Changeset 773 for pykota/trunk
- Timestamp:
- 02/09/03 14:05:43 (22 years ago)
- Location:
- pykota/trunk/pykota
- Files:
-
- 7 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/config.py
r747 r773 15 15 # 16 16 # $Log$ 17 # Revision 1.7 2003/02/09 13:05:43 jalet 18 # Internationalization continues... 19 # 17 20 # Revision 1.6 2003/02/07 22:00:09 jalet 18 21 # Bad cut&paste … … 71 74 "smtpserver", "method", "gracedelay" ] : 72 75 if not self.config.has_option("global", option) : 73 raise PyKotaConfigError, "Option %s not found in section global of %s"% (option, self.filename)76 raise PyKotaConfigError, _("Option %s not found in section global of %s") % (option, self.filename) 74 77 75 78 # more precise checks 76 79 validloggers = [ "stderr", "system" ] 77 80 if self.config.get("global", "logger").lower() not in validloggers : 78 raise PyKotaConfigError, "Option logger only supports values in %s"% str(validloggers)81 raise PyKotaConfigError, _("Option logger only supports values in %s") % str(validloggers) 79 82 80 83 validmethods = [ "lazy" ] # TODO add more methods 81 84 if self.config.get("global", "method").lower() not in validmethods : 82 raise PyKotaConfigError, "Option method only supports values in %s"% str(validmethods)85 raise PyKotaConfigError, _("Option method only supports values in %s") % str(validmethods) 83 86 84 87 # check all printers now … … 86 89 for poption in [ "requester", "policy" ] : 87 90 if not self.config.has_option(printer, poption) : 88 raise PyKotaConfigError, "Option %s not found in section %s of %s"% (option, printer, self.filename)91 raise PyKotaConfigError, _("Option %s not found in section %s of %s") % (option, printer, self.filename) 89 92 90 93 validpolicies = [ "ALLOW", "DENY" ] 91 94 if self.config.get(printer, "policy").upper() not in validpolicies : 92 raise PyKotaConfigError, "Option policy in section %s only supports values in %s"% (printer, str(validpolicies))95 raise PyKotaConfigError, _("Option policy in section %s only supports values in %s") % (printer, str(validpolicies)) 93 96 94 97 validrequesters = [ "snmp" ] # TODO : add more requesters 95 98 requester = self.config.get(printer, "requester").lower() 96 99 if requester not in validrequesters : 97 raise PyKotaConfigError, "Option requester in section %s only supports values in %s"% (printer, str(validrequesters))100 raise PyKotaConfigError, _("Option requester in section %s only supports values in %s") % (printer, str(validrequesters)) 98 101 if requester == "snmp" : 99 102 for poption in [ "snmpcmnty", "snmpoid" ] : 100 103 if not self.config.has_option(printer, poption) : 101 raise PyKotaConfigError, "Option %s not found in section %s of %s"% (option, printer, self.filename)104 raise PyKotaConfigError, _("Option %s not found in section %s of %s") % (option, printer, self.filename) 102 105 103 106 def getPrinterNames(self) : … … 150 153 return int(gd) 151 154 except ValueError : 152 raise PyKotaConfigError, "Invalid grace delay %s"% gd155 raise PyKotaConfigError, _("Invalid grace delay %s") % gd -
pykota/trunk/pykota/logger.py
r698 r773 15 15 # 16 16 # $Log$ 17 # Revision 1.4 2003/02/09 13:05:43 jalet 18 # Internationalization continues... 19 # 17 20 # Revision 1.3 2003/02/05 22:10:29 jalet 18 21 # Typos … … 47 50 exec "from pykota.loggers import %s as loggingbackend" % backend.lower() 48 51 except ImportError : 49 raise PyKotaLoggingError, "Unsupported logging subsystem %s"% backend52 raise PyKotaLoggingError, _("Unsupported logging subsystem %s") % backend 50 53 else : 51 54 return getattr(loggingbackend, "Logger")() -
pykota/trunk/pykota/requester.py
r698 r773 15 15 # 16 16 # $Log$ 17 # Revision 1.4 2003/02/09 13:05:43 jalet 18 # Internationalization continues... 19 # 17 20 # Revision 1.3 2003/02/05 22:10:29 jalet 18 21 # Typos … … 45 48 exec "from pykota.requesters import %s as requesterbackend" % backend.lower() 46 49 except ImportError : 47 raise PyKotaRequesterError, "Unsupported requester backend %s"% backend50 raise PyKotaRequesterError, _("Unsupported requester backend %s") % backend 48 51 else : 49 52 return getattr(requesterbackend, "Requester")(config, printername) -
pykota/trunk/pykota/requesters/external.py
r745 r773 15 15 # 16 16 # $Log$ 17 # Revision 1.2 2003/02/09 13:05:43 jalet 18 # Internationalization continues... 19 # 17 20 # Revision 1.1 2003/02/07 13:15:01 jalet 18 21 # External requester skeleton added. … … 29 32 """Sets instance vars depending on the current printer.""" 30 33 self.printername = printername 31 raise PyKotaRequesterError, "Requester not implemented yet."34 raise PyKotaRequesterError, _("Requester not implemented yet.") 32 35 33 36 def getPrinterPageCounter(self, hostname) : … … 36 39 Currently uses the snmpget external command. TODO : do it internally 37 40 """ 38 raise PyKotaRequesterError, "Requester not implemented yet."41 raise PyKotaRequesterError, _("Requester not implemented yet.") 39 42 -
pykota/trunk/pykota/requesters/snmp.py
r744 r773 15 15 # 16 16 # $Log$ 17 # Revision 1.4 2003/02/09 13:05:43 jalet 18 # Internationalization continues... 19 # 17 20 # Revision 1.3 2003/02/07 13:12:41 jalet 18 21 # Bad old comment … … 45 48 """ 46 49 if hostname is None : 47 raise PyKotaRequesterError, "Unknown printer address in SNMP(%s, %s) for printer %s"% (self.community, self.oid, self.printername)50 raise PyKotaRequesterError, _("Unknown printer address in SNMP(%s, %s) for printer %s") % (self.community, self.oid, self.printername) 48 51 answer = os.popen("snmpget -c %s -Ov %s %s" % (self.community, hostname, self.oid)) 49 52 try : 50 53 pagecounter = int(answer.readline().split()[-1].strip()) 51 54 except IndexError : 52 raise PyKotaRequesterError, "Unable to query printer %s via SNMP(%s, %s)"% (hostname, self.community, self.oid)55 raise PyKotaRequesterError, _("Unable to query printer %s via SNMP(%s, %s)") % (hostname, self.community, self.oid) 53 56 answer.close() 54 57 return pagecounter -
pykota/trunk/pykota/storage.py
r768 r773 15 15 # 16 16 # $Log$ 17 # Revision 1.6 2003/02/09 13:05:43 jalet 18 # Internationalization continues... 19 # 17 20 # Revision 1.5 2003/02/08 22:39:46 jalet 18 21 # --reset command line option added … … 109 112 exec "from pykota.storages import %s as storagebackend" % backend.lower() 110 113 except ImportError : 111 raise PyKotaStorageError, "Unsupported quota storage backend %s"% backend114 raise PyKotaStorageError, _("Unsupported quota storage backend %s") % backend 112 115 else : 113 116 return getattr(storagebackend, "Storage")(host, database, (asadmin and admin) or user) -
pykota/trunk/pykota/tool.py
r772 r773 15 15 # 16 16 # $Log$ 17 # Revision 1.17 2003/02/09 13:05:43 jalet 18 # Internationalization continues... 19 # 17 20 # Revision 1.16 2003/02/09 12:56:53 jalet 18 21 # Internationalization begins... … … 200 203 def sendMessageToUser(self, username, subject, message) : 201 204 """Sends an email message to a user.""" 202 message += "\n\nPlease contact your system administrator :\n\n\t%s - <%s>\n"% (self.admin, self.adminmail)205 message += _("\n\nPlease contact your system administrator :\n\n\t%s - <%s>\n") % (self.admin, self.adminmail) 203 206 self.sendMessage(username, "Subject: %s\n\n%s" % (subject, message)) 204 207 … … 217 220 else : 218 221 action = "DENY" 219 self.logger.log_message( "Unable to match user %s on printer %s, applying default policy (%s)"% (username, printername, action), "warn")222 self.logger.log_message(_("Unable to match user %s on printer %s, applying default policy (%s)") % (username, printername, action), "warn") 220 223 return (action, None, None) 221 224 else : … … 250 253 """Checks a user quota and send him a message if quota is exceeded on current printer.""" 251 254 pname = printername or self.printername 252 raise PyKotaToolError, "Group quotas are currently not implemented."255 raise PyKotaToolError, _("Group quotas are currently not implemented.") 253 256 254 257 def warnUserPQuota(self, username, printername=None) : … … 259 262 if (grace is not None) and (gracedate is not None) : 260 263 # only when both user and printer are known 261 adminmessage = "Print Quota exceeded for user %s on printer %s"% (username, pname)264 adminmessage = _("Print Quota exceeded for user %s on printer %s") % (username, pname) 262 265 self.logger.log_message(adminmessage) 263 self.sendMessageToUser(username, "Print Quota Exceeded", "You are not allowed to print anymore because\nyour Print Quota is exceeded on printer %s."% pname)266 self.sendMessageToUser(username, _("Print Quota Exceeded"), _("You are not allowed to print anymore because\nyour Print Quota is exceeded on printer %s.") % pname) 264 267 self.sendMessageToAdmin("Print Quota", adminmessage) 265 268 elif action == "WARN" : 266 adminmessage = "Print Quota soft limit exceeded for user %s on printer %s"% (username, pname)269 adminmessage = _("Print Quota soft limit exceeded for user %s on printer %s") % (username, pname) 267 270 self.logger.log_message(adminmessage) 268 self.sendMessageToUser(username, "Print Quota Exceeded", "You will soon be forbidden to print anymore because\nyour Print Quota is almost reached on printer %s."% pname)269 self.sendMessageToAdmin( "Print Quota", adminmessage)271 self.sendMessageToUser(username, _("Print Quota Exceeded"), _("You will soon be forbidden to print anymore because\nyour Print Quota is almost reached on printer %s.") % pname) 272 self.sendMessageToAdmin(_("Print Quota"), adminmessage) 270 273 return action 271 274