diff options
author | Florian Bruhin <git@the-compiler.org> | 2015-07-14 07:00:30 +0200 |
---|---|---|
committer | Florian Bruhin <git@the-compiler.org> | 2015-07-14 16:18:34 +0200 |
commit | 60b66520068362e04619131097b3670cbe407fa3 (patch) | |
tree | 407140ac79bfe4d51ca1b313e21753ffc51b359a /scripts/link_pyqt.py | |
parent | 03383c48eb949caae85cc059e9f660cf59a39a5f (diff) | |
download | qutebrowser-60b66520068362e04619131097b3670cbe407fa3.tar.gz qutebrowser-60b66520068362e04619131097b3670cbe407fa3.zip |
Better output on errors.
Diffstat (limited to 'scripts/link_pyqt.py')
-rw-r--r-- | scripts/link_pyqt.py | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/scripts/link_pyqt.py b/scripts/link_pyqt.py index 794d0c4fe..6da3aa2fb 100644 --- a/scripts/link_pyqt.py +++ b/scripts/link_pyqt.py @@ -106,18 +106,28 @@ def get_lib_path(executable, name, required=True): code = [ 'try:', ' import {}'.format(name), - 'except ImportError:', - ' print("")', + 'except ImportError as e:', + ' print("ImportError: " + str(e))', 'else:', - ' print({}.__file__)'.format(name) + ' print("path: " + {}.__file__)'.format(name) ] - path = run_py(executable, *code) - if path: - return path - elif required: - raise Error("Did not find {} with {}!".format(name, executable)) + output = run_py(executable, *code) + + try: + prefix, data = output.split(': ') + except ValueError: + raise ValueError("Unexpected output: {!r}".format(output)) + + if prefix == 'path': + return data + elif prefix == 'ImportError': + if required: + raise Error("Could not import {} with {}: {}!".format( + name, executable, data)) + else: + return None else: - return None + raise ValueError("Unexpected output: {!r}".format(output)) def link_pyqt(executable, venv_path): |