need_install() got an unexpected keyword argument 'force'

Questions about WAPT Server / Requests and help related to the WAPT server
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
Floflobel
Messages: 135
Registration: Oct 15, 2015 - 5:32 p.m.

May 17, 2016 - 4:32 PM

Good morning,

I modified all my packages to improve them and I'm encountering this error on quite a few machines:

Code: Select all

need_install() got an unexpected keyword argument 'force'
I saw on another thread that a patch was available on the git repository. But I confess I didn't understand how to patch it.
I've replaced the correct lines. But do I need to recompile the project? And send the file to all the machines?

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

May 17, 2016 - 11:09 PM

I don't think the patch fixes this at first glance.

Could you see the package structure to understand the problem?

Also, what version of the WAPT client is it?

If it's a problem with the new `install_exe_if_needed` and `install_msi_if_needed` functions,
it would mean, if I understand correctly, that the `force` argument provided to the `need_install` command is being misinterpreted:

https://github.com/tranquilit/WAPT/blob ... s.py#L3407

Simon
Floflobel
Messages: 135
Registration: Oct 15, 2015 - 5:32 p.m.

May 18, 2016 - 10:24

Good morning,

The various clients experiencing this problem are on version 1.3.5.0. If this is not the case, I force the update.
Here is one of the packages with the error:

Code: Select all

# -*- coding: utf-8 -*-
import urllib

from setuphelpers import *

uninstallkey = []

# Name of the software
namesoftware='soft'

# Uninstall register key
# For OS 64bits and Software 32bits version : HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\
# For OS 32 bits or 64bits (and Software 64bits version) : HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\
ukey='{00000000000000}'

# Version of software
version='3.19'

# Unzip folder define in Winrar
foldertmp='C:\Temp'

# Name of execute file
execfile='soft.exe'

# Insert the silent parameters
silentparameters='/install /silent /norestart'

# Link to download the software
downloadlink='http://repo/exe/soft.exe'

# Name of installation files
downloadfilename='soft.exe'


def install():
    print(foldertmp + '\\' + execfile)
    if need_install(ukey,min_version=version,force=False):
        if isfile(foldertmp + '\\' + execfile):
            print('Installation files are already present - Installing ' + namesoftware)
            install_exe_if_needed(foldertmp + '\\' + execfile, silentflags=silentparameters, key=ukey, min_version=version, accept_returncodes=[0], timeout=600)
            #remove_tree(foldertmp)
        else:
            print('Download and unzip ' + namesoftware)
            os.mkdir(foldertmp)
            urllib.urlretrieve (downloadlink, foldertmp + '\\' + execfile)
			#wget(downloadlink,downloadfilename)
            #run(downloadfilename)
            print('Installing ' + namesoftware)
            install_exe_if_needed(foldertmp + '\\' + execfile, silentflags=silentparameters, key=ukey, min_version=version, accept_returncodes=[0], timeout=600)
            #remove_tree(foldertmp)
    else:
        print('The software is already installed in this version or newer version')
Error: TypeError: need_install() got an unexpected keyword argument 'force'

I replaced the name and the ukey because it's proprietary software. But the error persists on several packages.
I use install_exe_if_needed & install_msi_if_needed.
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

May 18, 2016 - 11:12

I don't know if this will solve your problem, but I would do it more like this:

Code: Select all

    
    import inspect
    caller_globals = inspect.stack()[1][0].f_globals
    WAPT = caller_globals.get('WAPT',None)
    force = WAPT and WAPT.options.force
    if need_install(ukey,min_version=version,force=force):
This allows the --force option to work for your package (I'm using the setuphelper example again) here:
https://github.com/tranquilit/WAPT/blob ... s.py#L3351

Simon
Floflobel
Messages: 135
Registration: Oct 15, 2015 - 5:32 p.m.

May 18, 2016 - 11:44

Code: Select all

install_exe_if_needed(foldertmp + '\\' + execfile, silentflags=silentparameters, key=ukey, min_version=version, accept_returncodes=[0], timeout=600, force=force)
So I just add force=force? And I don't change anything else?
Or should I use need_install?

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

May 18, 2016 - 12:03

More like this:

Code: Select all

# -*- coding: utf-8 -*-
import urllib

from setuphelpers import *

uninstallkey = []

# Name of the software
namesoftware='soft'

# Uninstall register key
# For OS 64bits and Software 32bits version : HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\
# For OS 32 bits or 64bits (and Software 64bits version) : HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\
ukey='{00000000000000}'

# Version of software
version='3.19'

# Unzip folder define in Winrar
foldertmp='C:\Temp'

# Name of execute file
execfile='soft.exe'

# Insert the silent parameters
silentparameters='/install /silent /norestart'

# Link to download the software
downloadlink='http://repo/exe/soft.exe'

# Name of installation files
downloadfilename='soft.exe'


def install():
    print(foldertmp + '\\' + execfile)
    import inspect
    caller_globals = inspect.stack()[1][0].f_globals
    WAPT = caller_globals.get('WAPT',None)
    force = WAPT and WAPT.options.force
    if need_install(ukey,min_version=version,force=force):
        if isfile(foldertmp + '\\' + execfile):
            print('Installation files are already present - Installing ' + namesoftware)
            install_exe_if_needed(foldertmp + '\\' + execfile, silentflags=silentparameters, key=ukey, min_version=version, accept_returncodes=[0], timeout=600)
            #remove_tree(foldertmp)
        else:
            print('Download and unzip ' + namesoftware)
            os.mkdir(foldertmp)
            urllib.urlretrieve (downloadlink, foldertmp + '\\' + execfile)
         #wget(downloadlink,downloadfilename)
            #run(downloadfilename)
            print('Installing ' + namesoftware)
            install_exe_if_needed(foldertmp + '\\' + execfile, silentflags=silentparameters, key=ukey, min_version=version, accept_returncodes=[0], timeout=600)
            #remove_tree(foldertmp)
    else:
        print('The software is already installed in this version or newer version')
I have serious doubts that this is it, but anyway...
Floflobel
Messages: 135
Registration: Oct 15, 2015 - 5:32 p.m.

May 18, 2016 - 12:26

I just ran the test and nothing changed with these extra lines.
I'm afraid we'll have to wait for someone from the development team to get back to us.

Anyway, thanks for your help.
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

May 18, 2016 - 1:14 PM

Hmm, yes, sorry, I don't see the problem. :?

Does it happen on all of them?

Was it installed via the service or command line?
Floflobel
Messages: 135
Registration: Oct 15, 2015 - 5:32 p.m.

May 18, 2016 - 4:13 PM

This happens randomly... on packages with the same structure.
Not all machines are affected, but it's likely to happen gradually.

Installation is via WAPT-EXIT, so thanks to the agent.

Do you know how I can contact a developer?
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

May 18, 2016 - 5:07 PM

They usually post here regularly or on the mailing list.
Otherwise, you can submit a support ticket directly to them.

I think I understand your problem.

The error message says that the `need_install` function doesn't understand why you're passing it the `force` parameter.

I'm almost certain your client is version 1.2.3.3 (or lower).

Here's the `need_install` function in version 1.2.3.3:
https://github.com/tranquilit/WAPT/blob ... s.py#L3002

And in the latest version:
https://github.com/tranquilit/WAPT/blob ... s.py#L3116

You should check on the WAPT client (on the machine that isn't working) if the `need_install` function in the setuphelper looks like what I sent you above.

Sometimes WAPT client updates don't work properly; the package appears as installed, but the WAPT client isn't the latest version.

Let me know, but I'm almost certain that's the issue.

Simon
Locked