| Reply | « Previous Thread | Next Thread » |
|
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! |
|
Join Date: Feb 2008
Posts: 743
Location: Belo Horizonte, Brazil
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.
|
|
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
Nadav |
|
Join Date: Nov 2007
Posts: 318
Location: Sertaozinho/Brazil
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
Marcelo Barros Nokia E71, N800, N95 and XM 5800 http://www.croozeus.com http://wordmobi.wordpress.com http://jedizone.wordpress.com |
|
Quote:
![]() |
|
Quote:
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 |
|
Join Date: Nov 2007
Posts: 318
Location: Sertaozinho/Brazil
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 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
Last edited by marcelobarrosalmeida : 2009-03-11 at 00:55.
|
|
Join Date: Feb 2008
Posts: 743
Location: Belo Horizonte, Brazil
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
Rafael. |
|
Quote:
Code:
try:
import btsocket as socket
except:
import socket
Mahesh PyS60 Team |
| mahesh.sayibabu |
| View Public Profile |
| Find all posts by mahesh.sayibabu |
|
Quote:
Code:
>>> [int(x) for x in "1.9.2 final".split(" ")[0].split(".")] > [1,4,5]
True
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/ |
|
Join Date: Nov 2007
Posts: 318
Location: Sertaozinho/Brazil
marcelobarrosalmeida
Offline
Forum Nokia Champion
|
|
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 | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| 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 |