Skip to content

Commit

Permalink
🚸 Apply liblvgl when upgrading to PROS 4 (#345)
Browse files Browse the repository at this point in the history
* Apply liblvgl when upgrading from PROS 3 to PROS 4

* Fetch template if necessary
  • Loading branch information
mayankpatibandla authored May 1, 2024
1 parent 30dfe91 commit 022dc57
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pros/cli/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions pros/conductor/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("")
Expand All @@ -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?')
Expand Down Expand Up @@ -333,6 +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:
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},'
Expand Down

0 comments on commit 022dc57

Please sign in to comment.