[SOLVED] Update Package Paraview

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
vnatton
Messages: 6
Registration: January 9, 2024 - 1:53 PM

April 18, 2024 - 5:17 PM

Good morning,

I just created a package update function for ParaView (https://www.paraview.org/)
I've been sweating a bit, so if this can be useful for "Lutizing" it.

The update is based on the "non-MPI" 64-bit version (see: https://learn.microsoft.com/en-us/messa ... rosoft-mpi)

As always, it's not super clean, but it works
I deliberately renamed the MSI file after downloading it because if the Python version changed in the binary, that would have needed to be managed as well. As for the shortcut, I had to create it manually because the silent MSI doesn't generate it.

Facility

Code: Select all

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

def install():
    app_path = makepath(programfiles,"Paraview %s\\bin" % control.get_software_version())
    msi = "ParaView-%s.msi" % control.get_software_version()

    install_msi_if_needed(msi)
    create_programs_menu_shortcut('Paraview', target="%s\\paraview.exe" % app_path)

    pass
The update_package

Code: Select all

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

def update_package():
    import requests
    import re
    from bs4 import BeautifulSoup
    from packaging.version import Version, parse
    from datetime import date
    import html.parser

    # Stockage de la version actuelle
    ancienne_version = control.get_software_version()

    #URL de base des téléchargements
    url = "https://www.paraview.org/files/"

    #RegEx du format de la version
    regex = r"v[0-9]*"

    #Requete pour récupérer le contenu de la page de téléchargement et récupération de la version la plus récente
    site = requests.get(url)
    HTML = site.text
    soup = BeautifulSoup(HTML,'html.parser')
    table = soup.find('table')

    trs = table.find_all('tr')

    version_courte = "0.0"

    for tr in trs:
        tds = tr.find_all('td')

        for td in tds:
            if re.match(regex, td.text):
                if Version(td.text[1:-1]) > Version(version_courte):
                    last = 1
                elif Version(td.text[1:-1]) < Version(version_courte):
                    last = -1
                else:
                    last = 0

                if last == 1:
                    version_courte = td.text[1:-1]


    #Contruction de l'URL de téléchargement apres avoir trouvé la dernière version
    constructed_url = "https://www.paraview.org/files/v%s" % version_courte

    #Requete pour récupérer le contenu de la page de téléchargement et récupérer le dernier fichier MSI (NON MPI)
    site2 = requests.get(constructed_url)
    HTML2 = site2.text
    soup2 = BeautifulSoup(HTML2,'html.parser')
    table2 = soup2.find('table')

    trsb = table2.find_all('tr')
    previousDate = "1970-01-01"

    for trb in trsb[3:-1]:
        tdsb = trb.find_all('td')

        if tdsb[1].find('a').text.endswith('.msi') == True and not "MPI" in tdsb[1].find('a').text:
            #Date
            date = tdsb[2].text.split(" ")[0]

            if previousDate < date:
                lastDate = date
                previousDate = date
                print(tdsb[1].find('a').text)
                latest_bin = tdsb[1].find('a').text
            else:
                print(date)
                tdsb[1].find('a').text
                previousDate = date

    version_complete = latest_bin.split("-")[1]
    ancien_fichier = 'ParaView-%s.msi' % ancienne_version

    #Comparaison de la dernière version avec celle du paquet
    if Version(version_complete) > Version(control.get_software_version()):
        package_updated=True

        print("Downloading: %s" % latest_bin)
        wget("%s/%s" % (constructed_url,latest_bin),"ParaView-%s.msi" % version_complete)

        print("Software version updated (from: %s to: %s)" % (control.get_software_version(), Version(version_complete)))

        # Suppression de l'ancien binaire
        if isfile(ancien_fichier):
            os.remove(ancien_fichier)

        control.set_software_version(version_complete)
        control.save_control_to_wapt()
    else:
        package_updated=False
        print("Binary is present: %s" % ancien_fichier)

    #On retourne True ou False pour que la console sache si elle doit update le paquet
    return package_updated

    pass
Good day
Vianney
User avatar
jpele
Messages: 156
Registration: March 4, 2019 - 12:01
Location: Nantes

April 19, 2024 - 11:09

As agreed with Vianney, this package will be retrieved as part of the WAPT Enterprise Store with a view to making it available to everyone.
Locked