Changeset 743:6bc880ac41eb for src/mlx/pirep.py
- Timestamp:
- 01/02/16 12:27:19 (8 years ago)
- Branch:
- default
- hg-Phase:
- (<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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)
Note:
See TracChangeset
for help on using the changeset viewer.