Changeset 809:4da4f80a2ab4 for src/mlx/rpc.py
- Timestamp:
- 09/08/16 07:32:45 (8 years ago)
- Branch:
- default
- hg-Phase:
- (<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
- File:
-
- 1 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):
Note:
See TracChangeset
for help on using the changeset viewer.