From dd813587ac550a6c0eb64ac04bd66e39b7a9b1c4 Mon Sep 17 00:00:00 2001 From: Achilles Rasquinha Date: Mon, 12 Mar 2018 18:25:00 +0530 Subject: [PATCH] fixes for encoding decoding --- bench/app.py | 3 +++ bench/cli.py | 2 +- bench/utils.py | 4 +++- patches.txt | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 patches.txt diff --git a/bench/app.py b/bench/app.py index 11c203ab..0710d65b 100755 --- a/bench/app.py +++ b/bench/app.py @@ -172,6 +172,7 @@ def pull_all_apps(bench_path='.', reset=False): app_dir = get_repo_dir(app, bench_path=bench_path) if os.path.exists(os.path.join(app_dir, '.git')): out = subprocess.check_output(["git", "status"], cwd=app_dir) + out = out.decode('utf-8') if not re.search(r'nothing to commit, working (directory|tree) clean', out): print(''' @@ -234,6 +235,7 @@ def get_remote(app, bench_path='.'): repo_dir = get_repo_dir(app, bench_path=bench_path) contents = subprocess.check_output(['git', 'remote', '-v'], cwd=repo_dir, stderr=subprocess.STDOUT) + contents = contents.decode('utf-8') if re.findall('upstream[\s]+', contents): remote = 'upstream' else: @@ -273,6 +275,7 @@ def get_upstream_version(app, branch=None, bench_path='.'): branch = get_current_branch(app, bench_path=bench_path) try: contents = subprocess.check_output(['git', 'show', 'upstream/{branch}:{app}/__init__.py'.format(branch=branch, app=app)], cwd=repo_dir, stderr=subprocess.STDOUT) + contents = contents.decode('utf-8') except subprocess.CalledProcessError as e: if b"Invalid object" in e.output: return None diff --git a/bench/cli.py b/bench/cli.py index 8e05c9f0..e6ad9984 100755 --- a/bench/cli.py +++ b/bench/cli.py @@ -96,7 +96,7 @@ def get_frappe_commands(bench_path='.'): return [] try: output = get_cmd_output("{python} -m frappe.utils.bench_helper get-frappe-commands".format(python=python), cwd=sites_path) - output = output.decode('utf-8') + # output = output.decode('utf-8') return json.loads(output) except subprocess.CalledProcessError: return [] diff --git a/bench/utils.py b/bench/utils.py index 88b361a4..fd3db388 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -373,7 +373,9 @@ def check_git_for_shallow_clone(): def get_cmd_output(cmd, cwd='.'): try: - return subprocess.check_output(cmd, cwd=cwd, shell=True, stderr=open(os.devnull, 'wb')).strip() + output = subprocess.check_output(cmd, cwd=cwd, shell=True, stderr=open(os.devnull, 'wb')).strip() + output = output.decode('utf-8') + return output except subprocess.CalledProcessError as e: if e.output: print(e.output) diff --git a/patches.txt b/patches.txt new file mode 100644 index 00000000..8f127fe4 --- /dev/null +++ b/patches.txt @@ -0,0 +1 @@ +bench.patches.v3.deprecate_old_config