From 1ec857bf41fb2486fd8b486c969793af1f395af7 Mon Sep 17 00:00:00 2001 From: Lowell Alleman Date: Fri, 21 Jun 2019 14:00:39 -0400 Subject: [PATCH 1/3] Enhance missing command detection If a given VCS command is not executable or blocked from execution by a LSM (SELinux/AppArmor) for example, then consider that VCS to be unavailable. This change prevents the error: OSError: [Error 13] Permission denied --- bumpversion/vcs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bumpversion/vcs.py b/bumpversion/vcs.py index 5df3592..122354e 100644 --- a/bumpversion/vcs.py +++ b/bumpversion/vcs.py @@ -51,8 +51,8 @@ def is_usable(cls): == 0 ) except OSError as e: - if e.errno == 2: - # mercurial is not installed then, ok. + if e.errno in (2, 13): + # VCS is not installed or permission denied then, ok. return False raise From d924c76072e5e6306a2b2d4fe3fd412cca4626d5 Mon Sep 17 00:00:00 2001 From: Lowell Alleman Date: Mon, 24 Jun 2019 12:48:46 -0400 Subject: [PATCH 2/3] Use errno constants - Swap hard-coded error numbers with constants from the errno module. --- bumpversion/vcs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bumpversion/vcs.py b/bumpversion/vcs.py index 122354e..767ee06 100644 --- a/bumpversion/vcs.py +++ b/bumpversion/vcs.py @@ -5,6 +5,7 @@ import logging import os import subprocess +import errno from tempfile import NamedTemporaryFile from bumpversion.exceptions import ( @@ -51,8 +52,7 @@ def is_usable(cls): == 0 ) except OSError as e: - if e.errno in (2, 13): - # VCS is not installed or permission denied then, ok. + if e.errno in (errno.ENOENT, errno.EACCES): return False raise From 10dd277be7c3a75b29c1bd8e37063808d8aa24a8 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Tue, 25 Jun 2019 15:47:28 +0200 Subject: [PATCH 3/3] Sort imports --- bumpversion/vcs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bumpversion/vcs.py b/bumpversion/vcs.py index 767ee06..0a577c4 100644 --- a/bumpversion/vcs.py +++ b/bumpversion/vcs.py @@ -2,10 +2,10 @@ from __future__ import unicode_literals, print_function +import errno import logging import os import subprocess -import errno from tempfile import NamedTemporaryFile from bumpversion.exceptions import (