Page 1 of 1

Is it possible to ignore version errors?

Published: July 11, 2018 - 09:53
by Eric
Hello,

I'm using WAPT 1.5 Community.

I have a package that installs an application from an MSI using `install_msi_if_needed`.
It always throws an error in WAPT with the message: "has been installed and the uninstall key found, but version is not good".
Despite various attempts, I haven't been able to fix this error. Ultimately, it doesn't matter much to me, as the software is installed correctly and works properly. However, since another package depends on it, this error prevents the installation of that other package.
Is it possible to tell WAPT, in some way, to ignore this error?
I'm already familiar with the `accept_returncodes` parameter, but in this case, it doesn't seem to be applicable.

for your help.
advance

Re: Is it possible to ignore version errors?

Published: July 11, 2018 - 10:23
by Eric
Just to clarify:

The version number in my config file is exactly the same as the one returned by the command
`get-itemproperty HKLM:\software\wow6432node\microsoft\currentversion\uninstall\uninstall\* | select-object displayname, displayversion`

Re: Is it possible to ignore version errors?

Published: July 11, 2018 - 11:08 AM
by htouvet
I suspect that one of the versions is on 3 components "1.2.3" and the other on 4 "1.2.3.0"?

You can force the version in the install_msi_if_needed function with the parameter:
get_version: provide a function that returns the currently installed version

Code: Select all

def my_get_version(soft):
    print(u'Version installée: %s' % soft['version'])
    return soft['version']

def install():
    install_msi_if_needed('setup.msi',get_version=my_get_version)

Re: Is it possible to ignore version errors?

Published: July 11, 2018 - 2:47 PM
by Eric
htouvet wrote: I suspect that one of the versions is on 3 components "1.2.3" and the other on 4 "1.2.3.0"?
Since the PowerShell command returns exactly the version number I'm using in my control file, I thought not, but I admit I don't know all the intricacies of the Windows world; MSI and such. :(

htouvet wrote:

Code: Select all

def my_get_version(soft):
    print(u'Version installée: %s' % soft['version'])
    return soft['version']
What should I send to this function? (Is the 'soft' variable the software name, its key, the location of the executable after installation...?)

THANKS
AND.

Re: Is it possible to ignore version errors?

Published: July 17, 2018 - 2:05 PM
by Eric
Good morning,

I found a function in the setuphelpers that seemed to answer my question:
get_msi_properties.
So, things became simple:

Code: Select all

def install():
	print ('Installing sentinelRuntime')
	soft = get_msi_properties("Sentinel Runtime.msi")
	install_msi_if_needed('Sentinel Runtime.msi', '/q /norestart', get_version=soft['Version'])
Except now, I'm allowed one error:
Installing Sentinel Runtime
TypeError: 'unicode object is not callable'

And here, I confess, I'm starting to crack a little...

A quick tip for those who haven't thought of it yet for testing setuphelpers in the console:
In a Python console, a simple "import setuphelpers" command works. This saves time when testing your code. ;-)
I know, it's silly, but sometimes we don't think about the simple things and we waste a lot of time...

Re: Is it possible to ignore version errors?

Published: July 18, 2018 - 12:22 PM
by Eric
Good morning,

After multiple tests, errors, corrections... this is where I am.

Code: Select all

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

uninstallkey = []

def get_sentinel_version(soft="Sentinel Runtime.msi"):
    sentiProps = get_msi_properties(soft)
    sentiVers = str(sentiProps['Version'])
    #print('Type de sentiVers : ' type(sentivers))
    return sentiVers

def install():
    print('installing unilim-sentinelRuntime')
    install_msi_if_needed('Sentinel Runtime.msi', '/q /norestart', get_version=get_sentinel_version)
In my previous code, I had an error because get_version was expecting a "callable object" and not a "string", hence the function (I hadn't understood why it was there before).
Now, I'm allowed to make a mistake:
TypeError: MSIOpenDatabase() argument 1 must be string, not dict
I tried using the str() function in my function to fix it, but it didn't work.

I keep sending messages in bottles, hoping that one day, one of them will inspire someone. ;-)

AND.

Re: Is it possible to ignore version errors?

Published: July 18, 2018 - 10:56 PM
by sfonteneau
In your case, the test is not good.

The aim of this maneuver is to tell wapt not to look for the software version in the software's uninstallkey but elsewhere.

get_version is used to tell wapt the version number of the software.

Example using the Naps software:

Code: Select all

       def versnaps2(key):
                return key['name'].replace('NAPS2 ','')

        install_exe_if_needed('naps2-5.3.3-setup.exe',silentflags='/VERYSILENT',key='NAPS2 (Not Another PDF Scanner 2)_is1',get_version=versnaps2)
        
Wapt is instructed to retrieve the version from the software name.

In your code, you are going to retrieve the version number from the msi file which is in the package, this does not make sense.

To resolve your issue, you can also simply modify the min_version by calling install_msi_if... rather than using get_version.

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

Re: Is it possible to ignore version errors?

Published: July 21, 2018 - 10:45 AM
by Eric
Hello,

thank you for your reply.
Actually, I decided to start from scratch, and I no longer have the version conflict problem. It's quite strange; the only difference from my original script is that I didn't specify `silent_options` in the parameters (in fact, `/q` and `/norestart` are already set by default in `install_msi_if_needed`, I noticed this in the code), and so it works.
I can't explain why...

Because of this problem, I lost quite a bit of time, but I gained a lot of knowledge about how WAPT works, through my tests and your replies, which will be very useful to me later.

you.
Thank