Better paste metainfo

This commit is contained in:
Florian Bruhin 2014-10-31 07:57:50 +01:00
parent 1c32e72e37
commit 6e4759b65a
2 changed files with 32 additions and 5 deletions

View File

@ -147,14 +147,23 @@ def safe_shlex_split(s):
orig_s, i, s)) # pylint: disable=undefined-loop-variable orig_s, i, s)) # pylint: disable=undefined-loop-variable
def pastebin(text): def pastebin(name, title, text, parent=None):
"""Paste the text into a pastebin and return the URL.""" """Paste the text into a pastebin and return the URL.
Args:
name: The username to post as.
title: The post title.
text: The text to post.
parent: The parent paste to reply to.
"""
api_url = 'http://paste.the-compiler.org/api/' api_url = 'http://paste.the-compiler.org/api/'
data = { data = {
'text': text, 'text': text,
'title': "qutebrowser crash", 'title': title,
'name': "qutebrowser", 'name': name,
} }
if parent is not None:
data['reply'] = parent
encoded_data = urllib.parse.urlencode(data).encode('utf-8') encoded_data = urllib.parse.urlencode(data).encode('utf-8')
create_url = urllib.parse.urljoin(api_url, 'create') create_url = urllib.parse.urljoin(api_url, 'create')
headers = { headers = {

View File

@ -23,6 +23,7 @@
import sys import sys
import html import html
import getpass
import traceback import traceback
import functools import functools
@ -38,6 +39,9 @@ class _CrashDialog(QDialog):
"""Dialog which gets shown after there was a crash. """Dialog which gets shown after there was a crash.
Class attributes:
NAME: The kind of condition we report.
Attributes: Attributes:
These are just here to have a static reference to avoid GCing. These are just here to have a static reference to avoid GCing.
_vbox: The main QVBoxLayout _vbox: The main QVBoxLayout
@ -48,6 +52,8 @@ class _CrashDialog(QDialog):
_crash_info: A list of tuples with title and crash information. _crash_info: A list of tuples with title and crash information.
""" """
NAME = None
def __init__(self, debug, parent=None): def __init__(self, debug, parent=None):
"""Constructor for CrashDialog. """Constructor for CrashDialog.
@ -175,7 +181,13 @@ class _CrashDialog(QDialog):
lines.append(self._debug_log.toPlainText()) lines.append(self._debug_log.toPlainText())
text = '\n\n'.join(lines) text = '\n\n'.join(lines)
try: try:
utils.pastebin(text) user = getpass.getuser()
except Exception as e:
log.misc.exception("Error while getting user")
user = 'unknown'
try:
utils.pastebin(user, "qutebrowser {}".format(self.NAME), text,
parent='90286958') # http://p.cmpl.cc/90286958
except Exception as e: except Exception as e:
log.misc.exception("Error while paste-binning") log.misc.exception("Error while paste-binning")
exc_text = '{}: {}'.format(e.__class__.__name__, e) exc_text = '{}: {}'.format(e.__class__.__name__, e)
@ -214,6 +226,8 @@ class ExceptionCrashDialog(_CrashDialog):
_objects: A list of all QObjects as string. _objects: A list of all QObjects as string.
""" """
NAME = 'exception'
def __init__(self, debug, pages, cmdhist, exc, objects, parent=None): def __init__(self, debug, pages, cmdhist, exc, objects, parent=None):
super().__init__(debug, parent) super().__init__(debug, parent)
self._pages = pages self._pages = pages
@ -294,6 +308,8 @@ class FatalCrashDialog(_CrashDialog):
_log: The log text to display. _log: The log text to display.
""" """
NAME = 'segfault'
def __init__(self, debug, text, parent=None): def __init__(self, debug, text, parent=None):
super().__init__(debug, parent) super().__init__(debug, parent)
self._log = text self._log = text
@ -330,6 +346,8 @@ class ReportDialog(_CrashDialog):
_objects: A list of all QObjects as string. _objects: A list of all QObjects as string.
""" """
NAME = 'report'
def __init__(self, pages, cmdhist, objects, parent=None): def __init__(self, pages, cmdhist, objects, parent=None):
super().__init__(False, parent) super().__init__(False, parent)
self.setAttribute(Qt.WA_DeleteOnClose) self.setAttribute(Qt.WA_DeleteOnClose)