From 2619087b5615985d15f744f194607f4ebfa4995c Mon Sep 17 00:00:00 2001 From: Mayank Patibandla <34776435+mayankpatibandla@users.noreply.github.com> Date: Sun, 28 Apr 2024 18:44:31 -0400 Subject: [PATCH 1/2] Apply liblvgl when upgrading from PROS 3 to PROS 4 --- pros/cli/conductor.py | 2 +- pros/conductor/conductor.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pros/cli/conductor.py b/pros/cli/conductor.py index 00a0ecb5..38d43235 100644 --- a/pros/cli/conductor.py +++ b/pros/cli/conductor.py @@ -159,7 +159,7 @@ def upgrade(ctx: click.Context, project: c.Project, query: c.BaseTemplate, **kwa """ analytics.send("upgrade-project") if not query.name: - for template in project.templates.keys(): + for template in tuple(project.templates.keys()): click.secho(f'Upgrading {template}', color='yellow') q = c.BaseTemplate.create_query(name=template, target=project.target, supported_kernels=project.templates['kernel'].version) diff --git a/pros/conductor/conductor.py b/pros/conductor/conductor.py index fb40d7e1..69c650a5 100644 --- a/pros/conductor/conductor.py +++ b/pros/conductor/conductor.py @@ -282,6 +282,8 @@ def apply_template(self, project: Project, identifier: Union[str, BaseTemplate], raise dont_send( InvalidTemplateException(f'Could not find a template satisfying {identifier} for {project.target}')) + apply_liblvgl = False # flag to apply liblvgl if upgrading to PROS 4 + # warn and prompt user if upgrading to PROS 4 or downgrading to PROS 3 if template.name == 'kernel': isProject = Project.find_project("") @@ -294,6 +296,7 @@ def apply_template(self, project: Project, identifier: Union[str, BaseTemplate], if not confirm: raise dont_send( InvalidTemplateException(f'Not upgrading')) + apply_liblvgl = True if template.version[0] == '3' and curr_proj.kernel[0] == '4': confirm = ui.confirm(f'Warning! Downgrading project to PROS 3 will cause breaking changes. ' f'Do you still want to downgrade?') @@ -333,6 +336,8 @@ def apply_template(self, project: Project, identifier: Union[str, BaseTemplate], force_user=kwargs.pop('force_user', False), remove_empty_directories=kwargs.pop('remove_empty_directories', False)) ui.finalize('apply', f'Finished applying {template.identifier} to {project.location}') + if apply_liblvgl: + self.apply_template(project=project, identifier="liblvgl") elif valid_action != TemplateAction.AlreadyInstalled: raise dont_send( InvalidTemplateException(f'Could not install {template.identifier} because it is {valid_action.name},' From 47944ac34ccd69d5f94e0d8bdc816d65d3df1f67 Mon Sep 17 00:00:00 2001 From: Mayank Patibandla <34776435+mayankpatibandla@users.noreply.github.com> Date: Sun, 28 Apr 2024 19:47:09 -0400 Subject: [PATCH 2/2] Fetch template if necessary --- pros/conductor/conductor.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pros/conductor/conductor.py b/pros/conductor/conductor.py index 69c650a5..8e0d9e44 100644 --- a/pros/conductor/conductor.py +++ b/pros/conductor/conductor.py @@ -336,8 +336,16 @@ def apply_template(self, project: Project, identifier: Union[str, BaseTemplate], force_user=kwargs.pop('force_user', False), remove_empty_directories=kwargs.pop('remove_empty_directories', False)) ui.finalize('apply', f'Finished applying {template.identifier} to {project.location}') + + # Apply liblvgl if upgrading to PROS 4 if apply_liblvgl: - self.apply_template(project=project, identifier="liblvgl") + template = self.resolve_template(identifier="liblvgl", allow_online=download_ok, early_access=True) + if not isinstance(template, LocalTemplate): + with ui.Notification(): + template = self.fetch_template(self.get_depot(template.metadata['origin']), template, **kwargs) + assert isinstance(template, LocalTemplate) + project.apply_template(template) + ui.finalize('apply', f'Finished applying {template.identifier} to {project.location}') elif valid_action != TemplateAction.AlreadyInstalled: raise dont_send( InvalidTemplateException(f'Could not install {template.identifier} because it is {valid_action.name},'