Skip to content

Commit

Permalink
Merge branch 'master' into Encrypted-Communication-2
Browse files Browse the repository at this point in the history
  • Loading branch information
Scratchcat1 authored Oct 22, 2017
2 parents 5adcfc8 + cb46844 commit dc00cc3
Show file tree
Hide file tree
Showing 6 changed files with 232 additions and 503 deletions.
27 changes: 15 additions & 12 deletions AATC_Client_Text_UI.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,17 +361,14 @@ def GetMonitorPermissionUser(self):
#################################################

def Call_Exit(self):
Choice = input("Exit? (Y/N) >>").upper()
if Choice == "Y":
print("Exiting..")
try:
Sucess,Message = self.UserInterface.Exit()
self.DisplayResults(Sucess,Message)
except:
print("Unable to close server connection")
self.Exit = True
else:
print("Exit cancelled")
print("Exiting..")
try:
Sucess,Message = self.UserInterface.Exit()
self.DisplayResults(Sucess,Message)
except:
print("Unable to close server connection")
self.Exit = True




Expand All @@ -386,7 +383,13 @@ def Call_Exit(self):

TextUI = UserTextUI(U,MenuOptions)
TextUI.Main_Loop()
Exit = True #When user selects exit

Choice = input("Exit? (Y/N) >>").upper()
if Choice == "Y":
print("Exiting")
Exit = True #When user selects exit
else:
print("Exit cancelled")

except Exception as e:
print("Error occured creating user interface",e)
Expand Down
1 change: 1 addition & 0 deletions AATC_Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@
DRONE_BATTERY_DRAIN_MULT = 1



NOFLYZONE_THRESHOLD_COST = 50
2 changes: 2 additions & 0 deletions AATC_Crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def ServerGenerateKey(self):
data = self.Recv()
Command, Arguments = data[0],data[1]


if Command == "GenerateKey":
Sucess,Message,Data = self.ServerGenerateKeys(Arguments)

Expand All @@ -128,6 +129,7 @@ def ServerGenerateKey(self):

elif Command == "SetKey":
Sucess,Message,Data = self.ServerSetKey(Arguments)



elif Command == "Exit":
Expand Down
17 changes: 9 additions & 8 deletions AATC_DB.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def GetFlightsAll(self):
def AddFlight(self,UserID,DroneID,StartCoords,EndCoords,StartTime,ETA,EndTime,Distance,XOffset,YOffset,ZOffset):
self.cur.execute("SELECT 1 FROM User,Drone WHERE Drone.DroneID = %s AND Drone.UserID = %s",(DroneID,UserID))
if self.cur.fetchall() !=():
self.cur.execute("INSERT INTO Flight(DroneID,StartCoords,EndCoords,StartTime,ETA,EndTime,Distance,XOffset,YOffset,ZOffset,Completed) VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,0)",(DroneID,str(StartCoords),str(EndCoords),StartTime,ETA,EndTime,Distance,XOffset,YOffset,ZOffset))
self.cur.execute("INSERT INTO Flight(DroneID,StartCoords,EndCoords,StartTime,ETA,EndTime,Distance,XOffset,YOffset,ZOffset,Completed) VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,0)",(DroneID,str(StartCoords),str(EndCoords),int(StartTime),int(ETA),int(EndTime),Distance,XOffset,YOffset,ZOffset))
self.db_con.commit()
return True,"Flight added"
else:
Expand All @@ -200,7 +200,7 @@ def RemoveFlight(self,UserID,FlightID):

def CheckForFlight(self,DroneID,MaxLookAheadTime):
InvalidateDelay = 1800
self.cur.execute("SELECT FlightID FROM Flight WHERE DroneID = %s AND StartTime < (%s+%s) AND StartTime > (%s-%s) ORDER BY StartTime ASC LIMIT 1",(DroneID,GetTime(),MaxLookAheadTime, GetTime(),InvalidateDelay))
self.cur.execute("SELECT FlightID FROM Flight WHERE DroneID = %s AND StartTime < (%s+%s) AND StartTime > (%s-%s) AND Completed = 0 ORDER BY StartTime ASC LIMIT 1",(DroneID,GetTime(),MaxLookAheadTime, GetTime(),InvalidateDelay))
FlightIDFetch = self.cur.fetchall()
self.db_con.commit()
if FlightIDFetch != ():
Expand All @@ -227,11 +227,11 @@ def MarkFlightComplete(self,DroneID,FlightID,Code):
return False,"You do not have permission to mark this flight complete"

def GetCompletedFlightIDs(self,EndTimeThreshold):
self.cur.execute("SELECT FlightID FROM Flight WHERE Completed > 0 AND (EndTime + %s) > %s",(EndTimeThreshold,GetTime()))
self.cur.execute("SELECT FlightID FROM Flight WHERE (Completed > 0 AND (EndTime + %s) < %s) OR (EndTime+ %s) < %s",(EndTimeThreshold,GetTime(),EndTimeThreshold*3,GetTime()))
return True,"['FlightID']",self.cur.fetchall()

def CleanCompletedFlights(self,EndTimeThreshold):
self.cur.execute("DELETE FROM Flight WHERE Completed > 0 AND (EndTime + %s) > %s",(EndTimeThreshold,GetTime()))
def CleanFlights(self,FlightIDList):
self.cur.executemany("DELETE FROM Flight WHERE FlightID = %s",FlightIDList)
self.db_con.commit()
return True,"Deleted completed flights above threshold"

Expand All @@ -251,7 +251,7 @@ def GetFlightWaypointsAll(self):
def AddWaypoint(self,UserID,FlightID,WaypointNumber,Coords,ETA,BlockTime=0):
self.cur.execute("SELECT 1 FROM User,Flight,Drone WHERE User.UserID = %s AND User.UserID = Drone.UserID AND Drone.DroneID = Flight.DroneID AND Flight.FlightID = %s",(UserID,FlightID))
if self.cur.fetchall() !=():
self.cur.execute("INSERT INTO FlightWaypoints(FlightID,WaypointNumber,Coords,ETA,BlockTime) VALUES(%s,%s,%s,%s,%s)",(FlightID,WaypointNumber,str(Coords),ETA,BlockTime))
self.cur.execute("INSERT INTO FlightWaypoints(FlightID,WaypointNumber,Coords,ETA,BlockTime) VALUES(%s,%s,%s,%s,%s)",(FlightID,WaypointNumber,str(Coords),int(ETA),BlockTime))
self.db_con.commit()
return True,"Added Waypoint"
else:
Expand Down Expand Up @@ -307,11 +307,12 @@ def GetMonitorFlightWaypoints(self,MonitorID):

def GetMonitorID(self,MonitorName):
self.cur.execute("SELECT MonitorID FROM Monitor WHERE MonitorName = %s",(MonitorName,))
if len(self.cur.fetchall()) != 0:
result = self.cur.fetchall()
if len(result) != 0:
Sucess = True
else:
Sucess = False
return Sucess,"['MonitorID']",self.cur.fetchall()
return Sucess,"['MonitorID']",result
def GetMonitorName(self,MonitorID):
self.cur.execute("SELECT MonitorName FROM Monitor WHERE MonitorID = %s",(MonitorID,))
return True,"['MonitorName']",self.cur.fetchall()
Expand Down
Loading

0 comments on commit dc00cc3

Please sign in to comment.