Updating the python import paths for the o3de scripts to use the new package o3de package location
This commit is contained in:
+15
-8
@@ -10,17 +10,24 @@
|
||||
#
|
||||
|
||||
import argparse
|
||||
import pathlib
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Resolve the common python module
|
||||
ROOT_DEV_PATH = os.path.realpath(os.path.join(os.path.dirname(__file__), '..'))
|
||||
if ROOT_DEV_PATH not in sys.path:
|
||||
sys.path.append(ROOT_DEV_PATH)
|
||||
# As o3de.py shares the same name as the o3de package attempting to use a regular
|
||||
# from o3de import <module> line tries to import from the current o3de.py script and not the package
|
||||
# So the current script directory is removed from the sys.path temporary
|
||||
SCRIPT_DIR_REMOVED = False
|
||||
SCRIPT_DIR = pathlib.Path(__file__).parent.resolve()
|
||||
if str(SCRIPT_DIR) in sys.path:
|
||||
SCRIPT_DIR_REMOVED = True
|
||||
sys.path.remove(str(SCRIPT_DIR))
|
||||
|
||||
from cmake.Tools import engine_template
|
||||
from cmake.Tools import global_project
|
||||
from cmake.Tools import registration
|
||||
from o3de import engine_template
|
||||
from o3de import global_project
|
||||
from o3de import registration
|
||||
|
||||
if SCRIPT_DIR_REMOVED:
|
||||
sys.path.insert(0, str(SCRIPT_DIR))
|
||||
|
||||
|
||||
def add_args(parser, subparsers) -> None:
|
||||
|
||||
@@ -9,4 +9,4 @@
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
#
|
||||
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(tests)
|
||||
|
||||
@@ -20,8 +20,8 @@ import json
|
||||
import uuid
|
||||
import re
|
||||
|
||||
from cmake.Tools import utils
|
||||
import cmake.Tools.registration as registration
|
||||
|
||||
from o3de import utils, registration
|
||||
|
||||
logger = logging.getLogger()
|
||||
logging.basicConfig()
|
||||
@@ -2423,7 +2423,7 @@ if __name__ == "__main__":
|
||||
the_parser = argparse.ArgumentParser()
|
||||
|
||||
# add subparsers
|
||||
the_subparsers = the_parser.add_subparsers(help='sub-command help')
|
||||
the_subparsers = the_parser.add_subparsers(help='sub-command help', dest='command', required=True)
|
||||
|
||||
# add args to the parser
|
||||
add_args(the_parser, the_subparsers)
|
||||
@@ -2432,7 +2432,8 @@ if __name__ == "__main__":
|
||||
the_args = the_parser.parse_args()
|
||||
|
||||
# run
|
||||
ret = the_args.func(the_args)
|
||||
|
||||
ret = the_args.func(the_args) if hasattr(the_args, 'func') else 1
|
||||
|
||||
# return
|
||||
sys.exit(ret)
|
||||
|
||||
@@ -16,7 +16,7 @@ import sys
|
||||
import re
|
||||
import pathlib
|
||||
import json
|
||||
import cmake.Tools.registration as registration
|
||||
from o3de import registration
|
||||
|
||||
logger = logging.getLogger()
|
||||
logging.basicConfig()
|
||||
@@ -153,7 +153,7 @@ if __name__ == "__main__":
|
||||
the_parser = argparse.ArgumentParser()
|
||||
|
||||
# add subparsers
|
||||
the_subparsers = the_parser.add_subparsers(help='sub-command help')
|
||||
the_subparsers = the_parser.add_subparsers(help='sub-command help', dest='command', required=True)
|
||||
|
||||
# add args to the parser
|
||||
add_args(the_parser, the_subparsers)
|
||||
@@ -162,7 +162,7 @@ if __name__ == "__main__":
|
||||
the_args = the_parser.parse_args()
|
||||
|
||||
# run
|
||||
ret = the_args.func(the_args)
|
||||
ret = the_args.func(the_args) if hasattr(the_args, 'func') else 1
|
||||
|
||||
# return
|
||||
sys.exit(ret)
|
||||
|
||||
@@ -4416,7 +4416,7 @@ if __name__ == "__main__":
|
||||
the_parser = argparse.ArgumentParser()
|
||||
|
||||
# add subparsers
|
||||
the_subparsers = the_parser.add_subparsers(help='sub-command help')
|
||||
the_subparsers = the_parser.add_subparsers(help='sub-command help', dest='command', required=True)
|
||||
|
||||
# add args to the parser
|
||||
add_args(the_parser, the_subparsers)
|
||||
@@ -4425,7 +4425,7 @@ if __name__ == "__main__":
|
||||
the_args = the_parser.parse_args()
|
||||
|
||||
# run
|
||||
ret = the_args.func(the_args)
|
||||
ret = the_args.func(the_args) if hasattr(the_args, 'func') else 1
|
||||
|
||||
# return
|
||||
sys.exit(ret)
|
||||
|
||||
@@ -29,12 +29,11 @@ executable_path = ''
|
||||
logger = logging.getLogger()
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
from cmake.Tools import engine_template
|
||||
from cmake.Tools import registration
|
||||
from o3de import engine_template, registration
|
||||
|
||||
o3de_folder = registration.get_o3de_folder()
|
||||
o3de_logs_folder = registration.get_o3de_logs_folder()
|
||||
project_manager_log_file_path = o3de_log_folder / "project_manager.log"
|
||||
project_manager_log_file_path = o3de_logs_folder / "project_manager.log"
|
||||
log_file_handler = RotatingFileHandler(filename=project_manager_log_file_path, maxBytes=1024 * 1024, backupCount=1)
|
||||
formatter = logging.Formatter('%(asctime)s | %(levelname)s : %(message)s')
|
||||
log_file_handler.setFormatter(formatter)
|
||||
|
||||
Reference in New Issue
Block a user