[SOLVED] Handling return code for uninstall

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
Thierry Rapp
Messages: 8
Registration: Apr 04, 2023 - 08:03

June 8, 2023 - 09:45

Hello,
I have a piece of software that installs correctly and enters the silent uninstallation key, but the return code is not 0.
What are the best practices for this type of problem?

Thank you in advance,
Thierry Rapp
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

June 8, 2023 - 10:15

Good morning

In this case, I advise you to clear uninstallkey after the installation:

SO :

Code: Select all

uninstallkey = []
This way wapt will forget the key

then create an uninstall function:

Code: Select all

def uninstall():
    run('uninstall.exe',accept_returncodes=2)
Thierry Rapp
Messages: 8
Registration: Apr 04, 2023 - 08:03

June 8, 2023 - 10:50

I tested it:

The Uninstall method executed directly works
The remove me method returns another error

Code: Select all

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

app_uninstall_key = '{7261A53C-9352-45D1-8DE0-B326E177CA84}'

def install():
    # Declaring local variables
    fichier_lic=makepath('c:','ProgramData','itech','CESAR-LCPC','6.3','CDs')
    fichier_nethasp=makepath('c:','CESAR-LCPCv2022.0','bin')
    rep_syswow=makepath('c:','Windows','SysWOW64')
    # Installing the software
    print("Installing: CESAR-LCPCv2022.0.2.exe")
    install_exe_if_needed('CESAR-LCPCv2022.0.2.exe',
        silentflags='/b0 /q2',
        key=app_uninstall_key,
        min_version='2022.0',
        timeout=600,
        accept_returncodes=[0,12]
    )
 
    if not isdir(fichier_lic):
        mkdirs(fichier_lic)
    filecopyto('CESAR-LCPC_V6.3.ilicx',fichier_lic)
    filecopyto('nethasp.ini',fichier_nethasp)
    filecopyto('nethasp.ini',rep_syswow)
    uninstallkey =[]


def uninstall():
    uninstCMD = uninstall_cmd(app_uninstall_key)
    print(uninstCMD)
    run(uninstCMD,accept_returncodes=[0,12])
    wait_uninstallkey_present()



User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

June 8, 2023 - 12:08

Can you provide the error message?


I have a doubt about something...

Can you declare uninstallkey right before setup.py?

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *
uninstallkey =[]
app_uninstall_key = '{7261A53C-9352-45D1-8DE0-B326E177CA84}'

def install():
    # Declaring local variables
    fichier_lic=makepath('c:','ProgramData','itech','CESAR-LCPC','6.3','CDs')
    fichier_nethasp=makepath('c:','CESAR-LCPCv2022.0','bin')
    rep_syswow=makepath('c:','Windows','SysWOW64')
    # Installing the software
    print("Installing: CESAR-LCPCv2022.0.2.exe")
    install_exe_if_needed('CESAR-LCPCv2022.0.2.exe',
        silentflags='/b0 /q2',
        key=app_uninstall_key,
        min_version='2022.0',
        timeout=600,
        accept_returncodes=[0,12]
    )
 
    if not isdir(fichier_lic):
        mkdirs(fichier_lic)
    filecopyto('CESAR-LCPC_V6.3.ilicx',fichier_lic)
    filecopyto('nethasp.ini',fichier_nethasp)
    filecopyto('nethasp.ini',rep_syswow)
    uninstallkey =[]


def uninstall():
    uninstCMD = uninstall_cmd(app_uninstall_key)
    print(uninstCMD)
    run(uninstCMD,accept_returncodes=[0,12])
    wait_uninstallkey_present()

I don't think that's it, but... if uninstallkey is empty, then wapt no longer has a key to test. If it continues to give errors, it means the key is still there
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

June 8, 2023 - 12:18

Oh yes, be careful when you're doing your tests; you absolutely must reinstall the program before testing a remove command, otherwise it won't work because the code isn't in the database! That might be the simple reason
Thierry Rapp
Messages: 8
Registration: Apr 04, 2023 - 08:03

June 9, 2023 - 07:42

Code: Select all

Removing C:\waptdev\insastg-cesar_2022.0.2-2_windows_PROD ...
2023-06-09 07:39:07,072 CRITICAL Critical error during uninstall: CalledProcessErrorOutput: Command 'C:\\PROGRA~3\\UNINST~1\\{7261A~1\\Setup.exe /remove /q' returned non-zero exit status 12.
Output:
No package removed !
FATAL ERROR : TypeError: not all arguments converted during string formatting
Thierry Rapp
Messages: 8
Registration: Apr 04, 2023 - 08:03

June 9, 2023 - 07:46

I'm restarting the installation.

The program is uninstalled correctly; it's just triggering an exception.
Thierry Rapp
Messages: 8
Registration: Apr 04, 2023 - 08:03

June 9, 2023 - 08:43

Code: Select all

Une exception s'est produite : SystemExit       (note: full exception trace is shown but execution is paused at: _run_module_as_main)
3
  File "C:\Program Files (x86)\wapt\wapt-get.py", line 817, in main
    print("=== Error removing packages ===\n%s" % "\n".join(["  %s" % p for p in errors]))
  File "C:\Program Files (x86)\wapt\wapt-get.py", line 817, in <listcomp>
    print("=== Error removing packages ===\n%s" % "\n".join(["  %s" % p for p in errors]))
TypeError: not all arguments converted during string formatting

During handling of the above exception, another exception occurred:

  File "C:\Program Files (x86)\wapt\wapt-get.py", line 1651, in main
    sys.exit(3)
  File "C:\Program Files (x86)\wapt\wapt-get.py", line 1677, in <module>
    main()
  File "C:\Program Files (x86)\wapt\Lib\site-packages\runpy.py", line 87, in _run_code
  File "C:\Program Files (x86)\wapt\Lib\site-packages\runpy.py", line 194, in _run_module_as_main (Current frame)
SystemExit: 3
User avatar
dcardon
WAPT Expert
Messages: 1931
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

June 13, 2023 - 12:48

Thierry Rapp wrote: June 9, 2023 - 08:43

Code: Select all

Une exception s'est produite : SystemExit       (note: full exception trace is shown but execution is paused at: _run_module_as_main)
3
  File "C:\Program Files (x86)\wapt\wapt-get.py", line 817, in main
    print("=== Error removing packages ===\n%s" % "\n".join(["  %s" % p for p in errors]))
  File "C:\Program Files (x86)\wapt\wapt-get.py", line 817, in <listcomp>
    print("=== Error removing packages ===\n%s" % "\n".join(["  %s" % p for p in errors]))
TypeError: not all arguments converted during string formatting

During handling of the above exception, another exception occurred:

  File "C:\Program Files (x86)\wapt\wapt-get.py", line 1651, in main
    sys.exit(3)
  File "C:\Program Files (x86)\wapt\wapt-get.py", line 1677, in <module>
    main()
  File "C:\Program Files (x86)\wapt\Lib\site-packages\runpy.py", line 87, in _run_code
  File "C:\Program Files (x86)\wapt\Lib\site-packages\runpy.py", line 194, in _run_module_as_main (Current frame)
SystemExit: 3
Thank you for your feedback Thierry, we have made a fix for the exception message, it will be included in the next release 2.4.
I'm marking the topic as [RESOLVED].

Sincerely,

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