1e1051a39Sopenharmony_ci#!/usr/bin/env python 2e1051a39Sopenharmony_ci# -*- coding: utf-8 -*- 3e1051a39Sopenharmony_ci 4e1051a39Sopenharmony_ci# Copyright (c) 2023 Huawei Device Co., Ltd. 5e1051a39Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 6e1051a39Sopenharmony_ci# you may not use this file except in compliance with the License. 7e1051a39Sopenharmony_ci# You may obtain a copy of the License at 8e1051a39Sopenharmony_ci# 9e1051a39Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 10e1051a39Sopenharmony_ci# 11e1051a39Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 12e1051a39Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 13e1051a39Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14e1051a39Sopenharmony_ci# See the License for the specific language governing permissions and 15e1051a39Sopenharmony_ci# limitations under the License. 16e1051a39Sopenharmony_ci 17e1051a39Sopenharmony_ciimport subprocess 18e1051a39Sopenharmony_ciimport sys 19e1051a39Sopenharmony_ci 20e1051a39Sopenharmony_ci 21e1051a39Sopenharmony_cidef main(): 22e1051a39Sopenharmony_ci cmd = sys.argv[1:] 23e1051a39Sopenharmony_ci print(f'cmd {cmd} start') 24e1051a39Sopenharmony_ci result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 25e1051a39Sopenharmony_ci print(f'result.returncode = {result.returncode}') 26e1051a39Sopenharmony_ci print(f'result.stdout = {result.stdout.decode("utf-8", errors="ignore")}') 27e1051a39Sopenharmony_ci if (result.returncode != 0): 28e1051a39Sopenharmony_ci raise Exception(f'cmd {cmd} failed') 29e1051a39Sopenharmony_ci else: 30e1051a39Sopenharmony_ci print(f'cmd {cmd} ok') 31e1051a39Sopenharmony_ci 32e1051a39Sopenharmony_ciif __name__ == '__main__': 33e1051a39Sopenharmony_ci sys.exit(main()) 34