Some more bug fixes.. Server and Client should be finished now! (Save a
few bugs for later) git-svn-id: http://www.neo1973-germany.de/svn@163 46df4e5c-bc4e-4628-a0fc-830ba316316d
This commit is contained in:
parent
8e0227ac88
commit
44271cfda6
4 changed files with 13 additions and 8 deletions
|
@ -84,7 +84,6 @@ class TrackClient:
|
||||||
# set username and password globally in the class
|
# set username and password globally in the class
|
||||||
self.__username = username
|
self.__username = username
|
||||||
self.__pwhash = pwhash
|
self.__pwhash = pwhash
|
||||||
self.SendData(self.__username, self.__pwhash, action="START")
|
|
||||||
|
|
||||||
def SendData(self, username, pwhash, action, data=""):
|
def SendData(self, username, pwhash, action, data=""):
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ from socket import *
|
||||||
from WriteGPX import *
|
from WriteGPX import *
|
||||||
|
|
||||||
class TrackServer:
|
class TrackServer:
|
||||||
def __init__(self, host='localhost', port='49152', hashfile='hashfile', datadir = '.'):
|
def __init__(self, host='', port='49152', hashfile='hashfile', datadir = './'):
|
||||||
self.InitSocker(host, port)
|
self.InitSocket(host, port)
|
||||||
self.InitHashdb(hashfile)
|
self.InitHashdb(hashfile)
|
||||||
self.InitTrackDict()
|
self.InitTrackDict()
|
||||||
self.datadir = datadir
|
self.datadir = datadir
|
||||||
|
@ -31,8 +31,8 @@ class TrackServer:
|
||||||
self.__addr = (str(host),int(port))
|
self.__addr = (str(host),int(port))
|
||||||
|
|
||||||
# Create socket and bind it to the address
|
# Create socket and bind it to the address
|
||||||
self.__UDPSock = socket(AF_INET,SOCK_DGRAM)
|
self.UDPSock = socket(AF_INET,SOCK_DGRAM)
|
||||||
self.__UDPSock.bind(sel.__addr)
|
self.UDPSock.bind(self.__addr)
|
||||||
|
|
||||||
# Debug message:
|
# Debug message:
|
||||||
print "UDP Socket for %s at port %s created" % (host, port)
|
print "UDP Socket for %s at port %s created" % (host, port)
|
||||||
|
@ -66,9 +66,10 @@ class TrackServer:
|
||||||
# if a track has already started it needs to be closed (finished)
|
# if a track has already started it needs to be closed (finished)
|
||||||
if self.TrackDict[username]:
|
if self.TrackDict[username]:
|
||||||
self.TrackDict[username].close()
|
self.TrackDict[username].close()
|
||||||
|
print "Track closed because %s requested a new track" % (username)
|
||||||
# start the new track
|
# start the new track
|
||||||
self.TrackDict[username] = WriteGPX("%s%s%s" % (self.datadir, username, time.strftime("%Y%m%d%H%M%S")))
|
self.TrackDict[username] = WriteGPX("%s%s%s" % (self.datadir, username, time.strftime("%Y%m%d%H%M%S")))
|
||||||
print "Created track", self.TrackDict[username]
|
print "Created track %s%s%s" % (self.datadir, username, time.strftime("%Y%m%d%H%M%S"))
|
||||||
|
|
||||||
def CloseTrack(self, username):
|
def CloseTrack(self, username):
|
||||||
if self.TrackDict[username]:
|
if self.TrackDict[username]:
|
||||||
|
@ -89,6 +90,6 @@ instance = TrackServer()
|
||||||
|
|
||||||
#Receive messages
|
#Receive messages
|
||||||
while 1:
|
while 1:
|
||||||
data,addr = UDPSock.recvfrom(1024)
|
data,addr = instance.UDPSock.recvfrom(1024)
|
||||||
print "Following data received:", data
|
print "Following data received:", data
|
||||||
instance.Parser(data)
|
instance.Parser(data)
|
||||||
|
|
|
@ -32,7 +32,7 @@ class WriteGPX:
|
||||||
self.trackpoint = '<trkpt lat="%s" lon="%s">\n\
|
self.trackpoint = '<trkpt lat="%s" lon="%s">\n\
|
||||||
<ele>%s</ele>\n\
|
<ele>%s</ele>\n\
|
||||||
<time>%s</time>\n\
|
<time>%s</time>\n\
|
||||||
</trkpt>\n' % (lat, lon, ele, time)
|
</trkpt>\n' % (lat, lon, ele, time)
|
||||||
with open(self.filename,'a') as file:
|
with open(self.filename,'a') as file:
|
||||||
file.write(self.trackpoint)
|
file.write(self.trackpoint)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
from PyTrackerClient import *
|
from PyTrackerClient import *
|
||||||
|
import curses
|
||||||
|
|
||||||
test=TrackClient('edistar','refeco3','80.61.221.9')
|
test=TrackClient('edistar','refeco3','80.61.221.9')
|
||||||
|
test.StartTrack()
|
||||||
|
# I need an event to call test.StopTrack!
|
||||||
|
# How do I do that? Best would be KeyPressed("q") or something
|
||||||
ecore.main_loop_begin()
|
ecore.main_loop_begin()
|
||||||
|
|
Loading…
Reference in a new issue