earlyinit: Beautify messages
This commit is contained in:
parent
8be3d6f046
commit
d18a025d68
@ -41,30 +41,29 @@ def _missing_str(name, debian=None, arch=None, windows=None, pip=None):
|
|||||||
windows: String to be displayed for Windows.
|
windows: String to be displayed for Windows.
|
||||||
pip: pypi package name.
|
pip: pypi package name.
|
||||||
"""
|
"""
|
||||||
blocks = ["Fatal error: {} is required to run qutebrowser but could "
|
blocks = ["Fatal error: <b>{}</b> is required to run qutebrowser but "
|
||||||
"not be imported! Maybe it's not installed?".format(name)]
|
"could not be imported! Maybe it's not installed?".format(name)]
|
||||||
if debian is not None:
|
if debian is not None:
|
||||||
lines = ["On Debian/Ubuntu:"]
|
lines = ["<b>On Debian/Ubuntu:</b>"]
|
||||||
for line in debian.splitlines():
|
lines += debian.splitlines()
|
||||||
lines.append(' ' + line)
|
blocks.append('<br />'.join(lines))
|
||||||
blocks.append('\n'.join(lines))
|
|
||||||
if arch is not None:
|
if arch is not None:
|
||||||
lines = ["On Archlinux:"]
|
lines = ["<b>On Archlinux:</b>"]
|
||||||
for line in arch.splitlines():
|
lines += arch.splitlines()
|
||||||
lines.append(' ' + line)
|
blocks.append('<br />'.join(lines))
|
||||||
blocks.append('\n'.join(lines))
|
|
||||||
if windows is not None:
|
if windows is not None:
|
||||||
lines = ["On Windows:"]
|
lines = ["<b>On Windows:</b>"]
|
||||||
for line in windows.splitlines():
|
lines += windows.splitlines()
|
||||||
lines.append(' ' + line)
|
blocks.append('<br />'.join(lines))
|
||||||
blocks.append('\n'.join(lines))
|
lines = ["<b>For other distributions:</b>",
|
||||||
lines = ["For other distributions:",
|
"Check your package manager for similiarly named packages or "
|
||||||
" Check your package manager for similiarly named packages."]
|
"install via pip."]
|
||||||
|
blocks.append('<br />'.join(lines))
|
||||||
if pip is not None:
|
if pip is not None:
|
||||||
lines.append(" Or run pip install {} (using python3/pip3)".format(
|
lines = ["<b>Using pip:</b>"]
|
||||||
pip))
|
lines.append("pip3 install {}".format(pip))
|
||||||
blocks.append('\n'.join(lines))
|
blocks.append('<br />'.join(lines))
|
||||||
return '\n\n'.join(blocks)
|
return '<br /><br />'.join(blocks)
|
||||||
|
|
||||||
|
|
||||||
def _die(message, exception=True):
|
def _die(message, exception=True):
|
||||||
@ -77,12 +76,14 @@ def _die(message, exception=True):
|
|||||||
exception: Whether to print an exception with --debug.
|
exception: Whether to print an exception with --debug.
|
||||||
"""
|
"""
|
||||||
from PyQt5.QtWidgets import QApplication, QMessageBox
|
from PyQt5.QtWidgets import QApplication, QMessageBox
|
||||||
|
from PyQt5.QtCore import Qt
|
||||||
if '--debug' in sys.argv and exception:
|
if '--debug' in sys.argv and exception:
|
||||||
print(file=sys.stderr)
|
print(file=sys.stderr)
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
msgbox = QMessageBox(QMessageBox.Critical, "qutebrowser: Fatal error!",
|
msgbox = QMessageBox(QMessageBox.Critical, "qutebrowser: Fatal error!",
|
||||||
message)
|
message)
|
||||||
|
msgbox.setTextFormat(Qt.RichText)
|
||||||
msgbox.resize(msgbox.sizeHint())
|
msgbox.resize(msgbox.sizeHint())
|
||||||
msgbox.exec_()
|
msgbox.exec_()
|
||||||
app.quit()
|
app.quit()
|
||||||
@ -176,12 +177,15 @@ def check_pyqt_core():
|
|||||||
text = _missing_str('PyQt5',
|
text = _missing_str('PyQt5',
|
||||||
debian="apt-get install python3-pyqt5 "
|
debian="apt-get install python3-pyqt5 "
|
||||||
"python3-pyqt5.qtwebkit",
|
"python3-pyqt5.qtwebkit",
|
||||||
arch="pacman -S python-pyqt5 qt5-webkit\n"
|
arch="pacman -S python-pyqt5 qt5-webkit<br />"
|
||||||
"or install the qutebrowser package from AUR",
|
"or install the qutebrowser package from AUR",
|
||||||
windows="Use the installer by Riverbank computing "
|
windows="Use the installer by Riverbank computing "
|
||||||
"or the standalone qutebrowser exe.\n"
|
"or the standalone qutebrowser exe.<br />"
|
||||||
"http://www.riverbankcomputing.co.uk/"
|
"http://www.riverbankcomputing.co.uk/"
|
||||||
"software/pyqt/download5")
|
"software/pyqt/download5")
|
||||||
|
text = text.replace('<b>', '')
|
||||||
|
text = text.replace('</b>', '')
|
||||||
|
text = text.replace('<br />', '\n')
|
||||||
if Tk:
|
if Tk:
|
||||||
root = Tk()
|
root = Tk()
|
||||||
root.withdraw()
|
root.withdraw()
|
||||||
@ -237,15 +241,9 @@ def check_pypeg2():
|
|||||||
import pypeg2 # pylint: disable=unused-variable
|
import pypeg2 # pylint: disable=unused-variable
|
||||||
except ImportError:
|
except ImportError:
|
||||||
text = _missing_str("pypeg2",
|
text = _missing_str("pypeg2",
|
||||||
debian="No package available, try:\n"
|
debian="No package available, install via pip.",
|
||||||
"pip3 install pypeg2 "
|
arch="Install python-pypeg2 from the AUR",
|
||||||
"--allow-external pypeg2 "
|
windows="Install via pip.",
|
||||||
"--allow-unverified pypeg2",
|
|
||||||
arch="pacman -S python-pypeg2",
|
|
||||||
windows="pip install pypeg2 "
|
|
||||||
"--allow-external pypeg2 "
|
|
||||||
"--allow-unverified pypeg2 "
|
|
||||||
"(using python3)",
|
|
||||||
pip="pypeg2 --allow-external pypeg2 "
|
pip="pypeg2 --allow-external pypeg2 "
|
||||||
"--allow-unverified pypeg2")
|
"--allow-unverified pypeg2")
|
||||||
_die(text)
|
_die(text)
|
||||||
|
Loading…
Reference in New Issue
Block a user