Files
o3de/scripts/build/package/util.py
T
Steve Pham 38261d0800 Shorten copyright headers by splitting into 2 lines (#2213)
* Updated all copyright headers to split the longer original copyright line into 2 shorter lines

Signed-off-by: Steve Pham <spham@amazon.com>
2021-07-16 15:25:48 -07:00

60 lines
1.5 KiB
Python
Executable File

#
# Copyright (c) Contributors to the Open 3D Engine Project.
# For complete copyright and license terms please see the LICENSE at the root of this distribution.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
#
import json
import os
import re
import sys
import subprocess
class LyBuildError(Exception):
def __init__(self, message):
super(LyBuildError, self).__init__(message)
def ly_build_error(message):
raise LyBuildError(message)
def error(message):
print(('Error: {}'.format(message)))
exit(1)
# Exit with status code 0 means it won't fail the whole build process
def safe_exit_with_error(message):
print(('Error: {}'.format(message)))
exit(0)
def warn(message):
print(('Warning: {}'.format(message)))
def execute_system_call(command, **kwargs):
print(('Executing subprocess.check_call({})'.format(command)))
try:
subprocess.check_call(command, **kwargs)
except subprocess.CalledProcessError as e:
print((e.output))
error('Executing subprocess.check_call({}) failed with error {}'.format(command, e))
except FileNotFoundError as e:
error("File Not Found - Failed to call {} with error {}".format(command, e))
def safe_execute_system_call(command, **kwargs):
print(('Executing subprocess.check_call({})'.format(command)))
try:
subprocess.check_call(command, **kwargs)
except subprocess.CalledProcessError as e:
print((e.output))
warn('Executing subprocess.check_call({}) failed'.format(command))
return e.returncode
return 0