From c891c2734b5b1cc2513cc05c380b23a16fedae87 Mon Sep 17 00:00:00 2001 From: msyyc <70930885+msyyc@users.noreply.github.com> Date: Fri, 5 Mar 2021 14:55:53 +0800 Subject: [PATCH] [Python] python track1 new pipeline (#16489) * exception handle and encode problem * Update autorest_tools.py --- scripts/automation_generate.sh | 19 +++++++++++++------ .../packaging_tools/auto_package.py | 2 -- .../swaggertosdk/autorest_tools.py | 4 ++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/scripts/automation_generate.sh b/scripts/automation_generate.sh index f2c291651fdb..5d7575870488 100644 --- a/scripts/automation_generate.sh +++ b/scripts/automation_generate.sh @@ -10,12 +10,19 @@ sudo npm install -g n sudo n 10.15.0 export PATH=/usr/local/n/versions/node/10.15.0/bin:$PATH -# generate code and package -python -m packaging_tools.auto_codegen "$1" "$TMPDIR/venv-sdk/auto_temp.json" 2>&1 +TEMP_FILE="$TMPDIR/venv-sdk/auto_temp.json" +# generate code +python -m packaging_tools.auto_codegen "$1" "$TEMP_FILE" 2>&1 echo "[Generate] codegen done!!!" -python -m packaging_tools.auto_package "$TMPDIR/venv-sdk/auto_temp.json" "$2" 2>&1 -echo "[Generate] generate done!!!" +if [ ! -f "$TEMP_FILE" ]; then + echo "[Autorest]$TEMP_FILE does not exist!!!Error happened during codegen" + exit 1 +fi +# package +python -m packaging_tools.auto_package "$TEMP_FILE" "$2" 2>&1 +echo "[Generate] generate done!!!" if [ ! -f "$2" ]; then - echo "[Autorest]$2 does not exist!!!" -fi + echo "[Autorest]$2 does not exist!!!Error happened during package" + exit 1 +fi \ No newline at end of file diff --git a/tools/azure-sdk-tools/packaging_tools/auto_package.py b/tools/azure-sdk-tools/packaging_tools/auto_package.py index 323fc2d305f2..52f633ff105b 100644 --- a/tools/azure-sdk-tools/packaging_tools/auto_package.py +++ b/tools/azure-sdk-tools/packaging_tools/auto_package.py @@ -47,8 +47,6 @@ def change_log_generate(package_name): def main(generate_input, generate_output): with open(generate_input, "r") as reader: data = json.load(reader) - if not data: - return sdk_folder = '.' result = { diff --git a/tools/azure-sdk-tools/packaging_tools/swaggertosdk/autorest_tools.py b/tools/azure-sdk-tools/packaging_tools/swaggertosdk/autorest_tools.py index 378a3129aa91..09a52686dcd3 100644 --- a/tools/azure-sdk-tools/packaging_tools/swaggertosdk/autorest_tools.py +++ b/tools/azure-sdk-tools/packaging_tools/swaggertosdk/autorest_tools.py @@ -5,7 +5,6 @@ import shutil import subprocess - _LOGGER = logging.getLogger(__name__) @@ -130,7 +129,8 @@ def execute_simple_command(cmd_line, cwd=None, shell=False, env=None): universal_newlines=True, cwd=cwd, shell=shell, - env=env) + env=env, + encoding='utf-8') output_buffer = [] for line in process.stdout: output_buffer.append(line.rstrip())