[SOLVED] Session_cleanup function not working for the LibreOffice Fantastic Cartable extension

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
brice73
Messages: 42
Registration: February 13, 2023 - 8:05 AM

April 14, 2026 - 10:41

Good morning,

Some time ago, I was trying to package the "Fantastic Schoolbag" extension for LibreOffice. After some difficulty, I managed to package it and am sharing the package here in case it might be useful to someone. (This package depends on a package that installs LibreOffice.)

Code: Select all

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

r"""Pour information : installation avec unopkg.exe pour tous les utilisateurs (argument --shared) inopérante (avec LO 25.8.6)
    -> utiliser unopkg.exe pour chaque utilisateur via fonction session_setup() """


source_dir=makepath('C:','cachefileWAPT','LibreOffice_extensions','Lbo_CartableFantastique_college')

def install():

    #copie du dossier de l'extension en local
    if not isdir(source_dir):
        mkdirs(source_dir)
        print(f"Copie de l'extension Cartable Fantastique dans {source_dir}")
        filecopyto('Lbo_CartableFantastique_college.v5.oxt',source_dir)

    print("Installation terminée avec succès")


def session_setup():

    run(r'"C:\Program Files\LibreOffice\program\unopkg.exe" add --suppress-license "C:\cachefileWAPT\LibreOffice_extensions\Lbo_CartableFantastique_college\Lbo_CartableFantastique_college.v5.oxt"')

def session_cleanup():

    r"""Désinstallation de l'extension dans les profils utilisateurs
        Attention, pour obtenir l'id de désinstallation de l'extension utiliser unopkg.com list et non unopkg.exe list qui ne renvoie rien"""

    if installed_softwares('LibreOffice'):

        run_notfatal(r'"C:\Program Files\LibreOffice\program\unopkg.exe" remove vnd.cmfpmatik.cartablefantastique')

def uninstall():

    print("Suppression du dossier de l'extension Cartable Fantastique")

    if isdir(source_dir):
        remove_tree(source_dir)
    if dir_is_empty(makepath('C:','cachefileWAPT','LibreOffice_extensions')):
        remove_tree(makepath('C:','cachefileWAPT','LibreOffice_extensions'))

    print("Désinstallation terminée avec succès")
My problem is that the `session_cleanup()` function does not automatically uninstall the extension from user profiles after the Wapt package has been uninstalled. However, when I test the `session_cleanup()` function in PyScripter, `installed_softwares('LibreOffice')` correctly returns a list, and `run_notfatal(r'"C:\Program Files\LibreOffice\program\unopkg.exe" remove vnd.cmfpmatik.cartablefantastique') correctly uninstalls the extension from the profile.

However, if after the wapt package has been uninstalled, for a user I open a command prompt and execute the session_cleanup function:

Code: Select all

U:\>wapt-get session-cleanup col73-libreoffice-extension-cartable-fantastique-college
Using config file: C:\Program Files (x86)\wapt\wapt-get.ini
0

U:\>
It seems to run correctly, but the extension is not uninstalled.

Surprisingly, if I run the session_cleanup function command in a command prompt within the user's session (with user rights, not administrator privileges):

Code: Select all

U:\>"C:\Program Files\LibreOffice\program\unopkg.exe" remove vnd.cmfpmatik.cartablefantastique

U:\>
The extension uninstalls correctly here.

I don't understand where the problem is coming from. Do you have any idea?
WAPT Enterprise 2.6.1.17765
WAPT server under Debian 13
Administration/package creation under Windows 11/10
brice73
Messages: 42
Registration: February 13, 2023 - 8:05 AM

April 14, 2026 - 12:04

I managed to solve the problem. I don't know why, but by replacing the run_notfatal() function with the run() function in the session_cleanup() function, the extension now uninstalls correctly and automatically from user profiles after the wapt package has been uninstalled.

Perhaps there is still something to investigate why the run_notfatal() function does not work while the run() function does work (in session_cleanup). :?:

So, I'm sharing my working package again (a package that has another dependency that installs LibreOffice) in which I've added an auditing function:

Code: Select all

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

r"""Pour information : installation avec unopkg.exe pour tous les utilisateurs (argument --shared) inopérante (avec LO 25.8.6)
    -> utiliser unopkg.exe pour chaque utilisateur via fonction session_setup() """


source_dir=makepath('C:','cachefileWAPT','LibreOffice_extensions','Lbo_CartableFantastique_college')

def install():

    #copie du dossier de l'extension en local
    if not isdir(source_dir):
        mkdirs(source_dir)

    print(f"Copie de l'extension Cartable Fantastique dans {source_dir}")
    filecopyto('Lbo_CartableFantastique_college.v5.oxt',source_dir)

    print("Installation terminée avec succès")

def audit():

    if not isfile(r'C:\cachefileWAPT\LibreOffice_extensions\Lbo_CartableFantastique_college\Lbo_CartableFantastique_college.v5.oxt'):
        print("Attention, l'extension Cartable Fantastique n'est pas présente sur le poste, elle ne pourra pas s'installer pour les prochains utilisateurs. Veuillez réinstaller le paquet")
        return("ERROR")
    else:
        return("OK")

def session_setup():

    run(r'"C:\Program Files\LibreOffice\program\unopkg.exe" add --suppress-license "C:\cachefileWAPT\LibreOffice_extensions\Lbo_CartableFantastique_college\Lbo_CartableFantastique_college.v5.oxt"')

def session_cleanup():

    r"""Désinstallation de l'extension dans les profils utilisateurs
        Attention, pour obtenir l'id de désinstallation de l'extension utiliser unopkg.com list et non unopkg.exe list qui ne renvoie rien"""

    if installed_softwares('LibreOffice'):

        run(r'"C:\Program Files\LibreOffice\program\unopkg.exe" remove vnd.cmfpmatik.cartablefantastique')

def uninstall():

    print("Suppression du dossier de l'extension Cartable Fantastique")

    if isdir(source_dir):
        remove_tree(source_dir)
    if dir_is_empty(makepath('C:','cachefileWAPT','LibreOffice_extensions')):
        remove_tree(makepath('C:','cachefileWAPT','LibreOffice_extensions'))

    print("Désinstallation terminée avec succès")
You can mark the thread as resolved.
Last edited by brice73 on Apr 14, 2026 - 4:58 PM, edited 1 time.
WAPT Enterprise 2.6.1.17765
WAPT server under Debian 13
Administration/package creation under Windows 11/10
User avatar
dcardon
WAPT Expert
Messages: 1929
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

April 14, 2026 - 1:12 PM

Hi Brice,

normally this shouldn't have any impact... For your test, are you sure the package number was correctly incremented and that the local waptservice database was properly updated with the last uninstall command?

Since the package is no longer present when session_cleanup is launched, its code is kept in the local database to run in user sessions. It is updated when the package is updated on the machine.

Could you please try switching back to run_not_fatal() and correctly incrementing the package version, then running an install/uninstall again?

Regards,

Denis
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
brice73
Messages: 42
Registration: February 13, 2023 - 8:05 AM

April 14, 2026 - 5:05 PM

Hello Denis,

I had indeed made sure that the wapt package was incremented, installed (and the extension was checked for different users), and then uninstalled, before verifying that the extension was properly uninstalled for the users.

I tried again with `run_notfatal` instead of `run` in `session_cleanup` and indeed, it also works with `run_notfatal`, so I don't really have any idea why there seemed to be a problem! Perhaps the `session_cleanup` function that was executed was actually the one from the previous package (which was incorrect) and not the one from the last one installed...?!

In any case, there doesn't seem to be any difference between `run` and `run_notfatal`.

Best regards,

Brice
WAPT Enterprise 2.6.1.17765
WAPT server under Debian 13
Administration/package creation under Windows 11/10
lfkl
Messages: 23
Registration: Apr 11, 2019 - 05:51

April 16, 2026 - 09:21

Thank you for sharing this package; we were sorely lacking it here, and I had struggled to find one myself...

Would it be possible to integrate it into the Wapt Store if the author agrees?

Best regards.
brice73
Messages: 42
Registration: February 13, 2023 - 8:05 AM

April 16, 2026 - 2:19 PM

Hello lfkl,

I'm glad to hear that this package is useful to you. :) It also gave me a lot of trouble, with seemingly ineffective commands, a seemingly malfunctioning installation for all users (--shared) (the extension was detected and installed but malfunctioned), and incomplete documentation! The only installation I found to work was the one performed within each user profile.

I would be very grateful if Tranquil IT would like to add this package to the store, certainly after verification and possible modifications/adaptations. :?:

Sincerely
WAPT Enterprise 2.6.1.17765
WAPT server under Debian 13
Administration/package creation under Windows 11/10
User avatar
dcardon
WAPT Expert
Messages: 1929
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

April 16, 2026 - 3:29 PM

Hi Brice,

I'm forwarding this post to the support team that manages the store.

Thanks for the feedback. :-)

I'm marking the topic as resolved.

Denis
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
Locked