Page 1 of 1

[SOLVED] Handling return code for uninstall

Published: June 8, 2023 - 9:45 AM
by Thierry Rapp
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

Re: Handling return code for uninstall

Published: June 8, 2023 - 10:15 AM
by sfonteneau
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)

Re: Handling return code for uninstall

Published: June 8, 2023 - 10:50 AM
by Thierry Rapp
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()




Re: Handling return code for uninstall

Published: June 8, 2023 - 12:08 PM
by sfonteneau
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

Re: Handling return code for uninstall

Published: June 8, 2023 - 12:18
by sfonteneau
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

Re: Handling return code for uninstall

Published: June 9, 2023 - 7:42 AM
by Thierry Rapp

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

Re: Handling return code for uninstall

Published: June 9, 2023 - 7:46 AM
by Thierry Rapp
I'm restarting the installation.

The program is uninstalled correctly; it's just triggering an exception.

Re: Handling return code for uninstall

Published: June 9, 2023 - 8:43 AM
by Thierry Rapp

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

Re: Handling return code for uninstall

Published: June 13, 2023 - 12:48
by dcardon
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