Skip to content

Commit

Permalink
SW-483 added tier switcher for octoprint (#1362)
Browse files Browse the repository at this point in the history
* Added tier switcher for octoprint

* Keep `github_commit` for develop tier

* Only forward the update informations to the hook if they are not None
  • Loading branch information
Josef-MrBeam authored and ahmed-mrbeam committed Nov 17, 2021
1 parent 0240a9c commit 1798842
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions octoprint_mrbeam/software_update_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_update_information(plugin):
_set_info_netconnectd_daemon(plugin, tier, beamos_date),
_set_info_iobeam(plugin, tier, beamos_date),
_set_info_mrb_hw_info(plugin, tier, beamos_date),
# _config_octoprint(plugin, tier),
_config_octoprint(plugin, tier),
],
)
)
Expand Down Expand Up @@ -98,16 +98,26 @@ def switch_software_channel(plugin, channel):
plugin.analytics_handler.add_software_channel_switch_event(old_channel, channel)


# def _config_octoprint(plugin, tier):
# return dict(
# octoprint=dict(
# checkout_folder="/home/pi/OctoPrint",
# pip="https://github.com/mrbeam/OctoPrint/archive/{target_version}.zip",
# user="mrbeam",
# branch="mrbeam2-stable",
# prerelease=(tier == SW_UPDATE_TIER_DEV),
# )
# )
def _config_octoprint(plugin, tier):
prerelease_channel = None
type = "github_release"
if tier in [SW_UPDATE_TIER_ALPHA, SW_UPDATE_TIER_BETA]:
prerelease_channel = "mrbeam2-{tier}"

elif tier in [SW_UPDATE_TIER_DEV]:
type = "github_commit"

return _get_octo_plugin_description(
"octoprint",
tier,
plugin,
type=type,
displayName="OctoPrint",
prerelease=(tier in [SW_UPDATE_TIER_ALPHA, SW_UPDATE_TIER_BETA]),
prerelease_channel=prerelease_channel,
restart="octoprint",
pip="https://github.com/mrbeam/OctoPrint/archive/{target_version}.zip",
)


def _set_info_mrbeam_plugin(plugin, tier, beamos_date):
Expand Down Expand Up @@ -284,13 +294,12 @@ def _get_package_description(
module_id,
tier,
displayName=None,
displayVersion=None,
type="github_commit",
user="mrbeam",
repo=None,
branch="mrbeam2-{tier}",
branch_default="mrbeam2-{tier}",
restart="environment",
prerelease_channel=None,
**kwargs
):
"""Shorthand to create repo details for octoprint software update plugin to handle."""
Expand All @@ -299,16 +308,16 @@ def _get_package_description(
branch = branch.format(tier=get_tier_by_id(tier))
if "{tier}" in branch_default:
branch_default = branch_default.format(tier=get_tier_by_id(tier))
if prerelease_channel and "{tier}" in prerelease_channel:
kwargs.update(prerelease_channel=prerelease_channel.format(tier=get_tier_by_id(tier)))
if tier in (SW_UPDATE_TIER_DEV, SW_UPDATE_TIER_ALPHA):
# adds pip upgrade flag in the develop tier so it will do a upgrade even without a version bump
kwargs.update(pip_upgrade_flag=True)
update_info = dict(
tier=tier,
displayName=displayName,
displayVersion=displayVersion,
user=user,
type=type,
repo=repo,
branch=branch,
branch_default=branch_default,
restart=restart,
Expand Down

0 comments on commit 1798842

Please sign in to comment.