Change error reporting from exceptional.io to a SquareSquash instance at bugs.mcedit.net.
Exceptional.io is nice, but it is not appropriate for versioned desktop apps because it is designed for web apps where the latest version is the only deployed version.
This commit is contained in:
parent
4f37766e20
commit
b3042cec46
@ -106,36 +106,78 @@ def sanitize(s):
|
|||||||
return s
|
return s
|
||||||
|
|
||||||
def get_backtrace():
|
def get_backtrace():
|
||||||
backtrace = traceback.format_exc()
|
tb = sys.exc_traceback
|
||||||
try:
|
backtrace = []
|
||||||
backtrace = sanitize(backtrace)
|
for filename, lineno, name, line, selfstr in extract_tb(tb):
|
||||||
|
backtrace.append({
|
||||||
|
"file":filename,
|
||||||
|
"line":lineno,
|
||||||
|
"symbol":name,
|
||||||
|
})
|
||||||
|
|
||||||
except Exception, e:
|
return backtrace
|
||||||
print repr(e), "while scrubbing user directories from crash log! Error not reported."
|
|
||||||
raise
|
|
||||||
|
|
||||||
return backtrace.split('\n')
|
|
||||||
|
|
||||||
def json_crash_report():
|
def json_crash_report():
|
||||||
|
"""
|
||||||
|
fields = arguments[1] || new Object();
|
||||||
|
fields.api_key = this.options.APIKey;
|
||||||
|
fields.environment = this.options.environment;
|
||||||
|
fields.client = "javascript";
|
||||||
|
fields.revision = this.options.revision;
|
||||||
|
fields.class_name = error.type || error.name;
|
||||||
|
if (!error.name && (matches = error.message.match(/^(Uncaught )?(\w+): (.+)/))) {
|
||||||
|
fields.class_name = matches[2];
|
||||||
|
fields.message = matches[3];
|
||||||
|
} else {
|
||||||
|
fields.message = error.message;
|
||||||
|
}
|
||||||
|
if ((_ref5 = fields.class_name) == null) {
|
||||||
|
fields.class_name = 'Error';
|
||||||
|
}
|
||||||
|
fields.backtraces = buildBacktrace(error.stack);
|
||||||
|
fields.capture_method = error.mode;
|
||||||
|
fields.occurred_at = ISODateString(new Date());
|
||||||
|
fields.schema = window.location.protocol.replace(/:$/, '');
|
||||||
|
fields.host = window.location.hostname;
|
||||||
|
if (window.location.port.length > 0) {
|
||||||
|
fields.port = window.location.port;
|
||||||
|
}
|
||||||
|
fields.path = window.location.pathname;
|
||||||
|
fields.query = window.location.search;
|
||||||
|
if (window.location.hash !== '') {
|
||||||
|
fields.fragment = window.location.hash;
|
||||||
|
}
|
||||||
|
fields.user_agent = navigator.userAgent;
|
||||||
|
fields.screen_width = screen.width;
|
||||||
|
fields.screen_height = screen.height;
|
||||||
|
fields.window_width = window.innerWidth;
|
||||||
|
fields.window_height = window.innerHeight;
|
||||||
|
fields.color_depth = screen.colorDepth;
|
||||||
|
:return:
|
||||||
|
:rtype:
|
||||||
|
"""
|
||||||
exc_class, exc_value, exc_tb = sys.exc_info()
|
exc_class, exc_value, exc_tb = sys.exc_info()
|
||||||
|
|
||||||
report = {}
|
fields = {}
|
||||||
# We don't handle requests, so repurpose the request fields for release info.
|
fields['build'] = release.release
|
||||||
request = report['request'] = {}
|
fields['client'] = 'MCEdit Client(?)'
|
||||||
request['controller'] = release.release
|
|
||||||
|
|
||||||
exception = report['exception'] = {}
|
fields['backtraces'] = [{
|
||||||
exception['backtrace'] = get_backtrace()
|
"name":"Crashed Thread",
|
||||||
exception['exception_class'] = exc_class.__name__
|
"faulted": True,
|
||||||
|
"backtrace": get_backtrace(),
|
||||||
|
}]
|
||||||
|
|
||||||
|
fields['class_name'] = exc_class.__name__
|
||||||
if isinstance(exc_value, UnicodeError):
|
if isinstance(exc_value, UnicodeError):
|
||||||
exception['message'] = exc_class.__name__
|
fields['message'] = exc_class.__name__
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
exception['message'] = sanitize(str(exc_value))
|
fields['message'] = sanitize(str(exc_value))
|
||||||
except:
|
except:
|
||||||
exception['message'] = ""
|
fields['message'] = ""
|
||||||
|
|
||||||
exception['occurred_at'] = datetime.now().isoformat()
|
fields['occurred_at'] = datetime.now().isoformat()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.getcwdu().encode('ascii')
|
os.getcwdu().encode('ascii')
|
||||||
@ -143,64 +185,65 @@ def json_crash_report():
|
|||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
ascii_cwd = False
|
ascii_cwd = False
|
||||||
|
|
||||||
app_env = report['application_environment'] = {}
|
fields['environment'] = "development"
|
||||||
app_env['application_root_directory'] = "ASCII" if ascii_cwd else "Unicode"
|
fields['application_root_directory'] = "ASCII" if ascii_cwd else "Unicode"
|
||||||
app_env['framework'] = 'mcedit'
|
fields['language_version'] = sys.version
|
||||||
app_env['language'] = 'python'
|
|
||||||
app_env['language_version'] = sys.version
|
|
||||||
|
|
||||||
env = app_env['env'] = collections.OrderedDict()
|
fields['api_key'] = "6ea52b17-ac76-4fd8-8db4-2d7303473ca2"
|
||||||
|
fields['OS_NAME'] = os.name
|
||||||
|
fields['OS_VERSION'] = platform.version()
|
||||||
|
fields['OS_ARCH'] = platform.architecture()
|
||||||
|
fields['OS_PLATFORM'] = platform.platform()
|
||||||
|
fields['OS_CPU'] = platform.processor()
|
||||||
|
|
||||||
env['OS_NAME'] = os.name,
|
fields['FS_ENCODING'] = sys.getfilesystemencoding()
|
||||||
env['OS_VERSION'] = platform.version()
|
|
||||||
env['OS_ARCH'] = platform.architecture()
|
|
||||||
env['OS_PLATFORM'] = platform.platform()
|
|
||||||
env['OS_CPU'] = platform.processor()
|
|
||||||
|
|
||||||
env['FS_ENCODING'] = sys.getfilesystemencoding()
|
|
||||||
|
|
||||||
if 'LANG' in os.environ:
|
if 'LANG' in os.environ:
|
||||||
env['LANG'] = os.environ['LANG']
|
fields['LANG'] = os.environ['LANG']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from albow import root
|
from albow import root
|
||||||
env['FRAMES'] = str(root.get_root().frames)
|
fields['FRAMES'] = str(root.get_root().frames)
|
||||||
except:
|
except:
|
||||||
log.info("Can't get frame count")
|
log.info("Can't get frame count")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from OpenGL import GL
|
from OpenGL import GL
|
||||||
env['GL_VERSION'] = GL.glGetString(GL.GL_VERSION)
|
fields['GL_VERSION'] = GL.glGetString(GL.GL_VERSION)
|
||||||
except:
|
except:
|
||||||
log.info("Can't get GL_VERSION")
|
log.info("Can't get GL_VERSION")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from OpenGL import GL
|
from OpenGL import GL
|
||||||
env['GL_VENDOR'] = GL.glGetString(GL.GL_VENDOR)
|
fields['GL_VENDOR'] = GL.glGetString(GL.GL_VENDOR)
|
||||||
except:
|
except:
|
||||||
log.info("Can't get GL_VENDOR")
|
log.info("Can't get GL_VENDOR")
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from OpenGL import GL
|
from OpenGL import GL
|
||||||
env['GL_RENDERER'] = GL.glGetString(GL.GL_RENDERER)
|
fields['GL_RENDERER'] = GL.glGetString(GL.GL_RENDERER)
|
||||||
except:
|
except:
|
||||||
log.info("Can't get GL_RENDERER")
|
log.info("Can't get GL_RENDERER")
|
||||||
|
|
||||||
return json.dumps(report)
|
return json.dumps(fields)
|
||||||
|
|
||||||
def post_crash_report():
|
def post_crash_report():
|
||||||
"""
|
"""
|
||||||
POST http://api.exceptional.io/api/errors?api_key=YOUR_API_KEY&protocol_version=5
|
|
||||||
|
|
||||||
Note: protocol_version 5 means use zlib compression.
|
body = JSON.stringify(fields);
|
||||||
|
this.HTTPTransmit(this.options.APIHost + this.options.notifyPath, [['Content-Type', 'application/json']], body);
|
||||||
"""
|
"""
|
||||||
|
|
||||||
report = json_crash_report()
|
report = json_crash_report()
|
||||||
|
|
||||||
body = zlib.compress(report)
|
#conn = httplib.HTTPConnection("192.168.1.108", 3000)
|
||||||
conn = httplib.HTTPConnection("api.exceptional.io")
|
#conn.request("POST", "http://192.168.1.108:3000/bugs", body)
|
||||||
conn.request("POST", "http://api.exceptional.io/api/errors?api_key=%s&protocol_version=5" % EXCEPTIONAL_API_KEY, body)
|
conn = httplib.HTTPConnection("bugs.mcedit.net")
|
||||||
|
headers = { "Content-type": "application/octet-stream" }
|
||||||
|
|
||||||
|
conn.request("POST", "/bugs.php?foo=bar", report, headers)
|
||||||
|
|
||||||
|
|
||||||
resp = conn.getresponse()
|
resp = conn.getresponse()
|
||||||
print "Response status: %s\n Response data: %s\n" % (resp.status, resp.read())
|
print "Response status: %s\n Response data: %s\n" % (resp.status, resp.read())
|
||||||
@ -210,7 +253,7 @@ def post_crash_report():
|
|||||||
def reportException():
|
def reportException():
|
||||||
try:
|
try:
|
||||||
import config
|
import config
|
||||||
if config.config.get("Settings", "report crashes new"):
|
if config.config.getboolean("Settings", "report crashes new"):
|
||||||
post_crash_report()
|
post_crash_report()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print "Error while reporting crash: ", repr(e)
|
print "Error while reporting crash: ", repr(e)
|
||||||
|
@ -949,6 +949,8 @@ class MCEdit(GLViewport):
|
|||||||
Settings.reportCrashesAsked.set(True)
|
Settings.reportCrashesAsked.set(True)
|
||||||
|
|
||||||
config.saveConfig()
|
config.saveConfig()
|
||||||
|
if "-causeError" in sys.argv:
|
||||||
|
raise ValueError, "Error requested via -causeError"
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
@ -8,7 +8,7 @@ def get_version():
|
|||||||
"""
|
"""
|
||||||
if not os.path.exists('RELEASE-VERSION'):
|
if not os.path.exists('RELEASE-VERSION'):
|
||||||
try:
|
try:
|
||||||
return subprocess.check_output('git describe --tags --match=*.*.*'.split())
|
return subprocess.check_output('git describe --tags --match=*.*.*'.split()).strip()
|
||||||
except:
|
except:
|
||||||
return 'unknown'
|
return 'unknown'
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user