[RESOLU] Paquet WAPT dell-command-update-uwp

Questions about WAPT Packaging / Requêtes et aides autour des paquets Wapt.
Règles du forum
Règles du forum communautaire
* English support on www.reddit.com/r/wapt
* Le support communautaire en français se fait sur ce forum
* Merci de préfixer le titre du topic par [RESOLU] s'il est résolu.
* Merci de ne pas modifier un topic qui est taggé [RESOLU]. Ouvrez un nouveau topic en référençant l'ancien
* Préciser version de WAPT installée, version complète ET numéro de build (2.2.1.11957 / 2.2.2.12337 / etc.) AINSI QUE l'édition Enterprise / Discovery
* Les versions 1.8.2 et antérieures ne sont plus maintenues. Les seules questions acceptées vis à vis de la version 1.8.2 sont liés à la mise à jour vers une version supportée (2.1, 2.2, etc.)
* Préciser OS du serveur (Linux / Windows) et version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019)
* Préciser OS de la machine d'administration/création des paquets et de la machine avec l'agent qui pose problème le cas échéant (Windows 7 / 10 / 11 / Debian 11 / etc.)
* Eviter de poser plusieurs questions lors de l'ouverture de topic, sinon il risque d'être ignorer. Si plusieurs sujet, ouvrir plusieurs topic, et de préférence les uns après les autres et pas tous en même temps (ie ne pas spammer le forum).
* Inclure directement les morceaux de code, les captures d'écran et autres images directement dans le post. Les liens vers les pastebin, les bitly et autres sites tierces seront systématiquement supprimés.
* Comme tout forum communautaire, le support est fait bénévolement par les membres. Si vous avez besoin d'un support commercial, vous pouvez contacter le service commercial Tranquil IT au 02.40.97.57.55
SeiyaGame
Messages : 12
Inscription : 25 mai 2023 - 15:19

25 août 2023 - 17:09

Bonjour,

J'ai mis à jour ce paquet car une nouvelle version est disponible, c'est la version 5.0.0
J'ai adapté le code pour prendre en compte les changements du site Dell et aussi apporté quelques modifications pour les autres fonctions ( Peut être pas nécessaire ? )

Voici le code du fichier update_package.py:

Code : Tout sélectionner

# -*- coding: utf-8 -*-
from setuphelpers import *
from setupdevhelpers import *
import re


def update_package():
    # Declaring local variables
    result = False
    proxies = get_proxies()
    if not proxies:
        proxies = get_proxies_from_wapt_console()
    app_name = control.name
    url = "https://www.dell.com/support/kbdoc/en-us/000177325/dell-command-update"

    # Getting latest download link from official sources
    print("URL used is: %s" % url)
    for bs_search in bs_find_all(url, "a", "target", "_blank", proxies=proxies, timeout=10):  # , headers={"Accept-Language": "en,en-US"} not working
        url_title = (bs_search.string).replace(u'\xa0', u' ')
        if re.search("(?:Windows Universal|Universal Windows) (?:Application|Platform)", url_title):
            download_url = bs_search["href"]
            break

    # Getting latest version from official sources
    print("URL used is: %s" % download_url)
    for bs_search in bs_find_all(
        download_url, "a", "class", "dellmetrics-driverdownloads", proxies=proxies, timeout=10
    ):  # , headers={"Accept-Language": "en,en-US;"} not working
        if "Télécharger" in bs_search.string:
            version = bs_search["href"].split("_")[-2]
            latest_bin = bs_search["href"].split("/")[-1]
            download_url = bs_search["href"]
            break

    print("Latest %s version is: %s" % (app_name, version))
    print("Download URL is: %s" % download_url)

    # Downloading latest binaries
    if not isfile(latest_bin):
        print("Downloading: %s" % latest_bin)
        wget(download_url, latest_bin, proxies=proxies)
    else:
        print("Binary is present: %s" % latest_bin)

        # Checking version from file
        version_from_file = get_version_from_binary(latest_bin)
        # if not version_from_file.startswith(version) and version_from_file != '':
        if Version(version_from_file) != Version(version) and version_from_file != "":
            print("Changing version to the version number of the binary (from: %s to: %s)" % (version, version_from_file))
            os.rename(latest_bin, bin_contains + version_from_file + ".EXE")
            version = version_from_file
        else:
            print("Binary file version corresponds to online version")

    # Changing version of the package
    if Version(version) > Version(control.get_software_version()):
        print("Software version updated (from: %s to: %s)" % (control.get_software_version(), Version(version)))
        result = True
    else:
        print("Software version up-to-date (%s)" % Version(version))
    control.version = "%s-%s" % (Version(version), control.version.split("-", 1)[-1])
    # control.set_software_version(version)
    control.save_control_to_wapt()

    # Deleting outdated binaries
    remove_outdated_binaries(version)

    # Validating or not update-package-sources
    return result
Voici le code du fichier setup.py :
( Peut être que la modification de la fonction uninstall et audit n'est pas pertinentes )

Code : Tout sélectionner

# -*- coding: utf-8 -*-
from setuphelpers import *

"""
Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()

"""


def install():
    # Declaring local variables
    bin_name = glob.glob("*Dell-Command-Update-Windows-Universal-Application*.EXE")[0]

    # Installing the software
    print("Installing: %s" % bin_name)
    install_exe_if_needed(
        bin_name,
        silentflags="/s /factoryinstall",
        name="Dell Command | Update for Windows Universal",
        min_version=control.get_software_version(),
        timeout=900,
    )

    # Disabling telemetry
    registry_set(HKEY_LOCAL_MACHINE, r"SOFTWARE\DELL\UpdateService\Clients\CommandUpdate\Preferences\Settings\General", "UserConsentDefault", 0)
    registry_set(HKEY_LOCAL_MACHINE, r"SOFTWARE\DELL\UpdateService\Clients\CommandUpdate\Preferences\CFG", "ShowSetupPopup", 0)
    
    # Download updates (notify when ready)
    registry_set(
        HKEY_LOCAL_MACHINE, r"SOFTWARE\DELL\UpdateService\Clients\CommandUpdate\Preferences\Settings\Schedule", "AutomationMode", "ScanDownloadNotify"
    )
    registry_set(
        HKEY_LOCAL_MACHINE, r"SOFTWARE\DELL\UpdateService\Clients\CommandUpdate\Preferences\Settings\Schedule", "ScheduleMode", 
        "Auto"
    )

    # Manual updates only
    # registry_set(
    #     HKEY_LOCAL_MACHINE, r"SOFTWARE\DELL\UpdateService\Clients\CommandUpdate\Preferences\Settings\Schedule", "ScheduleMode", 
    #     "ManualUpdates"
    # )

    # Disable notification
    # registry_set(
    #     HKEY_LOCAL_MACHINE, r"SOFTWARE\DELL\UpdateService\Clients\CommandUpdate\Preferences\Settings\Schedule", "DisableNotification", 1
    # )

def uninstall():
    # Uninstalling the software
    print("Uninstalling: %s" % control.package)

    softs = installed_softwares('Dell Command | Update')
    for soft in softs:
        msiexec_command = ' '.join(uninstall_cmd(soft['key']))
        break
    
    run(msiexec_command)
    remove_appx("DellInc.DellCommandUpdate")

def audit():
    
    service_name = "DellClientManagementService"
    service_start_mode = get_service_start_mode(service_name)
    service_status = service_is_running(service_name)

    if service_start_mode in ["Disabled", "Manual"] and service_status:
        print("The Dell service is stopped and prevents the application from working properly.")
        return "ERROR"
    else:
        print("The Dell service is working properly.")
        return "OK"
Flavien.

Informations générales :

Serveur WAPT : Debian 11, version 2.4.0.14143, Édition Entreprise
Machine d'administration : Windows 11, version WAPT 2.4.0.14143
Avatar de l’utilisateur
jpele
Messages : 153
Inscription : 04 mars 2019 - 12:01
Localisation : Nantes

13 sept. 2023 - 17:52

Bonjour,
Merci pour votre retour, j'ai modifié le code en ce sens.
Je retravaillé votre audit pour le rendre plus fiable et j'ai intégré la partie du code commenté.

Voici le changelog :

Code : Tout sélectionner

-8
===
now audit DellClientManagementService service
print that Dell Command Update UWP can only be installed on a Dell System
Pour information l'update_package était corrigé depuis 2 jours sur le dépôt : https://wapt.tranquil.it/wapt-testing
N'hésitez pas à surveiller ce dépôt depuis votre console si vous attendez un paquet.

Cordialement,
Jimmy
Verrouillé