tis-charlemagne-notes icon

Charlemagne Notes

Paquet d’installation silencieuse pour Charlemagne Notes

12.1.0.0-5

  • package: tis-charlemagne-notes
  • name: Charlemagne Notes
  • version: 12.1.0.0-5
  • maintainer: WAPT Team,Tranquil IT, Flavien Schelfaut
  • editor: Aplim
  • locale: all
  • target_os: windows
  • impacted_process: Notes.exe
  • architecture: all
  • signature_date:
  • size: 41.04 Mo
  • homepage : https://www.aplim.fr
  • depends:

package           : tis-charlemagne-notes
version           : 12.1.0.0-5
architecture      : all
section           : base
priority          : optional
name              : Charlemagne Notes
categories        : 
maintainer        : WAPT Team,Tranquil IT, Flavien Schelfaut
description       : Charlemagne Notes
depends           : tis-charlemagne-competences,tis-charlemagne-outils
conflicts         : 
maturity          : PROD
locale            : all
target_os         : windows
min_wapt_version  : 2.1
sources           : https://api.ecoledirecte.com/v3/c/0/download/majcharlemagne.awp?verbe=get&chemin=MiseAJour\V2\&fichier=wNotes.exe
installed_size    : 
impacted_process  : Notes.exe
description_fr    : 
description_pl    : 
description_de    : 
description_es    : 
description_pt    : 
description_it    : 
description_nl    : 
description_ru    : 
audit_schedule    : 
editor            : Aplim
keywords          : 
licence           : 
homepage          : https://www.aplim.fr
package_uuid      : 49448858-1b5f-4100-b40f-46cb6ddb5f9e
valid_from        : 
valid_until       : 
forced_install_on : 
changelog         : 
min_os_version    : 10.0
max_os_version    : 
icon_sha256sum    : 181b48805706db35434cd78dd7bc70e2a340ff947e5db9201c3940662fafb6da
signer            : Tranquil IT
signer_fingerprint: 8c5127a75392be9cc9afd0dbae1222a673072c308c14d88ab246e23832e8c6bb
signature_date    : 2025-01-13T17:00:17.000000
signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,min_wapt_version,sources,installed_size,impacted_process,description_fr,description_pl,description_de,description_es,description_pt,description_it,description_nl,description_ru,audit_schedule,editor,keywords,licence,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
signature         : mi2AD2jpkECXqlc+NdsWPnZd3ua11Pg2xQw913Gnxr7HKH+pB870sp978MCuBPRJAF6hqCtWsXhPm0jA7yScmlyNGA/9Wk5f8hXa4hjO0h917aEDUovhxZbWkHAnhASBeFN1IoLnDPCBYuu6Xk8RcuBVOjt+5rWGjw8HxCG1770UorIsssPe//W0gd2r2YxEYzdK/lPT8bZHjvHhPDisTE15yoDB4bAXbJc20Aiwbj03uFIAQYnSHyDkfoyT88qkYDjBVSMvrg8YddgxqF1y3TsO/FWTghXa20Aaamq18mIZLZG3TV99xUbVmFyqk9RzNcl0LuV21JKOUGVzcj+tVg==

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

# Declaring global variables - Warnings: 1) WAPT context is only available in package functions; 2) Global variables are not persistent between calls
bin_name = "charlemagne_notes.exe"
silent_args = "/S"
desktop_shortcut_name = 'Charlemagne Notes'
path_folder = makepath(programfiles32(),'alcuin')
bin_exe = makepath(path_folder, 'Notes.exe') # Edit here the name of the executable

def install():
    
    # Initializing variables
    package_version = control.version.split("-")[0]
    
    # Installing the package
    print(f"Installing: {bin_name}")
    if force or not isfile(bin_exe) or Version(get_version_from_binary(bin_exe)) < Version(package_version):
        killalltasks(control.impacted_process)
        run(f"{makepath(basedir, bin_name)} {silent_args}")

    if not isfile(bin_exe): 
        error('error %s not found' % bin_exe) 

    bin_version = get_version_from_binary(bin_exe)
    if Version(bin_version) < Version(package_version):
        error('Version file for %s is %s' % (bin_exe,bin_version))
    
    remove_desktop_shortcut(desktop_shortcut_name)

def uninstall():
    remove_desktop_shortcut(desktop_shortcut_name)
    remove_file(bin_exe)

def audit():
    
    if not isfile(bin_exe):
        print(f"The executable can't be found here : {bin_exe}")
        return "ERROR"

    bin_version = get_version_from_binary(bin_exe)
    package_version = control.version.split("-")[0]

    if Version(bin_version) < Version(package_version):
        print('Version file for %s is %s' % (bin_exe,bin_version))
        return "ERROR"        

    if Version(bin_version) > Version(package_version):
        print('Version file for %s is %s' % (bin_exe,bin_version))
        return "WARNING"

    print("The installation has been done correctly")
    return "OK"

# -*- coding: UTF-8 -*-
from setuphelpers import *
from setupdevhelpers import *
import waptlicences
import json


url = "https://www.aplim.fr/Documentation.aspx/GetDirectoryAndFiles"
targeted_text = "Gestion des Notes"
latest_bin = "charlemagne_notes.exe"

def get_json_file(proxies=None):

    url="https://www.aplim.fr/Documentation.aspx/GetDirectoryAndFiles"

    headers = {
        "accept": "application/json",
        "content-type": "application/json",
        "cache-control": "no-cache",
        "pragma": "no-cache",
        "user-agent": "WAPT"
    }

    try:   
        response = requests.get(url, headers=headers, proxies=proxies)
        response.raise_for_status()
        response = response.json()

        return json.loads(response['d'])
    except:
        error('Unable to get json from aplim website !')

def find_charlemagne_downloads(json_file):
    downloads = next((item['nodes'] for item in json_file if item.get('text') == "Téléchargements"), list())
    charlemagne_item = next((item for item in downloads if item.get('text') == "Charlemagne"), dict())
    return charlemagne_item.get('nodes', list())

def find_charlemagne_software(downloads, targeted_text):
    for download in downloads:
        if targeted_text in download.get('text', ''):
            return download
    return None

def contains_letters(chaine):
    return any(c.isalpha() for c in chaine)

def get_charlemagne_version(text):
    return text.split('-')[-1].strip()

def update_package():
    # Declaring local variables
    package_updated = False
    proxies = get_proxies_from_wapt_console()
    if not proxies:
        proxies = get_proxies()

    app_name = control.name

    charlemagne_downloads = find_charlemagne_downloads(get_json_file(proxies=proxies))
    software = find_charlemagne_software(charlemagne_downloads, targeted_text)
    version = get_charlemagne_version(software['text'])
    
    download_url = software['href']

    print(f"Latest {app_name} version is: {version}")
    print(f"Download url is: {download_url}")

    # Before Aplim set up a bad naming scheme for its applications (Ex: 21.B , 9.2A ...)
    # so we check if this is not the case
    if contains_letters(version):
        print("For the moment, this application cannot be packaged due to incorrect version naming...")
        return package_updated

    for f in glob.glob('*.exe'):
        if Version(get_version_from_binary(f)) < Version(version):
            remove_file(f)

    if not isfile(latest_bin):
        print(f"Downloading: {latest_bin}")
        package_updated = True
        wget(download_url, latest_bin, proxies=proxies)
    else:
        print(f"Binary is present: {latest_bin}")

    expected_issuer = 'Aplim'
    sign_name = waptlicences.check_exe_signing_certificate(latest_bin)[0]
    if sign_name != expected_issuer:
        error(f'Bad issuer {sign_name} != {expected_issuer} ')

    # Changing version of the package
    if Version(version) > Version(control.get_software_version()):
        print(f"Software version updated (from: {control.get_software_version()} to: {version})")
        package_updated = True
    else:
        print(f"Software version up-to-date ({version})")
        
    control.set_software_version(get_version_from_binary(latest_bin))
    control.save_control_to_wapt()

    return package_updated

38d056ab130f7bf7c481c12636a4e9959de36561d3dfcbe54c6e3571bc0c1dc3 : WAPT/certificate.crt
ffc2cd844c21365b34b68c66e99187781517291076482f3ae62934b7590961b9 : WAPT/control
181b48805706db35434cd78dd7bc70e2a340ff947e5db9201c3940662fafb6da : WAPT/icon.png
e6c7d69b80a4556c40d62ab32ad0772b44f09e1a617a4634ad9f87fd1ca9bb4e : charlemagne_notes.exe
204067213c556277c5f5a30993b7d979ae153c067dca3a3122a21a5e43b92901 : luti.json
baa0a0d7272351818cc9b0e41d4aeb81ef59d0d8b913d7fd86dada0c539d08a8 : setup.py
27a06b2a2bea2ac930fe2d4c3a8ac72144951c9146a3ed6561aadec14b8bf6ad : update_package.py