Fix update_package logic

This commit is contained in:
Daniel Berteaud 2019-01-07 19:04:53 +01:00
parent f1e77fc6f1
commit ab33857304
2 changed files with 21 additions and 22 deletions

View File

@ -5,28 +5,28 @@ section : base
priority : optional
maintainer : Daniel Berteaud
description : Clean and optimize Windows
depends :
conflicts :
depends :
conflicts :
maturity : PROD
locale : all
target_os : windows
min_os_version : 5.1
max_os_version :
max_os_version :
min_wapt_version : 1.5
sources :
installed_size :
sources :
installed_size :
impacted_process : ccleaner.exe,ccleaner64.exe
description_fr : Outils de nettoyage et d'optimisation de Windows
description_pl :
description_de :
description_es :
audit_schedule :
description_pl :
description_de :
description_es :
audit_schedule :
editor : Piriform
keywords :
licence :
keywords :
licence :
homepage : http://www.piriform.com/ccleaner/
package_uuid :
package_uuid :
signer : Daniel Berteaud
signer_fingerprint:
signature_date :
signed_attributes :
signer_fingerprint:
signature_date :
signed_attributes :

View File

@ -52,12 +52,13 @@ def session_setup():
def update_package():
control = PackageEntry().load_control_from_wapt ('.')
page = requests.get('https://www.ccleaner.com/fr-fr/ccleaner/download/slim',headers={'User-Agent':'Mozilla/5.0 (Windows NT 6.1; Win64; x64)'}).text
bs = BeautifulSoup.BeautifulSoup(page)
download = bs.find('p', attrs={"class": u"fs-13"}).a["href"]
filename = download.rsplit('/',1)[1]
# on ne telecharge que si on ne l'a pas deja
# Only download if needed
if not isfile(filename):
wget(download, filename)
else:
@ -69,12 +70,10 @@ def update_package():
remove_file(fn)
vers = get_file_properties(filename)['ProductVersion']
os.chdir(os.path.dirname(__file__))
from waptpackage import PackageEntry
pe = PackageEntry()
pe.load_control_from_wapt(os.getcwd())
pe.version = vers + '-0'
pe.save_control_to_wapt(os.getcwd())
if Version(vers) > Version(control['version'].split('-',1)[0]):
control.version = vers + '-0'
control.save_control_to_wapt(os.getcwd())
if __name__ == '__main__':