From ae6a42406441c91566b5b6fb320ce6ea88379724 Mon Sep 17 00:00:00 2001 From: pconroy Date: Thu, 1 Jul 2021 13:22:44 -0700 Subject: [PATCH] Make remove_invalid_o3de_projects take a path and return a value Signed-off-by: pconroy --- Code/Tools/ProjectManager/Source/ProjectsScreen.cpp | 4 ++-- Code/Tools/ProjectManager/Source/ProjectsScreen.h | 2 +- Code/Tools/ProjectManager/Source/PythonBindings.cpp | 12 +++++++++--- Code/Tools/ProjectManager/Source/PythonBindings.h | 2 +- .../ProjectManager/Source/PythonBindingsInterface.h | 2 +- scripts/o3de/o3de/register.py | 13 ++++++++++--- 6 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp b/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp index df828b028a..90ef0b6416 100644 --- a/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp +++ b/Code/Tools/ProjectManager/Source/ProjectsScreen.cpp @@ -483,9 +483,9 @@ namespace O3DE::ProjectManager return displayFirstTimeContent; } - void ProjectsScreen::RemoveInvalidProjects() + bool ProjectsScreen::RemoveInvalidProjects() { - PythonBindingsInterface::Get()->RemoveInvalidProjects(); + return PythonBindingsInterface::Get()->RemoveInvalidProjects(); } void ProjectsScreen::StartProjectBuild(const ProjectInfo& projectInfo) diff --git a/Code/Tools/ProjectManager/Source/ProjectsScreen.h b/Code/Tools/ProjectManager/Source/ProjectsScreen.h index e2929c1107..6bedb1a188 100644 --- a/Code/Tools/ProjectManager/Source/ProjectsScreen.h +++ b/Code/Tools/ProjectManager/Source/ProjectsScreen.h @@ -59,7 +59,7 @@ namespace O3DE::ProjectManager ProjectButton* CreateProjectButton(ProjectInfo& project, QLayout* flowLayout, bool processing = false); void ResetProjectsContent(); bool ShouldDisplayFirstTimeContent(); - void RemoveInvalidProjects(); + bool RemoveInvalidProjects(); void StartProjectBuild(const ProjectInfo& projectInfo); QList::iterator RequiresBuildProjectIterator(const QString& projectPath); diff --git a/Code/Tools/ProjectManager/Source/PythonBindings.cpp b/Code/Tools/ProjectManager/Source/PythonBindings.cpp index 11ca5a79c5..00b6940255 100644 --- a/Code/Tools/ProjectManager/Source/PythonBindings.cpp +++ b/Code/Tools/ProjectManager/Source/PythonBindings.cpp @@ -755,13 +755,19 @@ namespace O3DE::ProjectManager }); } - void PythonBindings::RemoveInvalidProjects() + bool PythonBindings::RemoveInvalidProjects() { - ExecuteWithLockErrorHandling( + bool removalResult = false; + bool result = ExecuteWithLock( [&] { - m_register.attr("remove_invalid_o3de_projects")(); + auto pythonRemovalResult = m_register.attr("remove_invalid_o3de_projects")(); + + // Returns an exit code so boolify it then invert result + removalResult = !pythonRemovalResult.cast(); }); + + return result && removalResult; } AZ::Outcome PythonBindings::UpdateProject(const ProjectInfo& projectInfo) diff --git a/Code/Tools/ProjectManager/Source/PythonBindings.h b/Code/Tools/ProjectManager/Source/PythonBindings.h index a64727abfe..98ca8e90f0 100644 --- a/Code/Tools/ProjectManager/Source/PythonBindings.h +++ b/Code/Tools/ProjectManager/Source/PythonBindings.h @@ -50,7 +50,7 @@ namespace O3DE::ProjectManager AZ::Outcome UpdateProject(const ProjectInfo& projectInfo) override; AZ::Outcome AddGemToProject(const QString& gemPath, const QString& projectPath) override; AZ::Outcome RemoveGemFromProject(const QString& gemPath, const QString& projectPath) override; - void RemoveInvalidProjects() override; + bool RemoveInvalidProjects() override; // ProjectTemplate AZ::Outcome> GetProjectTemplates(const QString& projectPath = {}) override; diff --git a/Code/Tools/ProjectManager/Source/PythonBindingsInterface.h b/Code/Tools/ProjectManager/Source/PythonBindingsInterface.h index c4a271cfa1..8580087737 100644 --- a/Code/Tools/ProjectManager/Source/PythonBindingsInterface.h +++ b/Code/Tools/ProjectManager/Source/PythonBindingsInterface.h @@ -144,7 +144,7 @@ namespace O3DE::ProjectManager /** * Removes invalid projects from the manifest */ - virtual void RemoveInvalidProjects() = 0; + virtual bool RemoveInvalidProjects() = 0; // Project Templates diff --git a/scripts/o3de/o3de/register.py b/scripts/o3de/o3de/register.py index 3a006735ed..d1029ee47f 100644 --- a/scripts/o3de/o3de/register.py +++ b/scripts/o3de/o3de/register.py @@ -658,13 +658,20 @@ def register(engine_path: pathlib.Path = None, return result -def remove_invalid_o3de_projects() -> None: - json_data = manifest.load_o3de_manifest() +def remove_invalid_o3de_projects(manifest_path: pathlib.Path = None) -> int: + if not manifest_path: + manifest_path = manifest.get_o3de_manifest() + + json_data = manifest.load_o3de_manifest(manifest_path) + + result = 0 for project in json_data['projects']: if not validation.valid_o3de_project_json(pathlib.Path(project).resolve() / 'project.json'): logger.warn(f"Project path {project} is invalid.") - register(project_path=pathlib.Path(project), remove=True) + result = register(project_path=pathlib.Path(project), remove=True) + + return result def remove_invalid_o3de_objects() -> None: json_data = manifest.load_o3de_manifest()