Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
153 user(s) are online (145 user(s) are browsing Forums)

Members: 3
Guests: 150

Mr_byte, Nuder_Try, Petrol, more...

Support us!

Headlines

 
  Register To Post  

version check and compare from python
Home away from home
Home away from home


See User information
@All
I need to check by c:version from python script, if we had some library equal or lower than version i need. Code should handle all subversions include something like xx.100, etc. I can do it all with some big code by using something like:
version_info os.popen("c:version sys:Libs/mylib.library).read().strip().split()


And then compare first and second part, etc, but that all looks like a bit too much for such simple stuff , so i tried to do something simpler, like:

if ((os.path.exists("Sys:Libs/mylib.library")) and 
    (
os.system("version >NIL: *>NIL: Sys:Libs/mylib.library 1 100) >= 0)):
        print(we have library equal or lower 1.100)
else:
    print("
no library or greater than 1.100")


But this way not work.. Have anyone any idea ?


Edited by kas1e on 2024/11/23 7:55:44
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: version check and compare from python
Just popping in
Just popping in


See User information
Is it something like string vs int, as the splitted part is a string and you test it with an int?

Go to top
Re: version check and compare from python
Home away from home
Home away from home


See User information
Not only that, but yeah, and in my case 100 will be less that 99 because the comparison happens character by character. I can wrote it all correctly, like this:

result os.popen("c:version mylibrary").read().strip().split()
if 
len(result) > 1:
    
v1v2 result[1].split('.'), "1.100".split('.')
    
v1 += ['0'] * (len(v2) - len(v1))
    
v2 += ['0'] * (len(v1) - len(v2))
    if 
all(int(a) <= int(b) for ab in zip(v1v2)):
        print(
"less than 1.100")
    else:
        print(
"higher than 1.100")
else:
    print(
"Failed to get version")


But were hope someone can come with something based on 2-3 strings only, without involving this digital/len comprassion. Something amiga native, etc..


Edited by kas1e on 2024/11/23 7:55:21
Edited by kas1e on 2024/11/23 8:02:32
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: version check and compare from python
Just can't stay away
Just can't stay away


See User information
@kas1e

Hi, never did any python stuf, but I managed to get something:
#
# checkVer.py -- Check version/revision information
#
import os


def ver_rev_at_least
(_n_v_r) :
    
res 0
    version_info 
os.popen("c:version "_n).read().strip().split()
    
ver int(version_info[1].split('.')[0])
    
rev int(version_info[1].split('.')[1])
#    print "%d.%d" % (ver,rev)

    
if (ver _v) or (ver == _v  and  rev >= _r) :
        
res 1
    
if (res == 0) :
        print 
"Requires '%s' V%d.%d or higher" % (_n,_v,_r)

    return 
res


print ver_rev_at_least("SYS:Libs/version.library"5020)


EDIT1: used "#define LIB_IS_AT_LEAST()" as template for python script/function


Edited by jabirulo on 2024/11/23 10:04:11
Edited by jabirulo on 2024/11/23 10:05:34
Edited by jabirulo on 2024/11/23 10:08:58
Edited by jabirulo on 2024/11/23 10:24:05
Edited by jabirulo on 2024/11/23 10:37:53
Edited by jabirulo on 2024/11/23 10:39:59
Edited by jabirulo on 2024/11/23 10:43:09
Go to top
Re: version check and compare from python
Just popping in
Just popping in


See User information
@kas1e

if (int(os.path.exists("Sys:Libs/mylib.library")) and int(os.system("version >NIL: *>NIL: Sys:Libs/mylib.library 1 100")) >= 0)):
        print(
"we have library equal or lower 1.100")
else:
        print(
"no library or greater than 1.100")


What about something like this?

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project