×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    21

    How to check pys60's version

    Hi,
    so I just ran into the API change for bluetooth sockets between the older versions and the 1.9.1+ versions.

    I want my application to run under older and newer versions, so I would like to check the pys60 version number.
    I tried sys.version, but that's the python core version (2.5.1).

    Does anyone know what's the right way to check versions and perhaps even the standard check whether the version is higher than a certain number or lower than it?

    thanks!

  2. #2
    Super Contributor
    Join Date
    Feb 2008
    Location
    Belo Horizonte, Brazil
    Posts
    744

    Re: How to check pys60's version

    You can use e32 module:

    Code:
    import e32
    
    print e32.pys60_version

    Hope it helps,

    Rafael.
    Last edited by Rafael T.; 2009-03-10 at 02:50.

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    21

    Re: How to check pys60's version

    Thanks, that did the trick!

    In case it helps others, here's what I did:

    Code:
    from e32 import pys60_version
    if ((pys60_version.split())[0] >= '1.9.1'):
        import btsocket as socket
    else:
       import socket
    I did it for the bluetooth sockets, but you can put any other compatibility issue there...

    Nadav

  4. #4
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: How to check pys60's version

    My way:

    Code:
    import e32
    if float(e32.pys60_version[:3]) >= 1.9:
        import btsocket as socket
    else:
        import socket
    I don´t know if it will be usable/portable for all future version of 1.4.x and 1.9.x but ... I *think* I am prepared !

  5. #5
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,800

    Thumbs up Re: How to check pys60's version

    Quote Originally Posted by marcelobarrosalmeida View Post
    My way:

    Code:
    import e32
    if float(e32.pys60_version[:3]) >= 1.9:
        import btsocket as socket
    else:
        import socket
    I don´t know if it will be usable/portable for all future version of 1.4.x and 1.9.x but ... I *think* I am prepared !
    Good One!
    Pankaj Nathani
    www.croozeus.com

  6. #6
    Super Contributor
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976

    Re: How to check pys60's version

    Quote Originally Posted by marcelobarrosalmeida View Post
    Code:
    import e32
    if float(e32.pys60_version[:3]) >= 1.9:
        import btsocket as socket
    else:
        import socket
    I don´t know if it will be usable/portable for all future version of 1.4.x and 1.9.x but ... I *think* I am prepared !
    Sorry, too little sleep:

    1) Wouldn't simpler & faster text string comparison also work? For example "2.0" is bigger than "1.9" even as text strings?

    2) Would your check fail, when major version gets over 9? "10." is not valid float, is it

    Sleepy,

    --jouni

  7. #7
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: How to check pys60's version


    Yes, JOM is right, again ...
    Thanks to foreseen the mistake.

    But I think both approach have problems, in different situations:

    Code:
    >>> "2.10">"2.4"
    False
    But, I know, if we want just to check 1.x against 2.y, a simple string comparison is enough, as indicated by JOM. This seemed a simple question ...

    In my code (wordmobi), I defined versions like x.y.z, I mean, 3 numbers separated by ".". Each number with one or two digits. And I used this function:

    Code:
    def ver2num(ver):
        a,b,c = map(lambda x,y: x*y, [10000,100,1],[int(v) for v in ver.split(".")])
        return a+b+c
    An integer is returned but it costs a lot to process ...
    Last edited by marcelobarrosalmeida; 2009-03-10 at 23:55.

  8. #8
    Super Contributor
    Join Date
    Feb 2008
    Location
    Belo Horizonte, Brazil
    Posts
    744

    Re: How to check pys60's version

    Another simple way would be removing the dots, so 1.9.1 would be 191, for example.

    Code:
    ver = e32.pys60_version
    d_ver = int(ver[:6].replace(".", ""))
    
    if d_ver >= 191:
        import btsocket as socket
    
    else:
        import socket
    BR,

    Rafael.

  9. #9
    Nokia Developer Expert
    Join Date
    Apr 2007
    Posts
    131

    Re: How to check pys60's version

    Quote Originally Posted by nadavaha View Post
    Hi,
    so I just ran into the API change for bluetooth sockets between the older versions and the 1.9.1+ versions.

    I want my application to run under older and newer versions, so I would like to check the pys60 version number.
    I tried sys.version, but that's the python core version (2.5.1).

    Does anyone know what's the right way to check versions and perhaps even the standard check whether the version is higher than a certain number or lower than it?

    thanks!
    This should work on both the PyS60 series
    Code:
    try:
        import btsocket as socket
    except:
        import socket
    ====
    Mahesh
    PyS60 Team

  10. #10
    Regular Contributor
    Join Date
    Sep 2005
    Location
    Finland, Helsinki
    Posts
    323

    Re: How to check pys60's version

    Quote Originally Posted by JOM View Post
    1) Wouldn't simpler & faster text string comparison also work? For example "2.0" is bigger than "1.9" even as text strings?

    2) Would your check fail, when major version gets over 9? "10." is not valid float, is it
    Tested in Python 2.5 shell, but should work in PyS60 too:
    Code:
    >>> [int(x) for x in "1.9.2 final".split(" ")[0].split(".")] > [1,4,5]
    True
    The idea is to create a list of integers from this version string, e.g. "1.9.2 final" -> [1,9,2].

    1. split "1.9.2 final" -> ["1.9.2", "final"]
    2. split "1.9.2" -> ["1", "9", "2"]
    3. cast integers in string format in the list to integers using list comprehension
    4. finally compare two lists of integers which is okay in python :-)
    --
    Aapo Rista
    http://code.google.com/p/pys60gps/
    http://opennetmap.org/

  11. #11
    Super Contributor
    Join Date
    Nov 2007
    Location
    Sertaozinho/Brazil
    Posts
    768

    Re: How to check pys60's version

    Quote Originally Posted by mahesh.sayibabu View Post
    This should work on both the PyS60 series
    Code:
    try:
        import btsocket as socket
    except:
        import socket
    ====
    Mahesh
    PyS60 Team
    Perfect. I will take this solution.

Similar Threads

  1. Symbian OS version 9.3
    By ash_leo in forum Symbian
    Replies: 14
    Last Post: 2009-01-21, 09:56
  2. Problem with update app
    By Scolpy in forum Symbian
    Replies: 17
    Last Post: 2008-11-15, 21:14
  3. S60 2nd to 3rd/ PlatformSecurity / Capabilities
    By jarkoos in forum Symbian Signed Support, Application Packaging and Distribution and Security
    Replies: 4
    Last Post: 2007-04-14, 14:08
  4. Replies: 7
    Last Post: 2006-09-01, 09:30
  5. SMS Msg using VB Application
    By gurup83 in forum General Messaging
    Replies: 2
    Last Post: 2002-07-11, 04:48

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×