Ejemplo n.º 1
0
def pastebin_version(pbclient=None):
    """Pastebin the version and log the url to messages."""
    def _yank_url(url):
        utils.set_clipboard(url)
        message.info("Version url {} yanked to clipboard.".format(url))

    def _on_paste_version_success(url):
        global pastebin_url
        _yank_url(url)
        pbclient.deleteLater()
        pastebin_url = url

    def _on_paste_version_err(text):
        message.error("Failed to pastebin version" " info: {}".format(text))
        pbclient.deleteLater()

    if pastebin_url:
        _yank_url(pastebin_url)
        return

    app = QApplication.instance()
    http_client = httpclient.HTTPClient()

    misc_api = pastebin.PastebinClient.MISC_API_URL
    pbclient = pbclient or pastebin.PastebinClient(
        http_client, parent=app, api_url=misc_api)

    pbclient.success.connect(_on_paste_version_success)
    pbclient.error.connect(_on_paste_version_err)

    pbclient.paste(getpass.getuser(),
                   "qute version info {}".format(qutebrowser.__version__),
                   version(),
                   private=True)
Ejemplo n.º 2
0
    def __init__(self, debug, parent=None):
        """Constructor for CrashDialog.

        Args:
            debug: Whether --debug was given.
        """
        super().__init__(parent)
        # We don't set WA_DeleteOnClose here as on an exception, we'll get
        # closed anyways, and it only could have unintended side-effects.
        self._crash_info = []  # type: typing.Sequence[typing.Tuple[str, str]]
        self._btn_box = None
        self._btn_report = None
        self._btn_cancel = None
        self._lbl = None
        self._paste_text = None
        self.setWindowTitle("Whoops!")
        self.resize(QSize(640, 600))
        self._vbox = QVBoxLayout(self)
        http_client = httpclient.HTTPClient()
        self._paste_client = pastebin.PastebinClient(http_client, self)
        self._pypi_client = autoupdate.PyPIVersionClient(self)
        self._init_text()

        self._init_contact_input()

        info = QLabel("What were you doing when this crash/bug happened?")
        self._vbox.addWidget(info)
        self._info = QTextEdit()
        self._info.setTabChangesFocus(True)
        self._info.setAcceptRichText(False)
        self._info.setPlaceholderText("- Opened http://www.example.com/\n"
                                      "- Switched tabs\n"
                                      "- etc...")
        self._vbox.addWidget(self._info, 5)

        self._vbox.addSpacing(15)
        self._debug_log = QTextEdit()
        self._debug_log.setTabChangesFocus(True)
        self._debug_log.setAcceptRichText(False)
        self._debug_log.setLineWrapMode(QTextEdit.NoWrap)
        self._debug_log.hide()
        info = QLabel("<i>You can edit the log below to remove sensitive "
                      "information.</i>")
        info.setWordWrap(True)
        info.hide()
        self._fold = miscwidgets.DetailFold("Show log", self)
        self._fold.toggled.connect(self._debug_log.setVisible)
        self._fold.toggled.connect(info.setVisible)
        if debug:
            self._fold.toggle()
        self._vbox.addWidget(self._fold)
        self._vbox.addWidget(info)
        self._vbox.addWidget(self._debug_log, 10)
        self._vbox.addSpacing(15)

        self._init_checkboxes()
        self._init_info_text()
        self._init_buttons()
Ejemplo n.º 3
0
def pbclient(stubs):
    http_stub = stubs.HTTPPostStub()
    client = pastebin.PastebinClient(http_stub)
    yield client
    version.pastebin_url = None
Ejemplo n.º 4
0
def test_constructor(qapp):
    http_client = httpclient.HTTPClient()
    pastebin.PastebinClient(http_client)
Ejemplo n.º 5
0
def pbclient(stubs):
    http_stub = stubs.HTTPPostStub()
    client = pastebin.PastebinClient(http_stub)
    return client
Ejemplo n.º 6
0
    def __init__(self, debug, parent=None):
        """Constructor for CrashDialog.

        Args:
            debug: Whether --debug was given.
        """
        super().__init__(parent)
        # We don't set WA_DeleteOnClose here as on an exception, we'll get
        # closed anyways, and it only could have unintended side-effects.
        self._crash_info = []
        self._btn_box = None
        self._btn_report = None
        self._btn_cancel = None
        self._lbl = None
        self._paste_text = None
        self.setWindowTitle("Whoops!")
        self.resize(QSize(640, 600))
        self._vbox = QVBoxLayout(self)
        http_client = httpclient.HTTPClient()
        self._paste_client = pastebin.PastebinClient(http_client, self)
        self._pypi_client = autoupdate.PyPIVersionClient(self)
        self._init_text()

        contact = QLabel(
            "I'd like to be able to follow up with you, to keep "
            "you posted on the status of this crash and get more "
            "information if I need it - how can I contact you?",
            wordWrap=True)
        self._vbox.addWidget(contact)
        self._contact = QTextEdit(tabChangesFocus=True, acceptRichText=False)
        try:
            state = objreg.get('state-config')
            try:
                self._contact.setPlainText(state['general']['contact-info'])
            except KeyError:
                self._contact.setPlaceholderText("Mail or IRC nickname")
        except Exception:
            log.misc.exception("Failed to get contact information!")
            self._contact.setPlaceholderText("Mail or IRC nickname")
        self._vbox.addWidget(self._contact, 2)

        info = QLabel("What were you doing when this crash/bug happened?")
        self._vbox.addWidget(info)
        self._info = QTextEdit(tabChangesFocus=True, acceptRichText=False)
        self._info.setPlaceholderText("- Opened http://www.example.com/\n"
                                      "- Switched tabs\n"
                                      "- etc...")
        self._vbox.addWidget(self._info, 5)

        self._vbox.addSpacing(15)
        self._debug_log = QTextEdit(tabChangesFocus=True,
                                    acceptRichText=False,
                                    lineWrapMode=QTextEdit.NoWrap)
        self._debug_log.hide()
        info = QLabel(
            "<i>You can edit the log below to remove sensitive "
            "information.</i>",
            wordWrap=True)
        info.hide()
        self._fold = miscwidgets.DetailFold("Show log", self)
        self._fold.toggled.connect(self._debug_log.setVisible)
        self._fold.toggled.connect(info.setVisible)
        if debug:
            self._fold.toggle()
        self._vbox.addWidget(self._fold)
        self._vbox.addWidget(info)
        self._vbox.addWidget(self._debug_log, 10)
        self._vbox.addSpacing(15)

        self._init_checkboxes()
        self._init_info_text()
        self._init_buttons()