From 36dc58bf3501990d9ffa12f2bccfdd83b889c140 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Aug 20 2018 10:54:05 +0000 Subject: catch errno == ENOENT if mbs-manager is missing Sometimes a missing mbs-manager will cause exceptions that don't have the exact same error message. Additionally, test for wrapped exceptions with an errno set to ENOENT. Signed-off-by: Nils Philippsen --- diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index c094e8a..a32c920 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -3155,7 +3155,11 @@ class Commands(object): try: self._run_command(command, env=env) except rpkgError as e: - if str(e) == '[Errno 2] No such file or directory': + e_errno = None + if e.args and isinstance(e.args[0], Exception): + e_errno = getattr(e.args[0], 'errno', None) + if (e_errno == errno.ENOENT + or str(e) == '[Errno 2] No such file or directory'): raise rpkgError('mbs-manager is missing. Please install ' 'module-build-service.') else: