- Timestamp:
- 06/18/04 15:34:49 (20 years ago)
- Location:
- pykota/trunk
- Files:
-
- 9 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r1542 r1546 24 24 # 25 25 # $Log$ 26 # Revision 1.64 2004/06/18 13:34:46 jalet 27 # Now all tracebacks include PyKota's version number 28 # 26 29 # Revision 1.63 2004/06/17 13:26:50 jalet 27 30 # Better exception handling code … … 252 255 import time 253 256 254 from pykota.tool import PyKotaFilterOrBackend, PyKotaToolError 257 from pykota.tool import PyKotaFilterOrBackend, PyKotaToolError, crashed 255 258 from pykota.config import PyKotaConfigError 256 259 from pykota.storage import PyKotaStorageError … … 645 648 return retcode 646 649 647 def crashed(message) :648 """Minimal crash method."""649 import traceback650 lines = []651 for line in traceback.format_exception(*sys.exc_info()) :652 lines.extend([l for l in line.split("\n") if l])653 msg = "ERROR: ".join(["%s\n" % l for l in ([message] + lines)])654 sys.stderr.write(msg)655 sys.stderr.flush()656 657 650 if __name__ == "__main__" : 658 651 # This is a CUPS backend, we should act and die like a CUPS backend -
pykota/trunk/bin/edpykota
r1526 r1546 24 24 # 25 25 # $Log$ 26 # Revision 1.75 2004/06/18 13:34:47 jalet 27 # Now all tracebacks include PyKota's version number 28 # 26 29 # Revision 1.74 2004/06/07 18:43:40 jalet 27 30 # Fixed over-verbose exits when displaying help or version number … … 267 270 268 271 from pykota import version 269 from pykota.tool import PyKotaTool, PyKotaToolError 272 from pykota.tool import PyKotaTool, PyKotaToolError, crashed 270 273 from pykota.config import PyKotaConfigError 271 274 from pykota.storage import PyKotaStorageError … … 704 707 editor.crashed("edpykota failed") 705 708 except : 706 pass709 crashed("edpykota failed") 707 710 retcode = -1 708 711 -
pykota/trunk/bin/pkhint
r1526 r1546 24 24 # 25 25 # $Log$ 26 # Revision 1.11 2004/06/18 13:34:48 jalet 27 # Now all tracebacks include PyKota's version number 28 # 26 29 # Revision 1.10 2004/06/07 18:43:40 jalet 27 30 # Fixed over-verbose exits when displaying help or version number … … 65 68 66 69 from pykota import version 67 from pykota.tool import PyKotaTool, PyKotaToolError70 from pykota.tool import PyKotaTool, PyKotaToolError, crashed 68 71 from pykota.config import PyKotaConfigError 69 72 from pykota.storage import PyKotaStorageError … … 280 283 manager.crashed("pkhint failed") 281 284 except : 282 pass285 crashed("pkhint failed") 283 286 retcode = -1 284 287 -
pykota/trunk/bin/pkprinters
r1526 r1546 24 24 # 25 25 # $Log$ 26 # Revision 1.11 2004/06/18 13:34:48 jalet 27 # Now all tracebacks include PyKota's version number 28 # 26 29 # Revision 1.10 2004/06/07 18:43:40 jalet 27 30 # Fixed over-verbose exits when displaying help or version number … … 63 66 64 67 from pykota import version 65 from pykota.tool import PyKotaTool, PyKotaToolError 68 from pykota.tool import PyKotaTool, PyKotaToolError, crashed 66 69 from pykota.config import PyKotaConfigError 67 70 from pykota.storage import PyKotaStorageError … … 269 272 manager.crashed("pkprinters failed") 270 273 except : 271 pass274 crashed("pkprinters failed") 272 275 retcode = -1 273 276 -
pykota/trunk/bin/pykotme
r1526 r1546 24 24 # 25 25 # $Log$ 26 # Revision 1.12 2004/06/18 13:34:49 jalet 27 # Now all tracebacks include PyKota's version number 28 # 26 29 # Revision 1.11 2004/06/07 18:43:40 jalet 27 30 # Fixed over-verbose exits when displaying help or version number … … 72 75 73 76 from pykota import version 74 from pykota.tool import PyKotaTool, PyKotaToolError 77 from pykota.tool import PyKotaTool, PyKotaToolError, crashed 75 78 from pykota.config import PyKotaConfigError 76 79 from pykota.storage import PyKotaStorageError … … 200 203 sender.crashed("pykotme failed") 201 204 except : 202 pass205 crashed("pykotme failed") 203 206 retcode = -1 204 207 -
pykota/trunk/bin/repykota
r1526 r1546 24 24 # 25 25 # $Log$ 26 # Revision 1.49 2004/06/18 13:34:49 jalet 27 # Now all tracebacks include PyKota's version number 28 # 26 29 # Revision 1.48 2004/06/07 18:43:41 jalet 27 30 # Fixed over-verbose exits when displaying help or version number … … 189 192 190 193 from pykota import version 191 from pykota.tool import PyKotaTool, PyKotaToolError 194 from pykota.tool import PyKotaTool, PyKotaToolError, crashed 192 195 from pykota.config import PyKotaConfigError 193 196 from pykota.storage import PyKotaStorageError … … 322 325 reportTool.crashed("repykota failed") 323 326 except : 324 pass327 crashed("repykota failed") 325 328 retcode = -1 326 329 -
pykota/trunk/bin/warnpykota
r1526 r1546 24 24 # 25 25 # $Log$ 26 # Revision 1.29 2004/06/18 13:34:49 jalet 27 # Now all tracebacks include PyKota's version number 28 # 26 29 # Revision 1.28 2004/06/07 18:43:41 jalet 27 30 # Fixed over-verbose exits when displaying help or version number … … 121 124 122 125 from pykota import version 123 from pykota.tool import PyKotaTool, PyKotaToolError 126 from pykota.tool import PyKotaTool, PyKotaToolError, crashed 124 127 from pykota.config import PyKotaConfigError 125 128 from pykota.storage import PyKotaStorageError … … 261 264 sender.crashed("warnpykota failed") 262 265 except : 263 pass266 crashed("warnpykota failed") 264 267 retcode = -1 265 268 -
pykota/trunk/NEWS
r1545 r1546 24 24 - 1.19alpha23 : 25 25 26 - Messages sent by the crashrecipient directive now include 27 PyKota's version number. 26 - All tracebacks now include PyKota's version number. 28 27 29 28 - 1.19alpha22 : -
pykota/trunk/pykota/tool.py
r1545 r1546 22 22 # 23 23 # $Log$ 24 # Revision 1.104 2004/06/18 13:34:49 jalet 25 # Now all tracebacks include PyKota's version number 26 # 24 27 # Revision 1.103 2004/06/18 13:17:26 jalet 25 28 # Now includes PyKota's version number in messages sent by the crashrecipient … … 411 414 __str__ = __repr__ 412 415 416 def crashed(message) : 417 """Minimal crash method.""" 418 import traceback 419 lines = [] 420 for line in traceback.format_exception(*sys.exc_info()) : 421 lines.extend([l for l in line.split("\n") if l]) 422 msg = "ERROR: ".join(["%s\n" % l for l in (["ERROR: PyKota v%s" % version.__version__, message] + lines)]) 423 sys.stderr.write(msg) 424 sys.stderr.flush() 425 return msg 426 413 427 class PyKotaTool : 414 428 """Base class for all PyKota command line tools.""" … … 470 484 def crashed(self, message) : 471 485 """Outputs a crash message, and optionally sends it to software author.""" 472 import traceback 473 lines = [] 474 for line in traceback.format_exception(*sys.exc_info()) : 475 lines.extend([l for l in line.split("\n") if l]) 476 msg = "ERROR: ".join(["%s\n" % l for l in ([message] + lines)]) 477 sys.stderr.write(msg) 478 sys.stderr.flush() 486 msg = crashed(message) 479 487 try : 480 488 crashrecipient = self.config.getCrashRecipient() 481 489 if crashrecipient : 482 490 admin = self.config.getAdminMail("global") # Nice trick, isn't it ? 483 fullmessage = "========== Traceback for PyKota v%s:\n\n%s\n\n========== sys.argv :\n\n%s\n\n========== Environment :\n\n%s\n" % \484 ( version.__version__,msg, \491 fullmessage = "========== Traceback :\n\n%s\n\n========== sys.argv :\n\n%s\n\n========== Environment :\n\n%s\n" % \ 492 (msg, \ 485 493 "\n".join([" %s" % repr(a) for a in sys.argv]), \ 486 494 "\n".join([" %s=%s" % (k, v) for (k, v) in os.environ.items()])) 487 495 server = smtplib.SMTP(self.smtpserver) 488 server.sendmail(admin, [admin, crashrecipient], "From: %s\nTo: %s\nCc: %s\nSubject: PyKota crash traceback !\n\n%s" % (admin, crashrecipient, admin, fullmessage)) 496 server.sendmail(admin, [admin, crashrecipient], \ 497 "From: %s\nTo: %s\nCc: %s\nSubject: PyKota crash traceback !\n\n%s" % \ 498 (admin, crashrecipient, admin, fullmessage)) 489 499 server.quit() 490 500 except :