You Are Here:

Community: Developer Discussion Boards

#1 Old How to check pys60's version - 2009-03-10, 02:55

Join Date: Sep 2008
Posts: 21
nadavaha
Offline
Registered User
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!
Reply With Quote

#2 Old Re: How to check pys60's version - 2009-03-10, 03:16

Join Date: Feb 2008
Posts: 743
Location: Belo Horizonte, Brazil
Send a message via Skype™ to Rafael T.
Rafael T.'s Avatar
Rafael T.
Offline
Forum Nokia Champion
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 03:50.
Reply With Quote

#3 Old Re: How to check pys60's version - 2009-03-10, 03:43

Join Date: Sep 2008
Posts: 21
nadavaha
Offline
Registered User
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
Reply With Quote

#4 Old Re: How to check pys60's version - 2009-03-10, 12:41

Join Date: Nov 2007
Posts: 318
Location: Sertaozinho/Brazil
Send a message via MSN to marcelobarrosalmeida Send a message via Skype™ to marcelobarrosalmeida
marcelobarrosalmeida's Avatar
marcelobarrosalmeida
Offline
Forum Nokia Champion
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 !


Marcelo Barros
Nokia E71, N800, N95 and XM 5800
http://www.croozeus.com
http://wordmobi.wordpress.com
http://jedizone.wordpress.com
Reply With Quote

#5 Old Thumbs up Re: How to check pys60's version - 2009-03-10, 13:18

Join Date: May 2007
Posts: 2,738
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Offline
Forum Nokia Champion
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!
Reply With Quote

#6 Old Re: How to check pys60's version - 2009-03-10, 23:24

Join Date: Mar 2003
Posts: 937
Location: Espoo, Finland
JOM's Avatar
JOM
Offline
Forum Nokia Champion
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
Reply With Quote

#7 Old Re: How to check pys60's version - 2009-03-11, 00:12

Join Date: Nov 2007
Posts: 318
Location: Sertaozinho/Brazil
Send a message via MSN to marcelobarrosalmeida Send a message via Skype™ to marcelobarrosalmeida
marcelobarrosalmeida's Avatar
marcelobarrosalmeida
Offline
Forum Nokia Champion

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-11 at 00:55.
Reply With Quote

#8 Old Re: How to check pys60's version - 2009-03-11, 03:17

Join Date: Feb 2008
Posts: 743
Location: Belo Horizonte, Brazil
Send a message via Skype™ to Rafael T.
Rafael T.'s Avatar
Rafael T.
Offline
Forum Nokia Champion
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.
Reply With Quote

#9 Old Re: How to check pys60's version - 2009-03-11, 05:16

Join Date: Apr 2007
Posts: 131
mahesh.sayibabu's Avatar
mahesh.sayibabu
Offline
Regular Contributor
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
Reply With Quote

#10 Old Re: How to check pys60's version - 2009-03-11, 06:31

Join Date: Sep 2005
Posts: 314
Location: Finland, Helsinki
aaaaapo
Offline
Regular Contributor
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/
Reply With Quote

#11 Old Re: How to check pys60's version - 2009-03-11, 11:18

Join Date: Nov 2007
Posts: 318
Location: Sertaozinho/Brazil
Send a message via MSN to marcelobarrosalmeida Send a message via Skype™ to marcelobarrosalmeida
marcelobarrosalmeida's Avatar
marcelobarrosalmeida
Offline
Forum Nokia Champion
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.


Marcelo Barros
Nokia E71, N800, N95 and XM 5800
http://www.croozeus.com
http://wordmobi.wordpress.com
http://jedizone.wordpress.com
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Symbian OS version 9.3 ash_leo General Symbian C++ 14 2009-01-21 10:56
Problem with update app Scolpy Python 17 2008-11-15 22:14
S60 2nd to 3rd/ PlatformSecurity / Capabilities jarkoos Installation, Certification and Security 4 2007-04-14 15:08
A serious problem with 6600- setFullScreenMode and Version of device ? memosen80 Mobile Java General 7 2006-09-01 10:30
SMS Msg using VB Application gurup83 General Messaging 2 2002-07-11 05:48

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia