Changeset 743:6bc880ac41eb for src/mlx
- Timestamp:
- 01/02/16 12:27:19 (9 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/acars.py
r736 r743 49 49 return "Landed" 50 50 51 def _serialize(self): 52 """Serialize the ACARS object for JSON-RPC.""" 53 bookedFlight = self.bookedFlight 54 state = self.state 55 56 attrs = {} 57 attrs["longitude"] = state.longitude 58 attrs["latitude"] = state.latitude 59 attrs["pilotName"] = self.pilotName 60 attrs["numPassengers"] = bookedFlight.numPassengers 61 attrs["blockTime"] = self.getBlockTimeText() 62 attrs["callsign"] = bookedFlight.callsign 63 attrs["aircraftTypeName"] = bookedFlight.aircraftTypeName 64 attrs["departureICAO"] = bookedFlight.departureICAO 65 attrs["arrivalICAO"] = bookedFlight.arrivalICAO 66 attrs["altitude"] = state.altitude 67 attrs["groundSpeed"] = state.groundSpeed 68 attrs["event"] = self.getEventText() 69 attrs["tailNumber"] = bookedFlight.tailNumber 70 71 return ([], attrs) 51 72 52 73 #------------------------------------------------------------------------------ -
src/mlx/pirep.py
r437 r743 4 4 import const 5 5 import cPickle as pickle 6 import datetime 7 import time 6 8 7 9 #------------------------------------------------------------------------------ … … 19 21 class PIREP(object): 20 22 """A pilot's report of a flight.""" 23 _flightTypes = { const.FLIGHTTYPE_SCHEDULED : "SCHEDULED", 24 const.FLIGHTTYPE_OLDTIMER : "OT", 25 const.FLIGHTTYPE_VIP : "VIP", 26 const.FLIGHTTYPE_CHARTER : "CHARTER" } 27 21 28 @staticmethod 22 29 def _formatLine(timeStr, line): … … 24 31 some other things.""" 25 32 return "[" + timeStr + "]-[" + line + "]" 33 34 @staticmethod 35 def formatTimestampForRPC(t): 36 """Format the given timestamp for RPC.""" 37 return time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(t)) 26 38 27 39 @staticmethod … … 91 103 self.faultLineIndexes = logger.faultLineIndexes 92 104 105 @property 106 def flightTypeText(self): 107 """Get the text representation of the flight type.""" 108 return PIREP._flightTypes[self.flightType] 109 110 @property 111 def blockTimeStartText(self): 112 """Get the beginning of the block time in string format.""" 113 return PIREP.formatTimestampForRPC(self.blockTimeStart) 114 115 @property 116 def flightTimeStartText(self): 117 """Get the beginning of the flight time in string format.""" 118 return PIREP.formatTimestampForRPC(self.flightTimeStart) 119 120 @property 121 def flightTimeEndText(self): 122 """Get the end of the flight time in string format.""" 123 return PIREP.formatTimestampForRPC(self.flightTimeEnd) 124 125 @property 126 def blockTimeEndText(self): 127 """Get the end of the block time in string format.""" 128 return PIREP.formatTimestampForRPC(self.blockTimeEnd) 129 93 130 def getACARSText(self): 94 131 """Get the ACARS text. … … 152 189 print u"Failed saving PIREP to %s: %s" % (path, error) 153 190 return error 191 192 def _serialize(self): 193 """Serialize the PIREP for JSON-RPC.""" 194 attrs = {} 195 attrs["log"] = self.getACARSText() 196 attrs["numPassengers"] = self.numPassengers 197 attrs["numCrew"] = self.numCrew 198 attrs["cargoWeight"] = self.cargoWeight 199 attrs["bagWeight"] = self.bagWeight 200 attrs["mailWeight"] = self.mailWeight 201 attrs["flightType"] = self.flightTypeText 202 attrs["online"] = 1 if self.online else 0 203 attrs["blockTimeStart"] = self.blockTimeStartText 204 attrs["blockTimeEnd"] = self.blockTimeEndText 205 attrs["flightTimeStart"] = self.flightTimeStartText 206 attrs["flightTimeEnd"] = self.flightTimeEndText 207 attrs["timeComment"] = self.getTimeComment() 208 attrs["fuelUsed"] = self.fuelUsed 209 attrs["departureRunway"] = self.departureRunway 210 attrs["arrivalRunway"] = self.arrivalRunway 211 attrs["departureMETAR"] = self.departureMETAR 212 attrs["arrivalMETAR"] = self.arrivalMETAR 213 attrs["filedCruiseLevel"] = self.filedCruiseAltitude / 100.0 214 attrs["cruiseLevel"] = self.cruiseAltitude / 100.0 215 attrs["sid"] = self.sid 216 attrs["route"] = self.route 217 attrs["star"] = self.star 218 attrs["approachType"] = self.approachType 219 attrs["comments"] = self.comments 220 attrs["flightDefects"] = self.flightDefects 221 attrs["ratingText"] = self.getRatingText() 222 attrs["rating"] = max(0.0, self.rating) 223 attrs["flownDistance"] = self.flownDistance 224 # FIXME: it should be stored in the PIREP when it is sent later 225 attrs["flightDate"] = datetime.date.today().strftime("%Y-%m-%d") 226 227 return ([], attrs) -
src/mlx/web.py
r742 r743 844 844 class SendPIREP(Request): 845 845 """A request to send a PIREP to the MAVA website.""" 846 _flightTypes = { const.FLIGHTTYPE_SCHEDULED : "SCHEDULED",847 const.FLIGHTTYPE_OLDTIMER : "OT",848 const.FLIGHTTYPE_VIP : "VIP",849 const.FLIGHTTYPE_CHARTER : "CHARTER" }850 851 846 _latin2Encoder = codecs.getencoder("iso-8859-2") 852 847 … … 877 872 data["mail"] = str(pirep.mailWeight) 878 873 879 data["flttype"] = SendPIREP._flightTypes[pirep.flightType]874 data["flttype"] = pirep.flightTypeText 880 875 data["onoff"] = "1" if pirep.online else "0" 881 876 data["bt_dep"] = util.getTimestampString(pirep.blockTimeStart)
Note:
See TracChangeset
for help on using the changeset viewer.