×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Super Contributor
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976

    How to identify current PyS60 version

    Need to know whether my script is running under 1.4.5 (or older) or 1.9.0 (or newer). How would I detect this as easily and reliable as possible? Currently using this piece of code found from older DiBo thread, but I recall it might be buggy in case there's ever PyS60 1.9.10?

    Code:
    # Didn't work, some error...
    #if [int(x) for x in e32.pys60_version().split(" ")[0].split(".")] > [1,4,5]
    
    if float(e32.pys60_version[:3]) >= 1.9:
        # PyS60 1.9.x
        sys.path.append('c:\\Data\\Python')
        sys.path.append('e:\\Data\\Python')
    else:
        # PyS60 1.4.5
        sys.path.append('c:\\Python')
        sys.path.append('e:\\Python')
    ...yep, old and new versions are not 100% compatible. Want to use more efficient python 2.5.2 routines, if possible, and rely on work-arounds only as last resource

    Cheers,

    --jouni variating code

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

    Re: How to identify current PyS60 version

    Quote Originally Posted by JOM View Post
    Need to know whether my script is running under 1.4.5 (or older) or 1.9.0 (or newer). How would I detect this as easily and reliable as possible? Currently using this piece of code found from older DiBo thread, but I recall it might be buggy in case there's ever PyS60 1.9.10?

    Code:
    # Didn't work, some error...
    #if [int(x) for x in e32.pys60_version().split(" ")[0].split(".")] > [1,4,5]
    e32.pys60_version is a string, not a function. Remove parenthesis and try again. :-)
    Code:
    >>> [int(x) for x in e32.pys60_version.split(" ")[0].split(".")]
    [1, 4, 5]
    --
    Aapo Rista
    http://code.google.com/p/pys60gps/
    http://opennetmap.org/

  3. #3
    Nokia Developer Moderator
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: How to identify current PyS60 version

    If you just want to know whether the version is 1.9.0 (or greater) or 1.4.5 (or older) without knowing exactly which version, your code should be fine. 1.9.10 will make no difference, since e32.pys60_version[:3] only takes the first 3 characters (in this case "1.9").

    Here's what I came up with (works just like yours, nothing special):
    Code:
    import e32
    
    
    version_number = e32.pys60_version.split(" ")[0]
    
    if version_number >= "1.9.0":
        # PyS60 1.9.x
        print version_number
    else:
        # PyS60 1.4.5
        print version_number

  4. #4
    Wiki Moderators
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,779

    Re: How to identify current PyS60 version

    aaaaapo, you are fast

    e32.pys60_version.split(".")[1]

    Check for 4 or 9
    Pankaj Nathani
    www.croozeus.com

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

    Re: How to identify current PyS60 version

    Quote Originally Posted by croozeus View Post
    e32.pys60_version.split(".")[1]

    Check for 4 or 9
    But what happens when 2.0 is out?

    IMHO, my solution is the best one! :-)
    --
    Aapo Rista
    http://code.google.com/p/pys60gps/
    http://opennetmap.org/

  6. #6
    Wiki Moderators
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,779

    Re: How to identify current PyS60 version

    Quote Originally Posted by aaaaapo View Post
    But what happens when 2.0 is out?
    I believe (and also read somewhere) its going to be 2.0.0 and not 2.0 :-)

    Then we need to check for [0] as well.
    Last edited by croozeus; 2009-05-26 at 14:59.
    Pankaj Nathani
    www.croozeus.com

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

    Re: How to identify current PyS60 version

    Thanx all,

    Will be using this:

    Code:
        if [int(x) for x in e32.pys60_version.split(" ")[0].split(".")] > [1,4,5]:
            # PyS60 1.9.x
            # Complexity O(n) - Python 2.4's key parameter
            my_files.sort(key=str.lower)
        else:
            # PyS60 1.4.5
            # Complexity O(n log n) - custom routine
            my_files.sort(lambda x, y: cmp(x.lower(), y.lower()))
    Cheers,

    --jouni

  8. #8
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    53

    Re: How to identify current PyS60 version

    Is pys60 1.9x compatible with the program based on pys60 1.45 and some modules on it?
    My program is based on pys60 1.45 and some importing modules, I wonder if it works with the new pys60 1.9x platform?

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

    Re: How to identify current PyS60 version

    Quote Originally Posted by forumz View Post
    Is pys60 1.9x compatible with the program based on pys60 1.45 and some modules on it?
    My program is based on pys60 1.45 and some importing modules, I wonder if it works with the new pys60 1.9x platform?
    Yes. It also depends on the 1.4.5 modules you are using. If you are using 1.4.5's 'socket' module, you can import the same with the name 'btsocket'. Similarly, 'calendar' module can be imported with the name 'e32calendar'. On 1.9.x, 'socket' and 'calendar' refers to the Python core modules.

    If you are using any third party extension module that is developed for 1.4.5, then that module cannot be used as is in 1.9.x. The module has to be built again for 1.9.x and instructions for doing this can be found in PyS60_1_9_x_README.txt under the PyS60 1.9.x source zip.

    Packaging the Python script, the only supported tool is PyAP (PyS60 Application Packager) that comes with the 1.9.x release. This uses a modified version of ensymble for packaging purpose.

  10. #10
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    53

    Re: How to identify current PyS60 version

    Quote Originally Posted by mahesh.sayibabu View Post
    Yes. It also depends on the 1.4.5 modules you are using. If you are using 1.4.5's 'socket' module, you can import the same with the name 'btsocket'. Similarly, 'calendar' module can be imported with the name 'e32calendar'. On 1.9.x, 'socket' and 'calendar' refers to the Python core modules.

    If you are using any third party extension module that is developed for 1.4.5, then that module cannot be used as is in 1.9.x. The module has to be built again for 1.9.x and instructions for doing this can be found in PyS60_1_9_x_README.txt under the PyS60 1.9.x source zip.

    Packaging the Python script, the only supported tool is PyAP (PyS60 Application Packager) that comes with the 1.9.x release. This uses a modified version of ensymble for packaging purpose.
    Thanks for your explanation. I am also using third party modules, so that would be a huge work if I want my program running ok on pys60 1.9.x. I'd better stay on 1.4.5 right now.

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

    Re: How to identify current PyS60 version

    Quote Originally Posted by JOM View Post
    Will be using this:
    Code:
        if [int(x) for x in e32.pys60_version.split(" ")[0].split(".")] > [1,4,5]:
            # PyS60 1.9.x
        else:
    We may have 1.4.6 some day. :-)

    How about this:

    Code:
        if [int(x) for x in e32.pys60_version.split(" ")[0].split(".")] > [1,9]:
            # PyS60 1.9.x and above
        else:
            # Pys60 1.4.x or below
    This matches all 1.9.x (including 1.9.0) and 2.0.x series and above.
    --
    Aapo Rista
    http://code.google.com/p/pys60gps/
    http://opennetmap.org/

  12. #12
    Super Contributor
    Join Date
    Dec 2004
    Posts
    643

    Re: How to identify current PyS60 version

    Hey guys, it's easier than you think. Just use the pre-split form of the version: e32.pys60_version_info. Quoting the friendly manual:
    pys60_version_info
    A tuple containing the five components of the Python for S60 version number: major, minor, micro, release tag, and serial. All values except release level are integers; the release tag is a string. A value other than 'final' for the release tag signifies a development release. The pys60_version_info value corresponding to the Python for S60 version 1.9.3 is (1, 9, 3, 'svn2793', 0).

    Example:

    >>> import e32
    >>> e32.pys60_version_info
    (1, 9, 3, 'svn2793', 0)

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

    Re: How to identify current PyS60 version

    Quote Originally Posted by mahesh.sayibabu View Post
    Yes. It also depends on the 1.4.5 modules you are using.
    Another difference is caused by the used python core version: python 2.2.2 vs python 2.5.4. That shouldn't be too much to worry about, should be backwards compatible.

    Quote Originally Posted by mahesh.sayibabu View Post
    Packaging the Python script, the only supported tool is PyAP (PyS60 Application Packager) that comes with the 1.9.x release. This uses a modified version of ensymble for packaging purpose.
    Haven't tried yet, but I do hope command line support still works!

    Cheers,

    --jouni

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

    Re: How to identify current PyS60 version

    Quote Originally Posted by jplauril View Post
    Hey guys, it's easier than you think. Just use the pre-split form of the version: e32.pys60_version_info. - -
    Huh, you're right! e32.pys60_version_info is much easier and cheaper than kludges/workarounds introduced here earlier. ;-0
    --
    Aapo Rista
    http://code.google.com/p/pys60gps/
    http://opennetmap.org/

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

    Re: How to identify current PyS60 version

    Quote Originally Posted by aaaaapo View Post
    Huh, you're right! e32.pys60_version_info is much easier and cheaper than kludges/workarounds introduced here earlier. ;-0
    Well, I knew it was difficult! Otherwise wouldn't have asked

    Howabout this:
    Code:
        if list(e32.pys60_version_info) > [1,9]:
            # PyS60 1.9.x and above
        else:
            # Pys60 1.4.x or below
    Tested in 5800 and N82 using 1.4.5 and 1.9.5, all four cases ok.

    Cheers,

    --jouni

Similar Threads

  1. How can i get the current OS version?
    By JohnsonZ in forum Symbian
    Replies: 12
    Last Post: 2008-06-30, 09:47
  2. Replies: 7
    Last Post: 2006-09-01, 09:30
  3. Replies: 0
    Last Post: 2006-03-06, 11:56
  4. setting of Series 60 MIDP SDK for Symbian OS version 1.2 for networking
    By servigo in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2003-07-31, 07:47

Posting Permissions

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