first commit

This commit is contained in:
2023-09-05 16:33:48 +02:00
parent 17117a0b80
commit 2d810ffe98
5 changed files with 157 additions and 0 deletions

41
.gitignore vendored Normal file
View File

@@ -0,0 +1,41 @@
# Do not commit binaries:
*.exe
*.msu
*.msi
*.zip
*.rpm
*.deb
*.yum
*.dmg
*.vsix
*.appx
*.appxbundle
*.msix
*.msixbundle
*.iso
*.cab
*.pkg
*.jar
*.msp
*.part
*.bak
# Do not commit generated WAPT files:
*.pyc
*.crt
*.sha256
*.wapt
.env
*.psproj
**/.vscode/
signature
*.sha1
# Do not commit template part:
template.py
.vscode/*.json
code_template.cmd
/template
package_template.py
# Specific to this package (use ! as prefix to allow commit):

43
all/WAPT/control Normal file
View File

@@ -0,0 +1,43 @@
package : comi-apps-to-update-on-wapt-server
version : 0-10
architecture : all
section : base
priority : optional
name : json-update
categories : Utilities
maintainer : Comitari,pcosson
description : Package to audit the wapt-server and generate a json with applications that are not up to date
depends :
conflicts :
maturity : PROD
locale : all
target_os : all
min_wapt_version : 2.3
sources :
installed_size :
impacted_process :
description_fr : Package pour auditer le serveur wapt et générer un json avec les applications qui ne sont pas à jour
description_pl : Pakiet do audytu serwera wapt i generowania pliku json z aplikacjami, które nie są aktualne
description_de : Paket zur Überprüfung des wapt-Servers und zur Erstellung eines json mit Anwendungen, die nicht auf dem neuesten Stand sind
description_es : Paquete para auditar el servidor wapt y generar un json con las aplicaciones que no están actualizadas
description_pt : Pacote para auditar o wapt-server e gerar um json com as aplicações que não estão atualizadas
description_it : Pacchetto per verificare il server wapt e generare un json con le applicazioni che non sono aggiornate
description_nl : Pakket om de wapt-server te controleren en een json te genereren met applicaties die niet up-to-date zijn
description_ru : Пакет для аудита wapt-сервера и генерации json с неактуальными приложениями
audit_schedule :
editor :
keywords :
licence : opensource_free,wapt_public
homepage :
package_uuid :
valid_from :
valid_until :
forced_install_on :
changelog :
min_os_version :
max_os_version :
icon_sha256sum :
signer :
signer_fingerprint:
signature_date :
signed_attributes :

BIN
all/WAPT/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

69
all/setup.py Normal file
View File

@@ -0,0 +1,69 @@
# -*- coding: utf-8 -*-
from setuphelpers import *
import requests
import json
from configparser import ConfigParser
def install():
plugin_inifile = makepath(WAPT.private_dir, "wapt_api.ini")
if not isfile(plugin_inifile):
filecopyto("wapt_api.ini", WAPT.private_dir)
def audit():
plugin_inifile = makepath(WAPT.private_dir, "wapt_api.ini")
conf_wapt = ConfigParser()
conf_wapt.read(plugin_inifile)
wapt_url = conf_wapt.get("wapt", "wapt_url")
wapt_user = conf_wapt.get("wapt", "wapt_username")
wapt_password = conf_wapt.get("wapt", "wapt_password")
app_to_update_json_path = makepath(WAPT.private_dir, "app_to_update.json")
if isfile(app_to_update_json_path):
print("suppression de l'ancienne version du fichier json")
remove_file(app_to_update_json_path)
# Download JSON data from the URL
json_data = download_json_from_url("https://wapt.tranquil.it/store/packages_list")
if json_data is None:
return "ERROR"
online_dict = {}
transformed_package_dict = {}
app_to_update_list = []
# Transform data from JSON into a dictionary
for element in json_data:
online_dict[element[0].replace("tis-", "comi-")] = element[1]
# Assuming WAPT.list() returns a list of dictionaries containing package data
local_package_dict = json.loads(wgets("https://%s:%s@%s/api/v3/packages" % (wapt_user, wapt_password, wapt_url)))
# count the number of packages in the WAPT repository
print("Nombre de paquets dans le dépôt WAPT : " + str(len(local_package_dict)))
# Transform package data into a dictionary
for element in local_package_dict["result"]:
transformed_package_dict[element["package"]] = element["version"]
# Compare versions and find packages that need to be updated
for key in online_dict:
if key in transformed_package_dict:
if Version(online_dict[key]) > Version(transformed_package_dict[key]):
print("ajout de " + key + " à la liste des paquets à mettre à jour")
app_to_update_list.append({"package": key, "version": online_dict[key]})
with open(app_to_update_json_path, "w") as json_file:
json.dump(app_to_update_list, json_file)
return "OK"
def download_json_from_url(url):
try:
response = requests.get(url, verify=False)
response.raise_for_status() # Raise an exception for unsuccessful responses
json_data = response.json()
return json_data
except requests.exceptions.RequestException as e:
print(f"Error downloading JSON from URL: {e}")
return None

4
all/wapt_api.ini Normal file
View File

@@ -0,0 +1,4 @@
[wapt]
wapt_username = xxxxx
wapt_password = xxxxx
wapt_url =xxxxx