fix a few bugs..
git-svn-id: http://www.neo1973-germany.de/svn@166 46df4e5c-bc4e-4628-a0fc-830ba316316d
This commit is contained in:
parent
e2ba31e402
commit
614de06019
2 changed files with 27 additions and 7 deletions
|
@ -95,11 +95,17 @@ class TrackClient:
|
|||
|
||||
def StartTrack(self):
|
||||
self.SendData(self.__username, self.__pwhash, action="START")
|
||||
|
||||
# call self.UpdatePosition() when a dbus signal "PositionChanged" comes along the system bus
|
||||
if self.terminator:
|
||||
self.terminator.delete()
|
||||
# if an event handler has already been set, delete it!
|
||||
try:
|
||||
if self.terminator:
|
||||
self.terminator.delete()
|
||||
except:
|
||||
pass
|
||||
self.terminator = self.pos_iface.connect_to_signal("PositionChanged", self.UpdateData)
|
||||
|
||||
|
||||
|
||||
def StopTrack(self):
|
||||
self.SendData(self.__username, self.__pwhash, action="STOP")
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ This is a Class to create *.gpx Files
|
|||
Usage:
|
||||
open new file: file = WriteGPX(filename)
|
||||
write trackpint: file.write(lat, lon, alt, utctime)
|
||||
get status: file.GetStatus()
|
||||
close file: file.close()
|
||||
The file musst be closed, otherwise the file will be incomplete
|
||||
'''
|
||||
|
@ -15,6 +16,7 @@ from __future__ import with_statement
|
|||
class WriteGPX:
|
||||
def __init__(self, filename):
|
||||
self.filename = filename
|
||||
self.status = 'started'
|
||||
self.header = '<?xml version="1.0" encoding="UTF-8"?>\n\
|
||||
<gpx version="1.1"\n\
|
||||
creator="WriteGPX - Python Class used in PyTracker.py"\n\
|
||||
|
@ -25,17 +27,29 @@ class WriteGPX:
|
|||
<trkseg>\n'
|
||||
self.footer = '</trkseg>\n</trk>\n</gpx>\n'
|
||||
|
||||
with open(self.filename,'a') as file:
|
||||
with open(self.filename,'w') as file:
|
||||
file.write(self.header)
|
||||
self.status = 'active'
|
||||
print "file started!"
|
||||
|
||||
def write(self, lat, lon, ele, time):
|
||||
self.trackpoint = '<trkpt lat="%s" lon="%s">\n\
|
||||
<ele>%s</ele>\n\
|
||||
<time>%s</time>\n\
|
||||
</trkpt>\n' % (lat, lon, ele, time)
|
||||
with open(self.filename,'a') as file:
|
||||
file.write(self.trackpoint)
|
||||
if self.status != 'closed':
|
||||
with open(self.filename,'a') as file:
|
||||
file.write(self.trackpoint)
|
||||
print "file updated!"
|
||||
|
||||
def close(self):
|
||||
with open(self.filename,'a') as file:
|
||||
file.write(self.footer)
|
||||
if self.status != 'closed':
|
||||
file.write(self.footer)
|
||||
self.status = 'closed'
|
||||
print "file closed successfully"
|
||||
else:
|
||||
print "file closed already!"
|
||||
|
||||
def GetStatus():
|
||||
print self.status
|
||||
|
|
Loading…
Reference in a new issue