FIXED HORRIBLE TABS
git-svn-id: http://www.neo1973-germany.de/svn@161 46df4e5c-bc4e-4628-a0fc-830ba316316d
This commit is contained in:
parent
4792e251c5
commit
b1af915362
1 changed files with 22 additions and 22 deletions
|
@ -4,31 +4,31 @@ from socket import *
|
||||||
from WriteGPX import *
|
from WriteGPX import *
|
||||||
|
|
||||||
class TrackServer:
|
class TrackServer:
|
||||||
def __init__(self, host, port, hashfile, datadir = '.'):
|
def __init__(self, host, port, hashfile, datadir = '.'):
|
||||||
self.InitSocker(host, port)
|
self.InitSocker(host, port)
|
||||||
self.InitHashdb(hashfile)
|
self.InitHashdb(hashfile)
|
||||||
self.InitTrackDict()
|
self.InitTrackDict()
|
||||||
self.datadir = datadir
|
self.datadir = datadir
|
||||||
|
|
||||||
def InitHashdb(self, hashfile):
|
def InitHashdb(self, hashfile):
|
||||||
self.hashdb=[]
|
self.hashdb=[]
|
||||||
with open(hashfile, "r") as file:
|
with open(hashfile, "r") as file:
|
||||||
for line in file:
|
for line in file:
|
||||||
if line:
|
if line:
|
||||||
self.hashdb.append((line.split()[0], \
|
self.hashdb.append((line.split()[0], \
|
||||||
line.split()[1]))
|
line.split()[1]))
|
||||||
|
|
||||||
def InitTrackDict(self):
|
def InitTrackDict(self):
|
||||||
self.TrackDict={}
|
self.TrackDict={}
|
||||||
for data in self.hashdb:
|
for data in self.hashdb:
|
||||||
self.TrackDict[data[0]] = ""
|
self.TrackDict[data[0]] = ""
|
||||||
|
|
||||||
def InitSocket(self, host, port):
|
def InitSocket(self, host, port):
|
||||||
|
|
||||||
# Set the socket parameters
|
# Set the socket parameters
|
||||||
# e.g. host = "localhost"
|
# e.g. host = "localhost"
|
||||||
# e.g. port = 49152
|
# e.g. port = 49152
|
||||||
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)
|
||||||
|
@ -37,17 +37,17 @@ class TrackServer:
|
||||||
# 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)
|
||||||
|
|
||||||
def VerifyUser(self, username, password_hash):
|
def VerifyUser(self, username, password_hash):
|
||||||
for data in self.hashdb:
|
for data in self.hashdb:
|
||||||
if data[0] == username and data[1] == password_hash:
|
if data[0] == username and data[1] == password_hash:
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def Parser(self, stuff):
|
def Parser(self, stuff):
|
||||||
|
|
||||||
# Parses the complete data sent to UDP port
|
# Parses the complete data sent to UDP port
|
||||||
try:
|
try:
|
||||||
username, password_hash, action, data = stuff.split(';')
|
username, password_hash, action, data = stuff.split(';')
|
||||||
|
|
||||||
# Verifies the user and password
|
# Verifies the user and password
|
||||||
|
@ -65,10 +65,10 @@ class TrackServer:
|
||||||
def NewTrack(self, username):
|
def NewTrack(self, username):
|
||||||
# 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()
|
||||||
# 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", self.TrackDict[username]
|
||||||
|
|
||||||
def CloseTrack(self, username):
|
def CloseTrack(self, username):
|
||||||
if self.TrackDict[username]:
|
if self.TrackDict[username]:
|
||||||
|
|
Loading…
Reference in a new issue