From c80daf69204b0cc44789427ce13a9e0864a0a4d6 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Aug 20 2018 11:42:30 +0000 Subject: explain mbs-manager exception handling Signed-off-by: Nils Philippsen --- diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index a32c920..57c2169 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -3155,6 +3155,13 @@ class Commands(object): try: self._run_command(command, env=env) except rpkgError as e: + # If the exception wraps another one which has .errno == ENOENT + # this indicates that the file (mbs-manager executable) wasn't + # found. This works in both Python 2 and 3 which throw different + # types of exceptions in this case. We use duck-typing rather than + # checking for the respective specific exception types because the + # Python 3 FileNotFoundError exception isn't known in Python 2 and + # special casing this makes the code unnecessarily complicated. e_errno = None if e.args and isinstance(e.args[0], Exception): e_errno = getattr(e.args[0], 'errno', None)