Ensure version info only gets pasted once
This commit is contained in:
parent
9128afa01d
commit
682c3462f1
@ -39,6 +39,7 @@ from qutebrowser.utils import log, objreg, usertypes, message, debug, utils
|
|||||||
from qutebrowser.commands import cmdutils, runners, cmdexc
|
from qutebrowser.commands import cmdutils, runners, cmdexc
|
||||||
from qutebrowser.config import config, configdata
|
from qutebrowser.config import config, configdata
|
||||||
from qutebrowser.misc import consolewidget
|
from qutebrowser.misc import consolewidget
|
||||||
|
from qutebrowser.utils.version import pastebin_version
|
||||||
|
|
||||||
|
|
||||||
@cmdutils.register(maxsplit=1, no_cmd_split=True, no_replace_variables=True)
|
@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)
|
tabbed_browser.openurl(QUrl('qute://version'), newtab=True)
|
||||||
|
|
||||||
if paste:
|
if paste:
|
||||||
utils.version.pastebin_version()
|
pastebin_version()
|
||||||
|
@ -65,6 +65,7 @@ class DistributionInfo:
|
|||||||
pretty = attr.ib()
|
pretty = attr.ib()
|
||||||
|
|
||||||
|
|
||||||
|
PASTEBIN_URL = None
|
||||||
Distribution = enum.Enum(
|
Distribution = enum.Enum(
|
||||||
'Distribution', ['unknown', 'ubuntu', 'debian', 'void', 'arch',
|
'Distribution', ['unknown', 'ubuntu', 'debian', 'void', 'arch',
|
||||||
'gentoo', 'fedora', 'opensuse', 'linuxmint', 'manjaro'])
|
'gentoo', 'fedora', 'opensuse', 'linuxmint', 'manjaro'])
|
||||||
@ -453,22 +454,31 @@ def opengl_vendor(): # pragma: no cover
|
|||||||
|
|
||||||
def pastebin_version():
|
def pastebin_version():
|
||||||
"""Pastebin the version and log the url to messages."""
|
"""Pastebin the version and log the url to messages."""
|
||||||
app = QApplication.instance()
|
|
||||||
http_client = httpclient.HTTPClient()
|
|
||||||
|
|
||||||
def _get_paste_title():
|
def _get_paste_title():
|
||||||
return "qute version info {}".format(qutebrowser.__version__)
|
return "qute version info {}".format(qutebrowser.__version__)
|
||||||
|
|
||||||
def _on_paste_version_success(url):
|
def _yank_url(url):
|
||||||
utils.set_clipboard(url)
|
utils.set_clipboard(url)
|
||||||
message.info("Version url {} yanked to clipboard.".format(url))
|
message.info("Version url {} yanked to clipboard.".format(url))
|
||||||
|
|
||||||
|
def _on_paste_version_success(url):
|
||||||
|
global PASTEBIN_URL
|
||||||
|
_yank_url(url)
|
||||||
pbclient.deleteLater()
|
pbclient.deleteLater()
|
||||||
|
PASTEBIN_URL = url
|
||||||
|
|
||||||
def _on_paste_version_err(text):
|
def _on_paste_version_err(text):
|
||||||
message.error("Failed to pastebin version"
|
message.error("Failed to pastebin version"
|
||||||
" info: {}".format(text))
|
" info: {}".format(text))
|
||||||
pbclient.deleteLater()
|
pbclient.deleteLater()
|
||||||
|
|
||||||
|
if PASTEBIN_URL:
|
||||||
|
_yank_url(PASTEBIN_URL)
|
||||||
|
return
|
||||||
|
|
||||||
|
app = QApplication.instance()
|
||||||
|
http_client = httpclient.HTTPClient()
|
||||||
|
|
||||||
misc_api = pastebin.PastebinClient.MISC_API_URL
|
misc_api = pastebin.PastebinClient.MISC_API_URL
|
||||||
pbclient = pastebin.PastebinClient(http_client, parent=app,
|
pbclient = pastebin.PastebinClient(http_client, parent=app,
|
||||||
api_url=misc_api)
|
api_url=misc_api)
|
||||||
|
Loading…
Reference in New Issue
Block a user