1#!/usr/bin/env python 2# -*- coding: utf-8 -*- 3# Copyright (c) 2021 Huawei Device Co., Ltd. 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15import os 16import runpy 17import sys 18 19 20DEBUG = False 21 22 23def find_oem_script(path): 24 for relpath, dirs, files in os.walk(path): 25 if "oem_hook.py" in files: 26 script_path = os.path.join(path, relpath, "oem_hook.py") 27 return os.path.normpath(os.path.abspath(script_path)) 28 return "" 29 30 31def main(): 32 if DEBUG: 33 print("Run oem hook start") 34 hiview_build_path = os.path.split(os.path.realpath(__file__))[0] 35 hiview_path = os.path.realpath(os.path.join(hiview_build_path, "..")) 36 script_path = find_oem_script(hiview_path) 37 if script_path.strip() == '': 38 print("Could not find oem hook") 39 else: 40 runpy.run_path(script_path, run_name='__main__') 41 42 if DEBUG: 43 print("Run oem hook end") 44 return 0 45 46 47if __name__ == '__main__': 48 sys.exit(main()) 49