Page 1 of 1

[SOLVED] Audit status Warning and unknown

Published: July 24, 2023 - 3:24 PM
by AveyronJJ
Version: WAPTconsole 2.4.0.14031 -1420892a

Hello,

I'm taking over a WAPT installation and some packages and installations that were done by someone who is no longer with our department.
The last thing they did was install a package that copies an ISO image if one isn't already present.
The package does the copy correctly when necessary, but the audit status remains "Warning" on all machines in the inventory section
and "Unknown" in the General tab.
How can I reset these machines to "OK"?

Have a good day!

Re: Audit status Warning and unknown

Published: July 24, 2023 - 4:27 PM
by dcardon
Hi Jean-Jacques,

could you please provide the contents of your setup.py file so we can see the problem? The return code is returned by the script, so if it's incorrect, we'd need to check the code in the `def install()` function.

The audit status is also handled in the setup.py file, but within the `def audit()` function.

Regards,

Denis

Re: Audit status Warning and unknown

Published: July 25, 2023 - 08:14
by AveyronJJ
Hello Denis,

The code is as follows:

Code: Select all

from setuphelpers import *
import shutil
import os
from datetime import datetime

def install():
    # Chemin d'accès au fichier ISO dans le paquet WAPT
    iso_file_path = os.path.join(os.path.dirname(__file__), 'C6440102C-A.iso')

    # Chemin de destination pour la copie de l'ISO
    destination_folder = r'C:\PMF\install\cache\office2016'
    destination_file_path = os.path.join(destination_folder, 'C6440102C-A.iso')

    # Vérification et création du dossier de destination s'il n'existe pas
    if not os.path.exists(destination_folder):
        os.makedirs(destination_folder)
        print(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - Le dossier de destination a été créé avec succès.")
    else:
        print(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - Le dossier existe déjà.")

    # Vérification si le fichier ISO existe déjà dans la destination
    if not os.path.exists(destination_file_path):
        # Copie de l'ISO vers la destination
        shutil.copy2(iso_file_path, destination_file_path)
        print(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - La copie de l'ISO s'est bien exécutée.")
    else:
        print(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - Le fichier ISO est déjà en place.")

    # Chemin du fichier de log
    log_file_path = r'C:\PMF\RAPPINST\CopieOffice2016.log'

    # Ouverture du fichier de log en mode append (ajout à la fin)
    with open(log_file_path, 'a') as log_file:
        log_file.write(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - Copie de Office 2016 : Succès\n")

    print(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - Le fichier de log a été mis à jour avec succès.")

    print(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')} - Fin du log.")

def uninstall():
    # Votre code de désinstallation ici
    pass

def session_setup():
    # Votre code de configuration de session ici
    pass

def audit():
    # Votre code d'audit ici
    pass

def update_package():
    # Votre code de mise à jour du package ici
    pass
Sincerely,

Jean-Jacques

Re: Audit status Warning and unknown

Published: July 25, 2023 - 5:47 PM
by dcardon
Hello Jean-Jacques,

the `def audit()` function is not defined in the package.

By default, WAPT checks for the presence of the software uninstallation key when creating a software deployment package. Since your package doesn't contain any software installation, the `audit()` function is not defined, hence the "UNKNOWN" status. In the main grid, the UNKNOWN audit status is marked as WARNING to draw attention, but we didn't use UNKNOWN because this status is specific to a package (while the others are probably OK).

In the `audit` function, you can add a simple `return "OK"`, or even better, check that the ISO file is present, and if so, return OK; otherwise, return ERROR.

Sincerely,

Denis

Re: Audit status Warning and unknown

Published: July 26, 2023 - 10:29 AM
by AveyronJJ
Thank you Denis,

have a good day.

Jean-Jacques