Page 1 of 1

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

Published: April 14, 2026 - 10:41 AM
by brice73
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?

Re: session_cleanup function not working for the LibreOffice Fantastic Cartable extension

Published: April 14, 2026 - 12:04 PM
by brice73
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.

Re: session_cleanup function not working for the LibreOffice Fantastic Cartable extension

Published: April 14, 2026 - 1:12 PM
by dcardon
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

Re: session_cleanup function not working for the LibreOffice Fantastic Cartable extension

Published: April 14, 2026 - 5:05 PM
by brice73
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

Re: session_cleanup function not working for the LibreOffice Fantastic Cartable extension

Published: April 16, 2026 - 09:21
by lfkl
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.

Re: session_cleanup function not working for the LibreOffice Fantastic Cartable extension

Published: April 16, 2026 - 2:19 PM
by brice73
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

Re: session_cleanup function not working for the LibreOffice Fantastic Cartable extension

Published: April 16, 2026 - 3:29 PM
by dcardon
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