# -*- coding: utf-8 -*-
from setuphelpers import *
import waptguihelper
def update_package():
if params.get("install_with_luti", False):
return "OK"
nbr_logos = waptguihelper.ID_YES == waptguihelper.message_dialog(
"WAPT - Personnalisez la console avec votre logo", "Voulez vous appliquer un seul logo?", waptguihelper.ID_YES
)
if nbr_logos is True:
wapt_logo = waptguihelper.filename_dialog("Choose the WAPT Logo (.PNG) you want to use", "", "", "PNG|*.png")
filecopyto(wapt_logo, makepath(basedir, "wapt-logo.png"))
else:
waptexit_logo = waptguihelper.filename_dialog("Choose the WAPT Exit (.PNG) you want to use", "", "", "PNG|*.png")
filecopyto(waptexit_logo, makepath(basedir, "waptexit-logo.png"))
waptself_logo = waptguihelper.filename_dialog("Choose the WAPT SelfService (.PNG) you want to use", "", "", "PNG|*.png")
filecopyto(waptself_logo, makepath(basedir, "waptself-logo.png"))
waptmessage_logo = waptguihelper.filename_dialog("Choose the WAPT Message (.PNG) you want to use", "", "", "PNG|*.png")
filecopyto(waptmessage_logo, makepath(basedir, "waptmessage-logo.png"))
ask_control_package(control.package, "-template")
control.save_control_to_wapt()
# Validating or not update-package-sources
return ask_control_version(control.get_software_version())
def ask_control_version(version, inc_build=False):
"""Requesting that the user supply package version for the `control.version`. Additionally it will make sure user will be able to upload_package from WAPT Console"""
package_updated = False
# Changing version of the package
if Version(version, 4) > Version(control.get_software_version(), 4):
print("Software version updated (from: %s to: %s)" % (control.get_software_version(), Version(version)))
package_updated = True
else:
version_plus = (
".".join(version.split(".")[: len(version.split(".")) - 1]) + "." + str(int(version.split(".")[len(version.split(".")) - 1]) + 1)
)
version = ask_dialog(control.package, "Version must be %s minimum to upload from WAPT Console" % version_plus, version_plus)
if not version:
version = control.get_software_version()
if Version(version, 4) > Version(control.get_software_version(), 4):
print("Software version updated (from: %s to: %s)" % (control.get_software_version(), Version(version)))
package_updated = True
control.set_software_version(version)
if inc_build:
control.inc_build()
control.save_control_to_wapt()
return package_updated
def ask_dialog(title, text, default="", stay_on_top=False):
"""This function opens a dialog box with a action input"""
# - Title: the title for the dialog
# - Text: indicates which value the user should type
# - Default: the default value, if the user do not want to type any
# Optional:
# - StayOnTop: indicates if the form will always stay on top - default is False
return waptguihelper.input_dialog(title, text, default, stay_on_top)
def ask_control_package(control_package=None, conditionnal_package_name=None, remove_base_files=False):
"""Requesting that the user provide a package name to be entered into the control.package field, and offering the possibility of removing the base files (icon.png and changelog.txt) for template package usage
Args:
control_package (str) : prefilled control_package (default: actual control_package)
conditionnal_package_name (str) : only ask when the control.package contains conditionnal_package_name (default: always ask for control_package)
remove_base_files (bool) : removes base files if parameter is True and conditionnal_package_name is provided (default: False)
"""
if conditionnal_package_name is None or conditionnal_package_name in control.package:
control.package = waptguihelper.input_dialog(
control.package,
"You can redefine the package name",
control_package.replace(conditionnal_package_name, "") if conditionnal_package_name is not None else control_package,
)
control.save_control_to_wapt()