Il y a trois ou quatre ans j'ai créé un paquet pour Screenpresso avec l'ajout de la fonction update_package.
La version du fichier msi n'étant pas correctement indiqué dans le fichier j'ai rusé en téléchargeant la version EXE pour l'extraite puis je supprime le fichier EXE
Pouvez-vous l'ajouter au paquet ?
Le code pourrait être améliorer mais en l'état cela fonctionne parfaitement.
Chez moi j'ai conservé les commentaires datant de l'époque où je fonctionnait avec l'application portable.
C'est probablement KO mais je l'ai conservé en souvenir comme exemple en interne
Code : Tout sélectionner
# -*- 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()