/usr/share/pyshared/Wammu/Error.py is in wammu 0.36-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | # -*- coding: UTF-8 -*-
# vim: expandtab sw=4 ts=4 sts=4:
'''
Wammu - Phone manager
Unexpected exception handler
'''
__author__ = 'Michal Čihař'
__email__ = 'michal@cihar.com'
__license__ = '''
Copyright © 2003 - 2010 Michal Čihař
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License version 2 as published by
the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
'''
import traceback
try:
from hashlib import md5 as md5
except ImportError:
from md5 import new as md5
import Wammu.ErrorLog
import Wammu.ErrorMessage
from Wammu.Locales import StrConv
# set later in Wammu.App to have correct parent here
HANDLER_PARENT = None
ERROR_HISTORY = []
def Handler(errtype, value, tback):
"""User friendly error handling """
# prepare traceback text
trace = traceback.extract_tb(tback)
linetrace = traceback.format_list(trace)
texttrace = ''.join(linetrace)
textexc = ''.join(traceback.format_exception_only(errtype, value))
# debug log information
logtext = ''
outf, logname = Wammu.ErrorLog.SaveLog()
if outf is not None:
print 'Created debug log copy in %s for error reporting.' % logname
logtext = '\n%s\n' % _('Debug log was saved for phone communication, if this error appeared during communicating with phone, you are strongly encouraged to include it in bugreport. Debug log is saved in file %s.') % logname
# detection of same errors
tracehash = md5('%s,%s' % (textexc, texttrace)).hexdigest()
if tracehash in ERROR_HISTORY:
print 'Same error already detected, not showing dialog!'
print texttrace
print 'Exception: %s' % textexc
return
ERROR_HISTORY.append(tracehash)
# traceback id (md5 sum of last topmost traceback item inside Wammu - file(function):code)
try:
for trace_line in trace:
if trace_line[0].rfind('Wammu') > -1:
lasttrace = trace_line
traceidtext = '%s(%s):%s' % (
lasttrace[0][lasttrace[0].rfind('Wammu'):],
lasttrace[2],
lasttrace[3])
traceid = md5(traceidtext).hexdigest()
tracetext = '\n%s\n' % (
_('Before submiting please try searching for simmilar bugs on %s')
% ('http://bugs.cihar.com/view_all_set.php?f=3&type=1&search=%s\n'
% traceid))
except:
traceid = 'N/A'
tracetext = ''
# unicode warning
if errtype == UnicodeEncodeError or errtype == UnicodeDecodeError:
unicodewarning = ('\n%s\n' %
_('Unicode encoding error appeared, see question 1 in FAQ, how to solve this.'))
else:
unicodewarning = ''
# prepare message
text = u"""%s
%s
%s%s%s
%s
------------------ Traceback ID -------------------
%s
-------------------- Traceback --------------------
%s-------------------- Exception --------------------
%s---------------------------------------------------
""" % (
_('Unhandled exception appeared.'),
_('If you want to help improving this program, please submit following infomation and description how did it happen to %s. Please report in english, otherwise you will be most likely told to translate you report to english later.') % 'http://bugs.wammu.eu/',
logtext,
tracetext,
unicodewarning,
Wammu.ErrorLog.GetSystemInfo(),
traceid,
StrConv(texttrace),
StrConv(textexc))
# Include exception info in crash file
if outf is not None:
outf.write(text.encode('utf-8'))
outf.close()
# display error
try:
Wammu.ErrorMessage.ErrorMessage(HANDLER_PARENT,
_('Unhandled exception appeared. If you want to help improving this program, please report this together with description how this situation has happened. Please report in english, otherwise you will be most likely told to translate you report to english later.'),
_('Unhandled exception'),
traceid = traceid, autolog = logname,
exception = _('Traceback:\n%(traceback)s\nException: %(exception)s') % {
'traceback': StrConv(texttrace),
'exception' : StrConv(textexc) }).ShowModal()
except:
print text
|