Better paste metainfo
This commit is contained in:
parent
1c32e72e37
commit
6e4759b65a
@ -147,14 +147,23 @@ def safe_shlex_split(s):
|
||||
orig_s, i, s)) # pylint: disable=undefined-loop-variable
|
||||
|
||||
|
||||
def pastebin(text):
|
||||
"""Paste the text into a pastebin and return the URL."""
|
||||
def pastebin(name, title, text, parent=None):
|
||||
"""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/'
|
||||
data = {
|
||||
'text': text,
|
||||
'title': "qutebrowser crash",
|
||||
'name': "qutebrowser",
|
||||
'title': title,
|
||||
'name': name,
|
||||
}
|
||||
if parent is not None:
|
||||
data['reply'] = parent
|
||||
encoded_data = urllib.parse.urlencode(data).encode('utf-8')
|
||||
create_url = urllib.parse.urljoin(api_url, 'create')
|
||||
headers = {
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
import sys
|
||||
import html
|
||||
import getpass
|
||||
import traceback
|
||||
import functools
|
||||
|
||||
@ -38,6 +39,9 @@ class _CrashDialog(QDialog):
|
||||
|
||||
"""Dialog which gets shown after there was a crash.
|
||||
|
||||
Class attributes:
|
||||
NAME: The kind of condition we report.
|
||||
|
||||
Attributes:
|
||||
These are just here to have a static reference to avoid GCing.
|
||||
_vbox: The main QVBoxLayout
|
||||
@ -48,6 +52,8 @@ class _CrashDialog(QDialog):
|
||||
_crash_info: A list of tuples with title and crash information.
|
||||
"""
|
||||
|
||||
NAME = None
|
||||
|
||||
def __init__(self, debug, parent=None):
|
||||
"""Constructor for CrashDialog.
|
||||
|
||||
@ -175,7 +181,13 @@ class _CrashDialog(QDialog):
|
||||
lines.append(self._debug_log.toPlainText())
|
||||
text = '\n\n'.join(lines)
|
||||
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:
|
||||
log.misc.exception("Error while paste-binning")
|
||||
exc_text = '{}: {}'.format(e.__class__.__name__, e)
|
||||
@ -214,6 +226,8 @@ class ExceptionCrashDialog(_CrashDialog):
|
||||
_objects: A list of all QObjects as string.
|
||||
"""
|
||||
|
||||
NAME = 'exception'
|
||||
|
||||
def __init__(self, debug, pages, cmdhist, exc, objects, parent=None):
|
||||
super().__init__(debug, parent)
|
||||
self._pages = pages
|
||||
@ -294,6 +308,8 @@ class FatalCrashDialog(_CrashDialog):
|
||||
_log: The log text to display.
|
||||
"""
|
||||
|
||||
NAME = 'segfault'
|
||||
|
||||
def __init__(self, debug, text, parent=None):
|
||||
super().__init__(debug, parent)
|
||||
self._log = text
|
||||
@ -330,6 +346,8 @@ class ReportDialog(_CrashDialog):
|
||||
_objects: A list of all QObjects as string.
|
||||
"""
|
||||
|
||||
NAME = 'report'
|
||||
|
||||
def __init__(self, pages, cmdhist, objects, parent=None):
|
||||
super().__init__(False, parent)
|
||||
self.setAttribute(Qt.WA_DeleteOnClose)
|
||||
|
Loading…
Reference in New Issue
Block a user