From 5ecba6b13c9ce062052b263addeaed503e309abd Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 11 Jun 2022 23:11:50 +1000 Subject: [PATCH] Add error handling for case where user does not have git installed (#3179) --- InvenTree/plugin/helpers.py | 6 ++++++ InvenTree/plugin/registry.py | 3 +++ 2 files changed, 9 insertions(+) diff --git a/InvenTree/plugin/helpers.py b/InvenTree/plugin/helpers.py index f776bf95b8..53326ab286 100644 --- a/InvenTree/plugin/helpers.py +++ b/InvenTree/plugin/helpers.py @@ -111,6 +111,9 @@ def get_git_log(path): output = output.split('\n') except subprocess.CalledProcessError: # pragma: no cover pass + except FileNotFoundError: # pragma: no cover + # Most likely the system does not have 'git' installed + pass if not output: output = 7 * [''] # pragma: no cover @@ -125,6 +128,9 @@ def check_git_version(): output = str(subprocess.check_output(['git', '--version'], cwd=os.path.dirname(settings.BASE_DIR)), 'utf-8') except subprocess.CalledProcessError: # pragma: no cover return False + except FileNotFoundError: # pragma: no cover + # Most likely the system does not have 'git' installed + return False # process version string try: diff --git a/InvenTree/plugin/registry.py b/InvenTree/plugin/registry.py index 7443191cb6..98486dee38 100644 --- a/InvenTree/plugin/registry.py +++ b/InvenTree/plugin/registry.py @@ -227,6 +227,9 @@ class PluginsRegistry: except subprocess.CalledProcessError as error: # pragma: no cover logger.error(f'Ran into error while trying to install plugins!\n{str(error)}') return False + except FileNotFoundError: # pragma: no cover + # System most likely does not have 'git' installed + return False logger.info(f'plugin requirements were run\n{output}')