From 1d568a5cf490c98c7e1f78d2e45419260911ce63 Mon Sep 17 00:00:00 2001 From: Bryan Kok Date: Thu, 11 Jan 2018 05:59:42 +0800 Subject: [PATCH 01/11] Add feature to pastebin version string Added a --paste flag to the :version command and a JS button with corresponding qutescheme URL in the Version debug page to enable pastebinning version. --- qutebrowser/browser/qutescheme.py | 7 +++++++ qutebrowser/html/version.html | 14 +++++++++++++ qutebrowser/misc/pastebin.py | 7 +++++-- qutebrowser/misc/utilcmds.py | 5 ++++- qutebrowser/utils/utils.py | 33 ++++++++++++++++++++++++++++++- 5 files changed, 62 insertions(+), 4 deletions(-) diff --git a/qutebrowser/browser/qutescheme.py b/qutebrowser/browser/qutescheme.py index 320e7873a..50b25aa74 100644 --- a/qutebrowser/browser/qutescheme.py +++ b/qutebrowser/browser/qutescheme.py @@ -476,3 +476,10 @@ def qute_configdiff(url): else: data = config.instance.dump_userconfig().encode('utf-8') return 'text/plain', data + + +@add_handler('pastebin-version') +def qute_pastebin_version(url): # transfusion: pylint: disable=unused-argument + """Handler that pastebins the version string.""" + utils.pastebin_version() + return 'text/plain', b'Paste called.' diff --git a/qutebrowser/html/version.html b/qutebrowser/html/version.html index 736eb7547..9532c3d62 100644 --- a/qutebrowser/html/version.html +++ b/qutebrowser/html/version.html @@ -1,4 +1,17 @@ {% extends "base.html" %} + +{% block script %} +var paste_version = function(){ + xhr = new XMLHttpRequest(); + xhr.open("GET", "qute://pastebin-version"); + xhr.send(); +} +{% endblock %} + +{% block style %} +#paste { margin: auto; display: block; } +{% endblock %} + {% block content %} {{ super() }}

Version info

@@ -23,4 +36,5 @@ You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/ or open qute://gpl.

+ {% endblock %} diff --git a/qutebrowser/misc/pastebin.py b/qutebrowser/misc/pastebin.py index d022fc526..423709910 100644 --- a/qutebrowser/misc/pastebin.py +++ b/qutebrowser/misc/pastebin.py @@ -42,20 +42,23 @@ class PastebinClient(QObject): """ API_URL = 'https://crashes.qutebrowser.org/api/' + MISC_API_URL = 'http://paste.the-compiler.org/api/' success = pyqtSignal(str) error = pyqtSignal(str) - def __init__(self, client, parent=None): + def __init__(self, client, parent=None, api_url=API_URL): """Constructor. Args: client: The HTTPClient to use. Will be reparented. + api_url: The Stikked pastebin endpoint to use. """ super().__init__(parent) client.setParent(self) client.error.connect(self.error) client.success.connect(self.on_client_success) self._client = client + self.api_url = api_url def paste(self, name, title, text, parent=None): """Paste the text into a pastebin and return the URL. @@ -74,7 +77,7 @@ class PastebinClient(QObject): } if parent is not None: data['reply'] = parent - url = QUrl(urllib.parse.urljoin(self.API_URL, 'create')) + url = QUrl(urllib.parse.urljoin(self.api_url, 'create')) self._client.post(url, data) @pyqtSlot(str) diff --git a/qutebrowser/misc/utilcmds.py b/qutebrowser/misc/utilcmds.py index c0d83b7eb..093f79aaa 100644 --- a/qutebrowser/misc/utilcmds.py +++ b/qutebrowser/misc/utilcmds.py @@ -369,8 +369,11 @@ def nop(): @cmdutils.register() @cmdutils.argument('win_id', win_id=True) -def version(win_id): +def version(win_id, paste=False): """Show version information.""" tabbed_browser = objreg.get('tabbed-browser', scope='window', window=win_id) tabbed_browser.openurl(QUrl('qute://version'), newtab=True) + + if paste: + utils.pastebin_version() diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py index 079866920..3579ac243 100644 --- a/qutebrowser/utils/utils.py +++ b/qutebrowser/utils/utils.py @@ -33,9 +33,10 @@ import functools import contextlib import socket import shlex +import getpass import attr -from PyQt5.QtCore import Qt, QUrl +from PyQt5.QtCore import Qt, QUrl, pyqtSlot from PyQt5.QtGui import QKeySequence, QColor, QClipboard, QDesktopServices from PyQt5.QtWidgets import QApplication import pkg_resources @@ -49,6 +50,7 @@ except ImportError: # pragma: no cover import qutebrowser from qutebrowser.utils import qtutils, log, debug +from qutebrowser.misc import httpclient, pastebin fake_clipboard = None @@ -915,3 +917,32 @@ def yaml_dump(data, f=None): return None else: return yaml_data.decode('utf-8') + + +def pastebin_version(): + """Pastebins version and logs to messages""" + + app = qutebrowser.utils.objreg.get('app') + http_client = httpclient.HTTPClient() + + def _get_paste_title(): + return "qute version info {}".format(qutebrowser.__version__) + + @pyqtSlot(str) + def _on_paste_version_success(url): + qutebrowser.utils.message.info("Version info pastebinned" + " to: {}".format(url)) + + @pyqtSlot(str) + def _on_paste_version_err(text): + qutebrowser.utils.message.info("Failed to pastebin version" + " info: {}".format(text)) + + pbclient = pastebin.PastebinClient(http_client, parent=app, + api_url= + pastebin.PastebinClient.MISC_API_URL) + pbclient.success.connect(_on_paste_version_success) + pbclient.error.connect(_on_paste_version_err) + + pbclient.paste(getpass.getuser(), _get_paste_title(), + qutebrowser.utils.version.version()) From f45d572677ed6356a798b9ed109bca62e85a0bf9 Mon Sep 17 00:00:00 2001 From: George Edward Bulmer Date: Tue, 6 Feb 2018 19:48:31 +0000 Subject: [PATCH 02/11] Some style fixes in PR #3480's review --- qutebrowser/browser/qutescheme.py | 2 +- qutebrowser/misc/pastebin.py | 6 +++--- qutebrowser/misc/utilcmds.py | 6 +++++- qutebrowser/utils/utils.py | 8 ++++---- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/qutebrowser/browser/qutescheme.py b/qutebrowser/browser/qutescheme.py index 50b25aa74..9779b3949 100644 --- a/qutebrowser/browser/qutescheme.py +++ b/qutebrowser/browser/qutescheme.py @@ -479,7 +479,7 @@ def qute_configdiff(url): @add_handler('pastebin-version') -def qute_pastebin_version(url): # transfusion: pylint: disable=unused-argument +def qute_pastebin_version(_url): """Handler that pastebins the version string.""" utils.pastebin_version() return 'text/plain', b'Paste called.' diff --git a/qutebrowser/misc/pastebin.py b/qutebrowser/misc/pastebin.py index 423709910..0f2ed8ce4 100644 --- a/qutebrowser/misc/pastebin.py +++ b/qutebrowser/misc/pastebin.py @@ -42,7 +42,7 @@ class PastebinClient(QObject): """ API_URL = 'https://crashes.qutebrowser.org/api/' - MISC_API_URL = 'http://paste.the-compiler.org/api/' + MISC_API_URL = 'https://paste.the-compiler.org/api/' success = pyqtSignal(str) error = pyqtSignal(str) @@ -58,7 +58,7 @@ class PastebinClient(QObject): client.error.connect(self.error) client.success.connect(self.on_client_success) self._client = client - self.api_url = api_url + self._api_url = api_url def paste(self, name, title, text, parent=None): """Paste the text into a pastebin and return the URL. @@ -77,7 +77,7 @@ class PastebinClient(QObject): } if parent is not None: data['reply'] = parent - url = QUrl(urllib.parse.urljoin(self.api_url, 'create')) + url = QUrl(urllib.parse.urljoin(self._api_url, 'create')) self._client.post(url, data) @pyqtSlot(str) diff --git a/qutebrowser/misc/utilcmds.py b/qutebrowser/misc/utilcmds.py index 093f79aaa..e1ad25350 100644 --- a/qutebrowser/misc/utilcmds.py +++ b/qutebrowser/misc/utilcmds.py @@ -370,7 +370,11 @@ def nop(): @cmdutils.register() @cmdutils.argument('win_id', win_id=True) def version(win_id, paste=False): - """Show version information.""" + """Show version information. + + Args: + paste: Paste to pastebin. + """ tabbed_browser = objreg.get('tabbed-browser', scope='window', window=win_id) tabbed_browser.openurl(QUrl('qute://version'), newtab=True) diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py index 3579ac243..afad0f0c2 100644 --- a/qutebrowser/utils/utils.py +++ b/qutebrowser/utils/utils.py @@ -920,8 +920,7 @@ def yaml_dump(data, f=None): def pastebin_version(): - """Pastebins version and logs to messages""" - + """Pastebin the version and log the url to messages.""" app = qutebrowser.utils.objreg.get('app') http_client = httpclient.HTTPClient() @@ -938,9 +937,10 @@ def pastebin_version(): qutebrowser.utils.message.info("Failed to pastebin version" " info: {}".format(text)) + misc_api = pastebin.PastebinClient.MISC_API_URL pbclient = pastebin.PastebinClient(http_client, parent=app, - api_url= - pastebin.PastebinClient.MISC_API_URL) + api_url=misc_api) + pbclient.success.connect(_on_paste_version_success) pbclient.error.connect(_on_paste_version_err) From 86d3abc0c47e0bf0b788e034b1a16e4989749fd8 Mon Sep 17 00:00:00 2001 From: George Edward Bulmer Date: Wed, 7 Feb 2018 15:21:19 +0000 Subject: [PATCH 03/11] Additional code review changes from PR #3480 --- qutebrowser/utils/utils.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py index afad0f0c2..efcd76013 100644 --- a/qutebrowser/utils/utils.py +++ b/qutebrowser/utils/utils.py @@ -49,7 +49,7 @@ except ImportError: # pragma: no cover YAML_C_EXT = False import qutebrowser -from qutebrowser.utils import qtutils, log, debug +from qutebrowser.utils import qtutils, log, debug, message, version from qutebrowser.misc import httpclient, pastebin @@ -921,7 +921,7 @@ def yaml_dump(data, f=None): def pastebin_version(): """Pastebin the version and log the url to messages.""" - app = qutebrowser.utils.objreg.get('app') + app = QApplication.instance() http_client = httpclient.HTTPClient() def _get_paste_title(): @@ -929,20 +929,20 @@ def pastebin_version(): @pyqtSlot(str) def _on_paste_version_success(url): - qutebrowser.utils.message.info("Version info pastebinned" - " to: {}".format(url)) + set_clipboard(url) + message.info("Version url {} yanked to clipboard.".format(url)) @pyqtSlot(str) def _on_paste_version_err(text): - qutebrowser.utils.message.info("Failed to pastebin version" - " info: {}".format(text)) + message.error("Failed to pastebin version" + " info: {}".format(text)) - misc_api = pastebin.PastebinClient.MISC_API_URL + MISC_API = pastebin.PastebinClient.MISC_API_URL pbclient = pastebin.PastebinClient(http_client, parent=app, - api_url=misc_api) + api_url=MISC_API) pbclient.success.connect(_on_paste_version_success) pbclient.error.connect(_on_paste_version_err) pbclient.paste(getpass.getuser(), _get_paste_title(), - qutebrowser.utils.version.version()) + version.version()) From d0ec33730ee56954f1fd438e40efce314ccdf2be Mon Sep 17 00:00:00 2001 From: George Edward Bulmer Date: Wed, 7 Feb 2018 15:28:58 +0000 Subject: [PATCH 04/11] Add deleteLater to the paste callbacks --- qutebrowser/utils/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py index efcd76013..ffe6ca297 100644 --- a/qutebrowser/utils/utils.py +++ b/qutebrowser/utils/utils.py @@ -931,11 +931,13 @@ def pastebin_version(): def _on_paste_version_success(url): set_clipboard(url) message.info("Version url {} yanked to clipboard.".format(url)) + pbclient.deleteLater() @pyqtSlot(str) def _on_paste_version_err(text): message.error("Failed to pastebin version" " info: {}".format(text)) + pbclient.deleteLater() MISC_API = pastebin.PastebinClient.MISC_API_URL pbclient = pastebin.PastebinClient(http_client, parent=app, From a3d62c86df03e9292e16d0748fd3abf77fc543fd Mon Sep 17 00:00:00 2001 From: George Edward Bulmer Date: Wed, 7 Feb 2018 17:25:19 +0000 Subject: [PATCH 05/11] Fix style for linter --- qutebrowser/utils/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py index ffe6ca297..b314fc4c8 100644 --- a/qutebrowser/utils/utils.py +++ b/qutebrowser/utils/utils.py @@ -939,9 +939,9 @@ def pastebin_version(): " info: {}".format(text)) pbclient.deleteLater() - MISC_API = pastebin.PastebinClient.MISC_API_URL + misc_api = pastebin.PastebinClient.MISC_API_URL pbclient = pastebin.PastebinClient(http_client, parent=app, - api_url=MISC_API) + api_url=misc_api) pbclient.success.connect(_on_paste_version_success) pbclient.error.connect(_on_paste_version_err) From 9128afa01db7dcbb0b7a55424d278fe8c7bb3755 Mon Sep 17 00:00:00 2001 From: George Edward Bulmer Date: Wed, 7 Feb 2018 19:03:05 +0000 Subject: [PATCH 06/11] Move pastebin_version() to version.py This also fixes the introduced cyclic dependencies --- qutebrowser/browser/qutescheme.py | 2 +- qutebrowser/misc/utilcmds.py | 2 +- qutebrowser/utils/utils.py | 37 ++----------------------------- qutebrowser/utils/version.py | 33 +++++++++++++++++++++++++-- 4 files changed, 35 insertions(+), 39 deletions(-) diff --git a/qutebrowser/browser/qutescheme.py b/qutebrowser/browser/qutescheme.py index 9779b3949..cca74cb63 100644 --- a/qutebrowser/browser/qutescheme.py +++ b/qutebrowser/browser/qutescheme.py @@ -481,5 +481,5 @@ def qute_configdiff(url): @add_handler('pastebin-version') def qute_pastebin_version(_url): """Handler that pastebins the version string.""" - utils.pastebin_version() + version.pastebin_version() return 'text/plain', b'Paste called.' diff --git a/qutebrowser/misc/utilcmds.py b/qutebrowser/misc/utilcmds.py index e1ad25350..cc494a180 100644 --- a/qutebrowser/misc/utilcmds.py +++ b/qutebrowser/misc/utilcmds.py @@ -380,4 +380,4 @@ def version(win_id, paste=False): tabbed_browser.openurl(QUrl('qute://version'), newtab=True) if paste: - utils.pastebin_version() + utils.version.pastebin_version() diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py index b314fc4c8..f9361e3d5 100644 --- a/qutebrowser/utils/utils.py +++ b/qutebrowser/utils/utils.py @@ -36,7 +36,7 @@ import shlex import getpass import attr -from PyQt5.QtCore import Qt, QUrl, pyqtSlot +from PyQt5.QtCore import Qt, QUrl from PyQt5.QtGui import QKeySequence, QColor, QClipboard, QDesktopServices from PyQt5.QtWidgets import QApplication import pkg_resources @@ -49,9 +49,7 @@ except ImportError: # pragma: no cover YAML_C_EXT = False import qutebrowser -from qutebrowser.utils import qtutils, log, debug, message, version -from qutebrowser.misc import httpclient, pastebin - +from qutebrowser.utils import qtutils, log, debug fake_clipboard = None log_clipboard = False @@ -917,34 +915,3 @@ def yaml_dump(data, f=None): return None else: return yaml_data.decode('utf-8') - - -def pastebin_version(): - """Pastebin the version and log the url to messages.""" - app = QApplication.instance() - http_client = httpclient.HTTPClient() - - def _get_paste_title(): - return "qute version info {}".format(qutebrowser.__version__) - - @pyqtSlot(str) - def _on_paste_version_success(url): - set_clipboard(url) - message.info("Version url {} yanked to clipboard.".format(url)) - pbclient.deleteLater() - - @pyqtSlot(str) - def _on_paste_version_err(text): - message.error("Failed to pastebin version" - " info: {}".format(text)) - pbclient.deleteLater() - - misc_api = pastebin.PastebinClient.MISC_API_URL - pbclient = 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(), _get_paste_title(), - version.version()) diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py index aff7ed07b..fd6fdfa23 100644 --- a/qutebrowser/utils/version.py +++ b/qutebrowser/utils/version.py @@ -49,8 +49,8 @@ except ImportError: # pragma: no cover QWebEngineProfile = None import qutebrowser -from qutebrowser.utils import log, utils, standarddir, usertypes -from qutebrowser.misc import objects, earlyinit, sql +from qutebrowser.utils import log, utils, standarddir, usertypes, message +from qutebrowser.misc import objects, earlyinit, sql, httpclient, pastebin from qutebrowser.browser import pdfjs @@ -449,3 +449,32 @@ def opengl_vendor(): # pragma: no cover ctx.doneCurrent() if old_context and old_surface: old_context.makeCurrent(old_surface) + + +def pastebin_version(): + """Pastebin the version and log the url to messages.""" + app = QApplication.instance() + http_client = httpclient.HTTPClient() + + def _get_paste_title(): + return "qute version info {}".format(qutebrowser.__version__) + + def _on_paste_version_success(url): + utils.set_clipboard(url) + message.info("Version url {} yanked to clipboard.".format(url)) + pbclient.deleteLater() + + def _on_paste_version_err(text): + message.error("Failed to pastebin version" + " info: {}".format(text)) + pbclient.deleteLater() + + misc_api = pastebin.PastebinClient.MISC_API_URL + pbclient = 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(utils.getpass.getuser(), _get_paste_title(), + version()) From 682c3462f12d36a4c2b52c0d89b5e8a70786f5cb Mon Sep 17 00:00:00 2001 From: George Edward Bulmer Date: Wed, 7 Feb 2018 19:21:53 +0000 Subject: [PATCH 07/11] Ensure version info only gets pasted once --- qutebrowser/misc/utilcmds.py | 3 ++- qutebrowser/utils/version.py | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/qutebrowser/misc/utilcmds.py b/qutebrowser/misc/utilcmds.py index cc494a180..d2743d56e 100644 --- a/qutebrowser/misc/utilcmds.py +++ b/qutebrowser/misc/utilcmds.py @@ -39,6 +39,7 @@ from qutebrowser.utils import log, objreg, usertypes, message, debug, utils from qutebrowser.commands import cmdutils, runners, cmdexc from qutebrowser.config import config, configdata from qutebrowser.misc import consolewidget +from qutebrowser.utils.version import pastebin_version @cmdutils.register(maxsplit=1, no_cmd_split=True, no_replace_variables=True) @@ -380,4 +381,4 @@ def version(win_id, paste=False): tabbed_browser.openurl(QUrl('qute://version'), newtab=True) if paste: - utils.version.pastebin_version() + pastebin_version() diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py index fd6fdfa23..779be348b 100644 --- a/qutebrowser/utils/version.py +++ b/qutebrowser/utils/version.py @@ -65,6 +65,7 @@ class DistributionInfo: pretty = attr.ib() +PASTEBIN_URL = None Distribution = enum.Enum( 'Distribution', ['unknown', 'ubuntu', 'debian', 'void', 'arch', 'gentoo', 'fedora', 'opensuse', 'linuxmint', 'manjaro']) @@ -453,22 +454,31 @@ def opengl_vendor(): # pragma: no cover def pastebin_version(): """Pastebin the version and log the url to messages.""" - app = QApplication.instance() - http_client = httpclient.HTTPClient() - def _get_paste_title(): return "qute version info {}".format(qutebrowser.__version__) - def _on_paste_version_success(url): + 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 = pastebin.PastebinClient(http_client, parent=app, api_url=misc_api) From 0ee53028368536fef3ee9342d0d7567bd337d5a5 Mon Sep 17 00:00:00 2001 From: George Edward Bulmer Date: Wed, 7 Feb 2018 20:03:46 +0000 Subject: [PATCH 08/11] Pylint fixes --- qutebrowser/utils/utils.py | 1 - qutebrowser/utils/version.py | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py index f9361e3d5..2d96613ee 100644 --- a/qutebrowser/utils/utils.py +++ b/qutebrowser/utils/utils.py @@ -33,7 +33,6 @@ import functools import contextlib import socket import shlex -import getpass import attr from PyQt5.QtCore import Qt, QUrl diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py index 779be348b..941ad2123 100644 --- a/qutebrowser/utils/version.py +++ b/qutebrowser/utils/version.py @@ -29,6 +29,7 @@ import importlib import collections import enum import datetime +import getpass import attr import pkg_resources @@ -486,5 +487,5 @@ def pastebin_version(): pbclient.success.connect(_on_paste_version_success) pbclient.error.connect(_on_paste_version_err) - pbclient.paste(utils.getpass.getuser(), _get_paste_title(), + pbclient.paste(getpass.getuser(), _get_paste_title(), version()) From a9dfed948a42e1b91df7b3342c51901edf18b1d4 Mon Sep 17 00:00:00 2001 From: George Edward Bulmer Date: Wed, 7 Feb 2018 22:55:42 +0000 Subject: [PATCH 09/11] Remove extraneous function --- qutebrowser/utils/version.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py index 941ad2123..e246cb8c5 100644 --- a/qutebrowser/utils/version.py +++ b/qutebrowser/utils/version.py @@ -455,9 +455,6 @@ def opengl_vendor(): # pragma: no cover def pastebin_version(): """Pastebin the version and log the url to messages.""" - def _get_paste_title(): - return "qute version info {}".format(qutebrowser.__version__) - def _yank_url(url): utils.set_clipboard(url) message.info("Version url {} yanked to clipboard.".format(url)) @@ -487,5 +484,5 @@ def pastebin_version(): pbclient.success.connect(_on_paste_version_success) pbclient.error.connect(_on_paste_version_err) - pbclient.paste(getpass.getuser(), _get_paste_title(), - version()) + pbclient.paste(getpass.getuser(), + "qute version info {}".format(qutebrowser.__version__), version()) From 950e4227e37ba1534d4bd61bfec0acce0f5d457a Mon Sep 17 00:00:00 2001 From: George Edward Bulmer Date: Thu, 8 Feb 2018 14:01:51 +0000 Subject: [PATCH 10/11] Pylint fix --- qutebrowser/utils/version.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py index e246cb8c5..67bf5f423 100644 --- a/qutebrowser/utils/version.py +++ b/qutebrowser/utils/version.py @@ -485,4 +485,5 @@ def pastebin_version(): pbclient.error.connect(_on_paste_version_err) pbclient.paste(getpass.getuser(), - "qute version info {}".format(qutebrowser.__version__), version()) + "qute version info {}".format(qutebrowser.__version__), + version()) From ffddf9a15fa8e964abc7d9150af1909323bb929b Mon Sep 17 00:00:00 2001 From: George Edward Bulmer Date: Sat, 10 Feb 2018 15:14:07 +0000 Subject: [PATCH 11/11] Code style review changes --- qutebrowser/html/version.html | 6 +++--- qutebrowser/utils/utils.py | 1 + qutebrowser/utils/version.py | 10 +++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/qutebrowser/html/version.html b/qutebrowser/html/version.html index 9532c3d62..a69e6f9de 100644 --- a/qutebrowser/html/version.html +++ b/qutebrowser/html/version.html @@ -1,8 +1,8 @@ {% extends "base.html" %} {% block script %} -var paste_version = function(){ - xhr = new XMLHttpRequest(); +function paste_version() { + const xhr = new XMLHttpRequest(); xhr.open("GET", "qute://pastebin-version"); xhr.send(); } @@ -36,5 +36,5 @@ You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/ or open qute://gpl.

- + {% endblock %} diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py index 2d96613ee..079866920 100644 --- a/qutebrowser/utils/utils.py +++ b/qutebrowser/utils/utils.py @@ -50,6 +50,7 @@ except ImportError: # pragma: no cover import qutebrowser from qutebrowser.utils import qtutils, log, debug + fake_clipboard = None log_clipboard = False diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py index 67bf5f423..09a1a6efa 100644 --- a/qutebrowser/utils/version.py +++ b/qutebrowser/utils/version.py @@ -66,7 +66,7 @@ class DistributionInfo: pretty = attr.ib() -PASTEBIN_URL = None +pastebin_url = None Distribution = enum.Enum( 'Distribution', ['unknown', 'ubuntu', 'debian', 'void', 'arch', 'gentoo', 'fedora', 'opensuse', 'linuxmint', 'manjaro']) @@ -460,18 +460,18 @@ def pastebin_version(): message.info("Version url {} yanked to clipboard.".format(url)) def _on_paste_version_success(url): - global PASTEBIN_URL + global pastebin_url _yank_url(url) pbclient.deleteLater() - PASTEBIN_URL = url + 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) + if pastebin_url: + _yank_url(pastebin_url) return app = QApplication.instance()