Changeset 1546 for pykota

Show
Ignore:
Timestamp:
06/18/04 15:34:49 (20 years ago)
Author:
jalet
Message:

Now all tracebacks include PyKota's version number

Location:
pykota/trunk
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r1542 r1546  
    2424# 
    2525# $Log$ 
     26# Revision 1.64  2004/06/18 13:34:46  jalet 
     27# Now all tracebacks include PyKota's version number 
     28# 
    2629# Revision 1.63  2004/06/17 13:26:50  jalet 
    2730# Better exception handling code 
     
    252255import time 
    253256 
    254 from pykota.tool import PyKotaFilterOrBackend, PyKotaToolError 
     257from pykota.tool import PyKotaFilterOrBackend, PyKotaToolError, crashed 
    255258from pykota.config import PyKotaConfigError 
    256259from pykota.storage import PyKotaStorageError 
     
    645648        return retcode     
    646649     
    647 def crashed(message) :     
    648     """Minimal crash method.""" 
    649     import traceback 
    650     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  
    657650if __name__ == "__main__" :     
    658651    # This is a CUPS backend, we should act and die like a CUPS backend 
  • pykota/trunk/bin/edpykota

    r1526 r1546  
    2424# 
    2525# $Log$ 
     26# Revision 1.75  2004/06/18 13:34:47  jalet 
     27# Now all tracebacks include PyKota's version number 
     28# 
    2629# Revision 1.74  2004/06/07 18:43:40  jalet 
    2730# Fixed over-verbose exits when displaying help or version number 
     
    267270 
    268271from pykota import version 
    269 from pykota.tool import PyKotaTool, PyKotaToolError 
     272from pykota.tool import PyKotaTool, PyKotaToolError, crashed 
    270273from pykota.config import PyKotaConfigError 
    271274from pykota.storage import PyKotaStorageError 
     
    704707            editor.crashed("edpykota failed") 
    705708        except :     
    706             pass 
     709            crashed("edpykota failed") 
    707710        retcode = -1 
    708711 
  • pykota/trunk/bin/pkhint

    r1526 r1546  
    2424# 
    2525# $Log$ 
     26# Revision 1.11  2004/06/18 13:34:48  jalet 
     27# Now all tracebacks include PyKota's version number 
     28# 
    2629# Revision 1.10  2004/06/07 18:43:40  jalet 
    2730# Fixed over-verbose exits when displaying help or version number 
     
    6568 
    6669from pykota import version 
    67 from pykota.tool import PyKotaTool,PyKotaToolError 
     70from pykota.tool import PyKotaTool, PyKotaToolError, crashed 
    6871from pykota.config import PyKotaConfigError 
    6972from pykota.storage import PyKotaStorageError 
     
    280283            manager.crashed("pkhint failed") 
    281284        except :     
    282             pass 
     285            crashed("pkhint failed") 
    283286        retcode = -1 
    284287 
  • pykota/trunk/bin/pkprinters

    r1526 r1546  
    2424# 
    2525# $Log$ 
     26# Revision 1.11  2004/06/18 13:34:48  jalet 
     27# Now all tracebacks include PyKota's version number 
     28# 
    2629# Revision 1.10  2004/06/07 18:43:40  jalet 
    2730# Fixed over-verbose exits when displaying help or version number 
     
    6366 
    6467from pykota import version 
    65 from pykota.tool import PyKotaTool, PyKotaToolError 
     68from pykota.tool import PyKotaTool, PyKotaToolError, crashed 
    6669from pykota.config import PyKotaConfigError 
    6770from pykota.storage import PyKotaStorageError 
     
    269272            manager.crashed("pkprinters failed") 
    270273        except :     
    271             pass 
     274            crashed("pkprinters failed") 
    272275        retcode = -1 
    273276 
  • pykota/trunk/bin/pykotme

    r1526 r1546  
    2424# 
    2525# $Log$ 
     26# Revision 1.12  2004/06/18 13:34:49  jalet 
     27# Now all tracebacks include PyKota's version number 
     28# 
    2629# Revision 1.11  2004/06/07 18:43:40  jalet 
    2730# Fixed over-verbose exits when displaying help or version number 
     
    7275 
    7376from pykota import version 
    74 from pykota.tool import PyKotaTool, PyKotaToolError 
     77from pykota.tool import PyKotaTool, PyKotaToolError, crashed 
    7578from pykota.config import PyKotaConfigError 
    7679from pykota.storage import PyKotaStorageError 
     
    200203            sender.crashed("pykotme failed") 
    201204        except :     
    202             pass 
     205            crashed("pykotme failed") 
    203206        retcode = -1 
    204207 
  • pykota/trunk/bin/repykota

    r1526 r1546  
    2424# 
    2525# $Log$ 
     26# Revision 1.49  2004/06/18 13:34:49  jalet 
     27# Now all tracebacks include PyKota's version number 
     28# 
    2629# Revision 1.48  2004/06/07 18:43:41  jalet 
    2730# Fixed over-verbose exits when displaying help or version number 
     
    189192 
    190193from pykota import version 
    191 from pykota.tool import PyKotaTool, PyKotaToolError 
     194from pykota.tool import PyKotaTool, PyKotaToolError, crashed 
    192195from pykota.config import PyKotaConfigError 
    193196from pykota.storage import PyKotaStorageError 
     
    322325            reportTool.crashed("repykota failed") 
    323326        except :     
    324             pass 
     327            crashed("repykota failed") 
    325328        retcode = -1 
    326329 
  • pykota/trunk/bin/warnpykota

    r1526 r1546  
    2424# 
    2525# $Log$ 
     26# Revision 1.29  2004/06/18 13:34:49  jalet 
     27# Now all tracebacks include PyKota's version number 
     28# 
    2629# Revision 1.28  2004/06/07 18:43:41  jalet 
    2730# Fixed over-verbose exits when displaying help or version number 
     
    121124 
    122125from pykota import version 
    123 from pykota.tool import PyKotaTool, PyKotaToolError 
     126from pykota.tool import PyKotaTool, PyKotaToolError, crashed 
    124127from pykota.config import PyKotaConfigError 
    125128from pykota.storage import PyKotaStorageError 
     
    261264            sender.crashed("warnpykota failed") 
    262265        except :     
    263             pass 
     266            crashed("warnpykota failed") 
    264267        retcode = -1 
    265268         
  • pykota/trunk/NEWS

    r1545 r1546  
    2424    - 1.19alpha23 : 
    2525     
    26         - Messages sent by the crashrecipient directive now include 
    27           PyKota's version number. 
     26        - All tracebacks now include PyKota's version number. 
    2827           
    2928    - 1.19alpha22 : 
  • pykota/trunk/pykota/tool.py

    r1545 r1546  
    2222# 
    2323# $Log$ 
     24# Revision 1.104  2004/06/18 13:34:49  jalet 
     25# Now all tracebacks include PyKota's version number 
     26# 
    2427# Revision 1.103  2004/06/18 13:17:26  jalet 
    2528# Now includes PyKota's version number in messages sent by the crashrecipient 
     
    411414    __str__ = __repr__ 
    412415     
     416def 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 
    413427class PyKotaTool :     
    414428    """Base class for all PyKota command line tools.""" 
     
    470484    def crashed(self, message) :     
    471485        """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) 
    479487        try : 
    480488            crashrecipient = self.config.getCrashRecipient() 
    481489            if crashrecipient : 
    482490                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, \ 
    485493                                 "\n".join(["    %s" % repr(a) for a in sys.argv]), \ 
    486494                                 "\n".join(["    %s=%s" % (k, v) for (k, v) in os.environ.items()])) 
    487495                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)) 
    489499                server.quit() 
    490500        except :