From 77ac926361010e05b0b56323367f0ad12f18f8b9 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Mon, 19 Mar 2018 11:43:07 +0530 Subject: [PATCH] fix version decode, added safe_decode for bench --- bench/utils.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bench/utils.py b/bench/utils.py index fd3db388..497bbb3f 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -16,6 +16,13 @@ logger = logging.getLogger(__name__) folders_in_bench = ('apps', 'sites', 'config', 'logs', 'config/pids') +def safe_decode(string, encoding = 'utf-8'): + try: + string = string.decode(encoding) + except Exception: + pass + return string + def get_frappe(bench_path='.'): frappe = get_env_cmd('frappe', bench_path=bench_path) if not os.path.exists(frappe): @@ -351,7 +358,7 @@ def get_git_version(): '''returns git version from `git --version` extracts version number from string `get version 1.9.1` etc''' version = get_cmd_output("git --version") - version = version.decode('utf-8') + version = safe_decode(version) version = version.strip().split()[2] version = '.'.join(version.split('.')[0:2]) return float(version)