diff --git a/qutebrowser/app.py b/qutebrowser/app.py index dd7db5c84..85db46ed1 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -546,12 +546,16 @@ class Application(QApplication): log.destroy.debug("args: {}".format(args)) log.destroy.debug("cwd: {}".format(cwd)) # Open a new process and immediately shutdown the existing one - if cwd is None: - subprocess.Popen(args) + try: + if cwd is None: + subprocess.Popen(args) + else: + subprocess.Popen(args, cwd=cwd) + except OSError as e: + log.destroy.error("Failed to restart: {}".format(e)) else: - subprocess.Popen(args, cwd=cwd) - if shutdown: - self.shutdown() + if shutdown: + self.shutdown() @cmdutils.register(instance='app', split=False, debug=True) def debug_pyeval(self, s): diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 22dc1e232..deac9b26c 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -794,7 +794,11 @@ class CommandDispatcher: *args: The commandline to execute. """ log.procs.debug("Executing: {}".format(args)) - subprocess.Popen(args) + try: + subprocess.Popen(args) + except OSError as e: + raise cmdexc.CommandError("Error while spawning command: " + "{}".format(e)) @cmdutils.register(instance='command-dispatcher', scope='window') def home(self): diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index 30ac0e361..599a9fd75 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -420,7 +420,11 @@ class HintManager(QObject): """Spawn a simple command from a hint.""" urlstr = url.toString(QUrl.FullyEncoded | QUrl.RemovePassword) args = self._context.get_args(urlstr) - subprocess.Popen(args) + try: + subprocess.Popen(args) + except OSError as e: + msg = "Error while spawning command: {}".format(e) + message.error(self._win_id, msg, immediately=True) def _resolve_url(self, elem, baseurl=None): """Resolve a URL and check if we want to keep it. diff --git a/qutebrowser/utils/version.py b/qutebrowser/utils/version.py index d99ad8176..09bf5dc1c 100644 --- a/qutebrowser/utils/version.py +++ b/qutebrowser/utils/version.py @@ -96,7 +96,7 @@ def _git_str_subprocess(gitpath): ['git', 'show', '-s', '--format=%ci', 'HEAD'], cwd=gitpath).decode('UTF-8').strip() return '{} ({})'.format(cid, date) - except (subprocess.CalledProcessError, FileNotFoundError): + except (subprocess.CalledProcessError, OSError): return None diff --git a/scripts/asciidoc2html.py b/scripts/asciidoc2html.py index 878311eb6..c5da58b86 100755 --- a/scripts/asciidoc2html.py +++ b/scripts/asciidoc2html.py @@ -50,7 +50,7 @@ def call_asciidoc(src, dst): args.append(src) try: subprocess.check_call(args) - except subprocess.CalledProcessError as e: + except (subprocess.CalledProcessError, OSError) as e: utils.print_col(str(e), 'red') sys.exit(1) except FileNotFoundError: diff --git a/scripts/run_checks.py b/scripts/run_checks.py index b44cad822..04766aa3b 100755 --- a/scripts/run_checks.py +++ b/scripts/run_checks.py @@ -96,7 +96,7 @@ def _run_subprocess(name, args): """Run a checker via subprocess.""" try: return subprocess.call([name] + args) - except FileNotFoundError: + except OSError: traceback.print_exc() return None diff --git a/scripts/setupcommon.py b/scripts/setupcommon.py index a640f6f5a..0d9219fe4 100644 --- a/scripts/setupcommon.py +++ b/scripts/setupcommon.py @@ -78,7 +78,7 @@ def _git_str(): ['git', 'show', '-s', '--format=%ci', 'HEAD'], cwd=BASEDIR).decode('UTF-8').strip() return '{} ({})'.format(cid, date) - except (subprocess.CalledProcessError, FileNotFoundError): + except (subprocess.CalledProcessError, OSError): return None