Cleanup code indentation

This commit is contained in:
Josue-T 2020-04-27 11:16:40 +02:00 committed by GitHub
parent 01d5c91e60
commit 72b412c6d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -480,37 +480,39 @@ def app_upgrade(app=[], url=None, file=None, force=False):
logger.success(m18n.n('app_already_up_to_date', app=app_instance_name)) logger.success(m18n.n('app_already_up_to_date', app=app_instance_name))
continue continue
# Manage upgrade type and avoid any upgrade if there are nothing to do # Manage upgrade type and avoid any upgrade if there is nothing to do
upgrade_type = "UNKNOWN" upgrade_type = "UNKNOWN"
upgrade_only_if_version_changes = manifest.get('integration', {}).get("upgrade_only_if_version_changes", None) is True
# Get current_version and new version # Get current_version and new version
app_new_version = manifest.get("version", "?") app_new_version = version.parse(manifest.get("version", "?"))
app_current_version = app_dict.get("version", "?") app_current_version = version.parse(app_dict.get("version", "?"))
if "~ynh" not in str(app_current_version) or "~ynh" not in str(app_new_version):
if manifest.get('integration', {}).get("upgrade_only_if_version_changes", None) is True: logger.warning("/!\\ Packagers ! You have enabled the setting 'upgrade_only_if_version_changes' but you haven't used the official way to define the package version")
if "~ynh" in app_current_version and "~ynh" in app_new_version: upgrade_only_if_version_changes = False
if version.parse(app_current_version) >= version.parse(app_new_version) and not force: if upgrade_only_if_version_changes:
# No new version available if app_current_version >= app_new_version and not force:
logger.success(m18n.n('app_already_up_to_date', app=app_instance_name)) # In case of upgrade from file or custom repository
# Save update time # No new version available
now = int(time.time()) logger.success(m18n.n('app_already_up_to_date', app=app_instance_name))
app_setting(app_instance_name, 'update_time', now) # Save update time
app_setting(app_instance_name, 'current_revision', manifest.get('remote', {}).get('revision', "?")) now = int(time.time())
continue app_setting(app_instance_name, 'update_time', now)
elif version.parse(app_current_version) > version.parse(app_new_version): app_setting(app_instance_name, 'current_revision', manifest.get('remote', {}).get('revision', "?"))
upgrade_type = "DOWNGRADE_FORCED" continue
elif app_current_version == app_new_version: elif app_current_version > app_new_version:
upgrade_type = "UPGRADE_FORCED" upgrade_type = "DOWNGRADE_FORCED"
else: elif app_current_version == app_new_version:
app_current_version_upstream, app_current_version_pkg = app_current_version.split("~ynh") upgrade_type = "UPGRADE_FORCED"
app_new_version_upstream, app_new_version_pkg = app_new_version.split("~ynh")
if app_current_version_upstream == app_new_version_upstream:
upgrade_type = "UPGRADE_PACKAGE"
elif app_current_version_pkg == app_new_version_pkg:
upgrade_type = "UPGRADE_APP"
else:
upgrade_type = "UPGRADE_FULL"
else: else:
logger.warning("/!\\ Packagers ! You have enabled the setting 'upgrade_only_if_version_changes' but you haven't used the official way to define the package version") app_current_version_upstream, app_current_version_pkg = str(app_current_version).split("~ynh")
app_new_version_upstream, app_new_version_pkg = str(app_new_version).split("~ynh")
if app_current_version_upstream == app_new_version_upstream:
upgrade_type = "UPGRADE_PACKAGE"
elif app_current_version_pkg == app_new_version_pkg:
upgrade_type = "UPGRADE_APP"
else:
upgrade_type = "UPGRADE_FULL"
# Check requirements # Check requirements
_check_manifest_requirements(manifest, app_instance_name=app_instance_name) _check_manifest_requirements(manifest, app_instance_name=app_instance_name)