Changeset 809:4da4f80a2ab4
- Timestamp:
- 09/08/16 07:32:45 (8 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/rpc.py
r790 r809 73 73 raise Exception("Invalid aircraft type code: '" + typeCode + "'") 74 74 75 @staticmethod 76 def _decodeStatus(status): 77 """Decode the status from the status string.""" 78 if status=="booked": 79 return BookedFlight.STATUS_BOOKED 80 elif status=="reported": 81 return BookedFlight.STATUS_REPORTED 82 elif status=="accepted": 83 return BookedFlight.STATUS_ACCEPTED 84 elif status=="rejected": 85 return BookedFlight.STATUS_REJECTED 86 else: 87 raise Exception("Invalid flight status code: '" + status + "'") 88 75 89 # FIXME: copied from web.BookedFlight 76 90 @staticmethod … … 79 93 return datetime.datetime.strptime(date + " " + time, 80 94 "%Y-%m-%d %H:%M:%S") 95 96 # FIXME: copied from web.BookedFlight 97 STATUS_BOOKED = 1 98 99 # FIXME: copied from web.BookedFlight 100 STATUS_REPORTED = 2 101 102 # FIXME: copied from web.BookedFlight 103 STATUS_ACCEPTED = 3 104 105 # FIXME: copied from web.BookedFlight 106 STATUS_REJECTED = 4 81 107 82 108 # The instructions for the construction … … 87 113 "cargoWeight" : int, 88 114 "mailWeight" : int, 89 "aircraftType" : lambda value: BookedFlight._decodeAircraftType(value) 115 "aircraftType" : lambda value: BookedFlight._decodeAircraftType(value), 116 "status" : lambda value: BookedFlight._decodeStatus(value) 90 117 } 91 118 … … 246 273 def getFlights(self): 247 274 """Get the flights available for performing.""" 248 flights = [] 275 bookedFlights = [] 276 reportedFlights = [] 277 rejectedFlights = [] 249 278 250 279 value = self._performCall(lambda sessionID: 251 280 self._server.getFlights(sessionID)) 252 281 for flightData in value: 253 flights.append(BookedFlight(flightData)) 254 255 flights.sort(cmp = lambda flight1, flight2: 256 cmp(flight1.departureTime, flight2.departureTime)) 257 258 return flights 282 flight = BookedFlight(flightData) 283 if flight.status == BookedFlight.STATUS_BOOKED: 284 bookedFlights.append(flight) 285 elif flight.status == BookedFlight.STATUS_REPORTED: 286 reportedFlights.append(flight) 287 elif flight.status == BookedFlight.STATUS_REJECTED: 288 rejectedFlights.append(flight) 289 290 for flights in [bookedFlights, reportedFlights, rejectedFlights]: 291 flights.sort(cmp = lambda flight1, flight2: 292 cmp(flight1.departureTime, flight2.departureTime)) 293 294 return (bookedFlights, reportedFlights, rejectedFlights) 259 295 260 296 def getEntryExamStatus(self): -
src/mlx/web.py
r806 r809 96 96 const.AIRCRAFT_B738, const.AIRCRAFT_DH8D ] 97 97 98 STATUS_BOOKED = 1 99 100 STATUS_REPORTED = 2 101 102 STATUS_ACCEPTED = 3 103 104 STATUS_REJECTED = 4 105 98 106 @staticmethod 99 107 def getDateTime(date, time): … … 137 145 """Construct a booked flight with the given ID.""" 138 146 self.id = id 147 148 @property 149 def status(self): 150 """Get the status of the flight. 151 152 For web-based flights this is always STATUS_BOOKED.""" 153 return BookedFlight.STATUS_BOOKED 139 154 140 155 def readFromWeb(self, f): … … 769 784 result.rank = loginResult[1] 770 785 result.password = password 771 result.flights = client.getFlights() 786 flights = client.getFlights() 787 result.flights = flights[0] 788 result.reportedFlights = flights[1] 789 result.rejectedFlights = flights[2] 772 790 if result.rank=="STU": 773 791 reply = client.getEntryExamStatus()
Note:
See TracChangeset
for help on using the changeset viewer.