Update_package proposal for Screenpresso

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
Answer
jlatieule
Messages: 59
Registration: July 3, 2019 - 9:18 AM

October 7, 2024 - 1:13 PM

Hello team,


Three or four years ago I created a package for Screenpresso with the addition of the update_package function.
Since the MSI file version wasn't correctly indicated in the file, I used a workaround by downloading the EXE version, extracting it, and then deleting the EXE file

Can you add it to the package?
The code could be improved, but as it stands it works perfectly.
At home I kept the comments dating back to the time when I was using the mobile application.
It's probably a KO, but I kept it as a souvenir as an internal example

Code: Select all

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

uninstallkey = []

def install():
    version = control['version'].split('-',1)[0]

##    print('Desinstallation version EXE avant déploiement version portable')
##    if isdir(makepath(programfiles,'Learnpulse','Screenpresso')):
##        print('The directory exists')
##        print('Desinstallation de Screenpresso')
##        run('"C:\Program Files\Learnpulse\Screenpresso\Screenpresso.exe" -uninstall pf -silent')

##    print('Suppression de la version portable')
##    remove_tree( makepath('C:','ProgramData','Screenpresso'), ignore_errors=True )

##    print(u'Ajout de démarrage automatique')
##    registry_set(HKEY_LOCAL_MACHINE, r"Software\Microsoft\Windows\CurrentVersion\Run",'Screenpresso','"C:\Program Files\Learnpulse\Screenpresso\Screenpresso.exe" run --hideworkspace')

    # Suppression du démarrage auto de l'ancienne version à créer
    print('Installation de Screenpresso format MSI')
    install_msi_if_needed("Screenpresso.msi",killbefore="screenpresso")

##    print('Installation de Screenpresso format EXE')
##    install_exe_if_needed("Screenpresso.exe",'/install pf /silent',key='Screenpresso',min_version=version,killbefore=['Screenpresso.exe'],accept_returncodes=[4])

##    print('Copie pour utilisation application portable')
##    mkdirs(makepath ('C:','ProgramData','Screenpresso'))
##    filecopyto('Screenpresso.exe',makepath ('C:','ProgramData','Screenpresso'))
##    create_shortcut(r"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Screenpresso.lnk" , r"C:\Program Files\Learnpulse\Screenpresso\Screenpresso.exe")


def uninstall():
    print('Desinstallation de Screenpresso')
    for soft in installed_softwares('Screenpresso'):
        run(WAPT.uninstall_cmd(soft['key']))

##    run('"C:\Program Files\Learnpulse\Screenpresso\Screenpresso.exe" -uninstall pf -silent')



def session_setup():
##    print('Ajout au démarrage de session pour version portable')
##    registry_setstring(HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Run",'Screenpresso','"C:\ProgramData\Screenpresso\Screenpresso.exe" --portablemode --hideworkspace', type=REG_SZ)

##    # A FINALISER
##    print('Suppression au démarrage de session')
##    registry_deletekey(HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Run",'Screenpresso')
##    registry_deletekey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Run",'Screenpresso')

    remove_user_programs_menu_shortcut('Screenpresso')



def update_package():
    # Version MSI correcte depuis 12.2023, code à faire évoluer
    #print(get_product_props('Screenpresso.msi')['version'])


    try:
        import BeautifulSoup
    except:
        import bs4 as BeautifulSoup
    import re

    proxies = {}
    if isfile(makepath(user_local_appdata(),'waptconsole','waptconsole.ini')):
        proxywapt = inifile_readstring(makepath(user_local_appdata(),'waptconsole','waptconsole.ini'),'global','http_proxy')
        if proxywapt :
            proxies = {'http':proxywapt,'https':proxywapt}

    # Recherche et téléchargement de la dernière version de ScreenPresso
    os.chdir(os.path.dirname(__file__))
    page = wgets('https://www.screenpresso.com/fr/telechargement-msi',user_agent='Mozilla/5.0 (Windows NT 6.1; Win64; x64)',proxies=proxies)
    # Téléchargement du MSI
    bs = BeautifulSoup.BeautifulSoup(page, features="html.parser")
    url32 = bs.find(title = u"Cliquez ici pour télécharger")["href"]

    print(u'Telechargement de Screenpresso MSI')
    print (url32)
    wget(url32,'Screenpresso.msi',proxies=proxies)


    print(u'Recherche numéro de version (celui du MSI est incorrect)')
    bs = BeautifulSoup.BeautifulSoup(page, features="html.parser")
    url32 = bs.find(role = "button")["href"]
    #print ("Chemin vers la version : %s" % url32)

    version = (
        url32.split('screenpresso-')[1]
        .split('/')[0]
        .replace('-', '.')
    )

    # Changement de version du paquet
    if Version(version) > Version(control.get_software_version()):
        print("Mise à jour de la version logicielle (de: %s à: %s)" % (control.get_software_version(), Version(version)))
        package_updated = True
    else:
        print("Version du logiciel est déjà à jour (%s)" % Version(version))
    control.set_software_version(version)
    control.save_control_to_wapt()

##    # Validating or not update-package-sources
##    return package_updated

##if __name__ == '__main__':
##    update_package()
System and Network Administrator at Domitia Habitat
User avatar
blemoigne
Messages: 178
Registration: July 17, 2020 - 11:29

October 11, 2024 - 10:38

Hi @jlatieule,
Have you tried this one? https://wapt.tranquil.it/store/fr/tis-screenpresso

Bertrand
jlatieule
Messages: 59
Registration: July 3, 2019 - 9:18 AM

October 11, 2024 - 5:12 PM

Yes, and it simply installs a basic executable file
System and Network Administrator at Domitia Habitat
User avatar
blemoigne
Messages: 178
Registration: July 17, 2020 - 11:29

October 11, 2024 - 6:05 PM

Hi Joël,

I don't know if you're familiar with this interface: https://luti.tranquil.it/
You can track package builds as soon as a developer updates an application.
Screenpresso is one of these tracked packages and therefore already has an update_package() function. The update_package() function is now defined in a separate file (update_package.py instead of setup.py).

Have a good weekend,
Bertrand
Answer