From 2e46147ab43ba4007e7ff8a35f4bbec845b3c635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Kwiecin=CC=81ski?= Date: Wed, 6 Mar 2024 22:10:48 +0700 Subject: [PATCH] Trying to fix windows encoding --- entrypoint.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/entrypoint.py b/entrypoint.py index 5f34422..792d1c3 100644 --- a/entrypoint.py +++ b/entrypoint.py @@ -7,7 +7,6 @@ import uuid import zipfile import stat -import sys from itertools import zip_longest @@ -144,6 +143,9 @@ def sizeof_fmt(num, suffix='B', sign=False): exec_call.extend(["--old-mapping", os.getenv("INPUT_OLD_MAPPING_FILE")]) if os.getenv("INPUT_NEW_MAPPING_FILE").strip(): exec_call.extend(["--new-mapping", os.getenv("INPUT_NEW_MAPPING_FILE")]) +exec_call.append("--text") +output_file_name = "diffuse-output.txt" +exec_call.append(output_file_name) oldSize = os.stat(oldFile).st_size oldSizeText = sizeof_fmt(oldSize) @@ -158,16 +160,20 @@ def sizeof_fmt(num, suffix='B', sign=False): print(diffComment1) print(" ".join(exec_call)) -os.system(f"echo \"size-old-bytes={oldSize}\" >> $GITHUB_OUTPUT") -os.system(f"echo \"size-old-text={oldSizeText}\" >> $GITHUB_OUTPUT") -os.system(f"echo \"size-new-bytes={newSize}\" >> $GITHUB_OUTPUT") -os.system(f"echo \"size-new-text={newSizeText}\" >> $GITHUB_OUTPUT") -os.system(f"echo \"size-diff-comment_style_1={diffComment1}\" >> $GITHUB_OUTPUT") +github_output("size-old-bytes", oldSize) +github_output("size-old-text", oldSizeText) +github_output("size-new-bytes", newSize) +github_output("size-new-text", newSizeText) +github_output("size-diff-comment_style_1", diffComment1) -process = subprocess.Popen(exec_call, stdout=subprocess.PIPE) -out, _ = process.communicate() -diff = out.decode(encoding=sys.stdout.encoding).strip() +process = subprocess.run(exec_call) +if process.returncode != 0: + raise Exception("Error while executing diffuse") + +with open(output_file_name, mode="r", encoding="utf-8") as output: + outputPath = os.path.realpath(output.name) + diff = output.read() if process.returncode != 0: raise Exception("Error while executing diffuse") @@ -180,6 +186,7 @@ def sizeof_fmt(num, suffix='B', sign=False): if is_debug(): print(f"Found {len(sections)} sections") + print(f"Full output stored in: {outputPath}") github_comment = "" github_comment_all_collapsed = "" @@ -206,13 +213,6 @@ def sizeof_fmt(num, suffix='B', sign=False): github_comment_no_dex += section(title.strip(), value) github_comment_no_dex_all_collapsed += section(title.strip(), value) -output = open("diffuse-output.txt", "w") -output.write(diff) -output.close() -outputPath = os.path.realpath(output.name) -if is_debug(): - print(f"Full output stored in: {outputPath}") - github_output("diff-file", outputPath) github_output("diff-raw", diff[0:github_output_limit]) github_output("diff-gh-comment", github_comment)