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()