- Timestamp:
- 02/02/08 18:56:16 (17 years ago)
- Location:
- pykota/trunk
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r3306 r3324 227 227 228 228 if not self.checkCUPSVersion() : 229 self.printInfo("BEWARE : CUPS is too old. You mustuse CUPS v1.3.4 or higher.", "error")229 self.printInfo("BEWARE : CUPS is too old. You should use CUPS v1.3.4 or higher.", "error") 230 230 231 231 self.PrinterName = os.environ.get("PRINTER", "") … … 259 259 self.UserName = self.Ticket.OriginatingUserName 260 260 261 self.DataFile = os.path.join(self.Directory, "%s-%s-%s-%s" % \262 (self.myname, self.PrinterName, self.UserName, self.Ticket.JobId)) 261 self.DataFile = (os.path.join(self.Directory, "%s-%s-%s-%s" % \ 262 (self.myname, self.PrinterName, self.UserName, self.Ticket.JobId)).encode(sys.getfilesystemencoding(), "replace") 263 263 264 264 muststartwith = "%s:" % self.myname … … 301 301 self.OriginalJobBillingCode = None 302 302 else : 303 self.Ticket.BillingCode = self.UTF8ToUserCharset(self.Ticket.BillingCode).decode("UTF-8")304 303 self.OriginalJobBillingCode = self.Ticket.BillingCode[:] 305 304 … … 416 415 action = "CANCEL" 417 416 elif line.startswith("USERNAME=") : 418 username = self.userCharsetToUTF8(line.split("=", 1)[1].strip()).decode("UTF-8")417 username = line.split("=", 1)[1].strip().decode(self.charset, "replace") 419 418 self.logdebug("Seen new username [%s]" % username) 420 419 elif line.startswith("BILLINGCODE=") : 421 billingcode = self.userCharsetToUTF8(line.split("=", 1)[1].strip()).decode("UTF-8")420 billingcode = line.split("=", 1)[1].strip().decode(self.charset, "replace") 422 421 self.logdebug("Seen new billing code [%s]" % billingcode) 423 422 elif line.startswith("REASON=") : 424 reason = self.userCharsetToUTF8(line.split("=", 1)[1].strip()).decode("UTF-8")423 reason = line.split("=", 1)[1].strip().decode(self.charset, "replace") 425 424 self.logdebug("Seen new reason [%s]" % reason) 426 425 except IOError, msg : -
pykota/trunk/bin/pknotify
r3295 r3324 160 160 class PyKotaNotify(Tool) : 161 161 """A class for pknotify.""" 162 def UTF8ToUserCharset(self, text) : 163 """Converts from UTF-8 to user's charset.""" 164 if text is None : 165 return None 166 else : 167 return text.decode("UTF-8", "replace").encode(self.charset, "replace") 168 169 def userCharsetToUTF8(self, text) : 170 """Converts from user's charset to UTF-8.""" 171 if text is None : 172 return None 173 else : 174 return text.decode(self.charset, "replace").encode("UTF-8", "replace") 175 162 176 def sanitizeMessage(self, msg) : 163 177 """Replaces \\n and returns a messagee in xmlrpclib Binary format.""" -
pykota/trunk/pykota/tool.py
r3317 r3324 149 149 arguments = " ".join(['"%s"' % arg for arg in sys.argv]) 150 150 self.logdebug("Command line arguments : %s" % arguments) 151 152 def UTF8ToUserCharset(self, text) :153 """Converts from UTF-8 to user's charset."""154 if text is None :155 return None156 else :157 return text.decode("UTF-8", "replace").encode(self.charset, "replace")158 159 def userCharsetToUTF8(self, text) :160 """Converts from user's charset to UTF-8."""161 if text is None :162 return None163 else :164 return text.decode(self.charset, "replace").encode("UTF-8", "replace")165 151 166 152 def display(self, message) :