| Reply | « Previous Thread | Next Thread » |
|
hi,
help, I have a problem, I have an application that uses a two-class that reads data from GPS and another that creates a database using the module e32dbm, the idea is to read GPS data and store them in the database, when I run the application in Emulator works fine, but when I run into the N95 does not create a database on the specified drive Code:
import positioning
import socket
import appuifw
import time
import e32
import thread
import sysinfo
class LocationEngine:
def __init__(self):
self._tracking = True
self.r = None
self.year = None
self.month = None
self.date = None
self.hour = None
self.imei = sysinfo.imei()
self.service = True
self.conn = True
self.app_lock = e32.Ao_lock()
self.lock = thread.allocate_lock()
self.db = StorageData()
def startTracking(self):
positioning.set_requestors([{"type":"service", "format":"application","data":"WifeTracker"}])
positioning.position(course=1,satellites=1, callback = self.locationCallback)
def pruebaThread(self):
self.startTracking()
def DateandTime(self):
self.year = str(time.localtime()[0])[2:4]
self.month = time.localtime()[1]
self.date = time.localtime()[2]
self.hour = time.localtime()[3]
m = str(time.localtime()[4])
if(len(m) == 1):
minutes = "0"+m
else:
minutes = m
s = str(time.localtime()[5])
if(len(s) == 1):
self.seconds = "0"+s
else:
self.seconds = s
dates = self.year+str(self.month)+str(self.date)+str(self.hour)+str(minutes)+str(self.seconds)
return dates
def locationCallback(self,event):
lock = thread.allocate_lock()
lock.acquire()
e32.ao_sleep(1)
position = event['position']
course = event['course']
satellites=event['satellites']
posTuple = (position['latitude'], position['longitude'],position['altitude'])
velocidad = course['speed']
rumbo = course['heading']
date = satellites['time']
la,lo,al = posTuple
lat = '>R4'+','+self.DateandTime()+','+str("%.5f"%la)+','+str("%.5f"%lo)+','+str("%.5f"%velocidad)+','+str("%.5f"%rumbo)+','+self.imei+'<'
lock.release()
e32.ao_sleep(5)
y = lat.encode('UTF-8')
####Here stores data in the database
self.db.write_db(y)
#print lat
#self.db.write_db(y)
import e32dbm
DB_FILE=u"c:\\mydatabase.db"
class StorageData:
def write_db(self,a):
d = e32dbm.open(DB_FILE,"cf")
d[u"datas"] = a
loc = LocationEngine()
loc.pruebaThread()
|
|
Quote:
Mikko Ohtamaa Twinapex Research http://www.twinapex.com |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| [anounce] Tracker.py GPS mapping application | hurenkam | Python | 85 | 2009-05-13 11:38 |