Changeset 345:a62373a28d90 for src
- Timestamp:
- 12/08/12 15:02:57 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/acft.py
r344 r345 259 259 aircraftState.windSpeed)) 260 260 self._logRadios(aircraftState) 261 self._logV1R2( )261 self._logV1R2(aircraftState) 262 262 elif newStage==const.STAGE_DESCENT or newStage==const.STAGE_LANDING: 263 263 self._logRadios(aircraftState) … … 396 396 return str(speed) + " " + self._flight.getEnglishSpeedUnit() 397 397 398 def _logV1R2(self ):398 def _logV1R2(self, state = None): 399 399 """Log the V1, Vr and V2 value either newly, or by updating the 400 400 corresponding line.""" … … 405 405 406 406 if self._v1r2LineIndex is None: 407 if state is None: 408 state = self._aircraftState 407 409 self._v1r2LineIndex = \ 408 self.logger.message(s elf._aircraftState.timestamp, message)410 self.logger.message(state.timestamp, message) 409 411 else: 410 412 self.logger.updateLine(self._v1r2LineIndex, message) -
src/mlx/gui/common.py
r302 r345 297 297 faultTag.set_property("foreground", "red") 298 298 faultTag.set_property("weight", WEIGHT_BOLD) 299 buffer.get_tag_table().add(faultTag) 299 buffer.get_tag_table().add(faultTag) 300 300 301 301 #------------------------------------------------------------------------------ … … 305 305 306 306 If isFault is set, use the tag named 'fault'.""" 307 insertTextBuffer(buffer, buffer.get_end_iter(), text, isFault) 308 309 #------------------------------------------------------------------------------ 310 311 def insertTextBuffer(buffer, iter, text, isFault = False): 312 """Insert the given line into the given text buffer at the given iterator. 313 314 If isFault is set, use the tag named 'fault'.""" 307 315 if isFault: 308 buffer.insert_with_tags_by_name(buffer.get_end_iter(), text, 309 "fault") 316 buffer.insert_with_tags_by_name(iter, text, "fault") 310 317 else: 311 buffer.insert( buffer.get_end_iter(), text)312 313 #------------------------------------------------------------------------------ 318 buffer.insert(iter, text) 319 320 #------------------------------------------------------------------------------ -
src/mlx/gui/gui.py
r304 r345 90 90 def build(self, iconDirectory): 91 91 """Build the GUI.""" 92 92 93 93 self._mainWindow = window = gtk.Window() 94 94 window.set_title(WINDOW_TITLE_BASE) … … 112 112 self._notebook = gtk.Notebook() 113 113 mainVBox.pack_start(self._notebook, True, True, 4) 114 114 115 115 self._wizard = Wizard(self) 116 116 label = gtk.Label(xstr("tab_flight")) … … 131 131 label.set_tooltip_text(xstr("tab_weight_help_tooltip")) 132 132 self._notebook.append_page(self._weightHelp, label) 133 133 134 134 (logWidget, self._logView) = self._buildLogWidget() 135 addFaultTag(self._logView.get_buffer()) 135 addFaultTag(self._logView.get_buffer()) 136 136 label = gtk.Label(xstr("tab_log")) 137 137 label.set_use_underline(True) … … 144 144 label.set_tooltip_text(xstr("tab_gates_tooltip")) 145 145 self._notebook.append_page(self._fleetGateStatus, label) 146 146 147 147 (self._debugLogWidget, self._debugLogView) = self._buildLogWidget() 148 148 self._debugLogWidget.show_all() … … 186 186 """Get the main window of the GUI.""" 187 187 return self._mainWindow 188 188 189 189 @property 190 190 def logger(self): 191 191 """Get the logger used by us.""" 192 192 return self._logger 193 193 194 194 @property 195 195 def simulator(self): 196 196 """Get the simulator used by us.""" 197 197 return self._simulator 198 198 199 199 @property 200 200 def flight(self): … … 211 211 """Indicate if the user has logged in properly.""" 212 212 return self._wizard.loggedIn 213 213 214 214 @property 215 215 def loginResult(self): … … 251 251 """Get Zero-Fuel Weight calculated for the current flight.""" 252 252 return self._wizard.zfw 253 253 254 254 @property 255 255 def filedCruiseAltitude(self): 256 256 """Get cruise altitude filed for the current flight.""" 257 257 return self._wizard.filedCruiseAltitude 258 258 259 259 @property 260 260 def cruiseAltitude(self): … … 271 271 """Get the METAR of the deprature airport.""" 272 272 return self._wizard.departureMETAR 273 273 274 274 @property 275 275 def arrivalMETAR(self): … … 281 281 """Get the name of the departure runway.""" 282 282 return self._wizard.departureRunway 283 283 284 284 @property 285 285 def sid(self): … … 291 291 """Get the V1 speed calculated for the flight.""" 292 292 return self._wizard.v1 293 293 294 294 @property 295 295 def vr(self): 296 296 """Get the Vr speed calculated for the flight.""" 297 297 return self._wizard.vr 298 298 299 299 @property 300 300 def v2(self): 301 301 """Get the V2 speed calculated for the flight.""" 302 302 return self._wizard.v2 303 303 304 304 @property 305 305 def arrivalRunway(self): … … 326 326 """Get the Vref speed calculated for the flight.""" 327 327 return self._wizard.vref 328 328 329 329 @property 330 330 def flightType(self): … … 360 360 self._mainWindow) 361 361 self._updater.start() 362 362 363 363 singleton.raiseCallback = self.raiseCallback 364 364 gtk.main() … … 398 398 type = MESSAGETYPE_ERROR, 399 399 message_format = xstr("conn_failed")) 400 400 401 401 dialog.set_title(WINDOW_TITLE_BASE) 402 402 dialog.format_secondary_markup(xstr("conn_failed_sec")) 403 403 404 404 dialog.add_button(xstr("button_cancel"), 0) 405 405 dialog.add_button(xstr("button_tryagain"), 1) 406 406 dialog.set_default_response(1) 407 407 408 408 result = dialog.run() 409 409 dialog.hide() … … 413 413 else: 414 414 self.reset() 415 415 416 416 def disconnected(self): 417 417 """Called when we have disconnected from the simulator.""" … … 422 422 423 423 def _disconnected(self): 424 """Called when we have disconnected from the simulator unexpectedly.""" 424 """Called when we have disconnected from the simulator unexpectedly.""" 425 425 self._statusbar.updateConnection(self._connecting, self._connected) 426 426 … … 460 460 result = dialog.run() 461 461 dialog.hide() 462 462 463 463 if result==RESPONSETYPE_YES: 464 464 self.reset() … … 507 507 508 508 return True 509 510 def addFlightLogLine(self, timeStr, line, isFault = False): 511 """Write the given message line to the log.""" 512 gobject.idle_add(self._writeLog, 513 formatFlightLogLine(timeStr, line), 514 self._logView, isFault) 515 516 def updateFlightLogLine(self, index, timeStr, line): 517 """Update the line with the given index.""" 518 gobject.idle_add(self._updateFlightLogLine, index, 519 formatFlightLogLine(timeStr, line)) 520 521 def _updateFlightLogLine(self, index, line): 522 """Replace the contents of the given line in the log.""" 509 510 def insertFlightLogLine(self, index, timestampString, text, isFault): 511 """Insert the flight log line with the given data.""" 512 gobject.idle_add(self._insertFlightLogLine, index, 513 formatFlightLogLine(timestampString, text), 514 isFault) 515 516 def _insertFlightLogLine(self, index, line, isFault): 517 """Perform the real insertion. 518 519 To be called from the event loop.""" 520 buffer = self._logView.get_buffer() 521 lineIter = buffer.get_iter_at_line(index) 522 insertTextBuffer(buffer, lineIter, line, isFault = isFault) 523 self._logView.scroll_mark_onscreen(buffer.get_insert()) 524 525 def removeFlightLogLine(self, index): 526 """Remove the flight log line with the given index.""" 527 gobject.idle_add(self._removeFlightLogLine, index) 528 529 def _removeFlightLogLine(self, index): 530 """Perform the real removal.""" 523 531 buffer = self._logView.get_buffer() 524 532 startIter = buffer.get_iter_at_line(index) 525 endIter = buffer.get_iter_at_line(index +1)533 endIter = buffer.get_iter_at_line(index+1) 526 534 buffer.delete(startIter, endIter) 527 buffer.insert(startIter, line)528 535 self._logView.scroll_mark_onscreen(buffer.get_insert()) 529 536 … … 591 598 (event.new_window_state&WINDOW_STATE_ICONIFIED)==0: 592 599 self._mainWindow.present() 593 600 594 601 def raiseCallback(self): 595 602 """Callback for the singleton handling code.""" … … 630 637 self._mainWindow.present() 631 638 self._mainWindow.deiconify() 632 639 633 640 def toggleMainWindow(self): 634 641 """Toggle the main window.""" … … 679 686 if self._stdioText: 680 687 sys.__stderr__.write(self._stdioText) 681 688 682 689 def writeStdIO(self, text): 683 690 """Write the given text into standard I/O log.""" … … 758 765 self._updatePlaneStatus = status 759 766 self._updatePlaneGateNumber = gateNumber 760 767 761 768 self.webHandler.updatePlane(self._updatePlaneResultCallback, 762 769 tailNumber, status, gateNumber) … … 799 806 self._stdioText = "" 800 807 if not text: return 801 808 802 809 lines = text.splitlines() 803 810 if text[-1]=="\n": … … 809 816 now = datetime.datetime.now() 810 817 timeStr = "%02d:%02d:%02d: " % (now.hour, now.minute, now.second) 811 818 812 819 for line in lines: 813 820 #print >> sys.__stdout__, line … … 833 840 self._flight.aircraft = acft.Aircraft.create(self._flight) 834 841 self._flight.aircraft._checkers.append(self) 835 842 836 843 if self._simulator is None: 837 844 self._simulator = fs.createSimulator(const.SIM_MSFS9, self) 838 845 fs.setupMessageSending(self.config, self._simulator) 839 846 self._setupTimeSync() 840 847 841 848 self._flight.simulator = self._simulator 842 849 … … 845 852 846 853 self._connecting = True 847 self._simulator.connect(self._flight.aircraft) 854 self._simulator.connect(self._flight.aircraft) 848 855 849 856 def startMonitoring(self): … … 867 874 """Build the main menu bar.""" 868 875 menuBar = gtk.MenuBar() 869 876 870 877 fileMenuItem = gtk.MenuItem(xstr("menu_file")) 871 878 fileMenu = gtk.Menu() … … 965 972 966 973 helpMenu.append(gtk.SeparatorMenuItem()) 967 974 968 975 aboutMenuItem = gtk.ImageMenuItem(gtk.STOCK_ABOUT) 969 976 aboutMenuItem.set_use_stock(True) … … 982 989 label = gtk.Label(xstr("tab_debug_log")) 983 990 label.set_use_underline(True) 984 label.set_tooltip_text(xstr("tab_debug_log_tooltip")) 991 label.set_tooltip_text(xstr("tab_debug_log_tooltip")) 985 992 self._debugLogPage = self._notebook.append_page(self._debugLogWidget, label) 986 993 self._notebook.set_current_page(self._debugLogPage) … … 1037 1044 result = dialog.run() 1038 1045 dialog.hide() 1039 1046 1040 1047 if result==RESPONSETYPE_YES: 1041 1048 self._statusIcon.destroy() … … 1052 1059 """Callback for editing the checklists.""" 1053 1060 self._checklistEditor.run() 1054 1061 1055 1062 def _editApproachCallouts(self, menuItem): 1056 1063 """Callback for editing the approach callouts.""" 1057 1064 self._approachCalloutsEditor.run() 1058 1065 1059 1066 def _editPreferences(self, menuItem): 1060 1067 """Callback for editing the preferences.""" … … 1084 1091 if pirepDirectory is not None: 1085 1092 dialog.set_current_folder(pirepDirectory) 1086 1093 1087 1094 result = dialog.run() 1088 1095 dialog.hide() … … 1132 1139 parent = self._mainWindow) 1133 1140 dialog.set_modal(True) 1134 1141 1135 1142 1136 1143 filter = gtk.FileFilter() … … 1138 1145 filter.add_pattern("*.pirep") 1139 1146 dialog.add_filter(filter) 1140 1147 1141 1148 filter = gtk.FileFilter() 1142 1149 filter.set_name(xstr("file_filter_all")) … … 1184 1191 labelAlignment.add(label) 1185 1192 table.attach(labelAlignment, 0, 1, 0, 1) 1186 1193 1187 1194 label = gtk.Label(bookedFlight.callsign) 1188 1195 labelAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.5, … … 1197 1204 labelAlignment.add(label) 1198 1205 table.attach(labelAlignment, 0, 1, 1, 2) 1199 1206 1200 1207 label = gtk.Label(str(bookedFlight.departureTime.date())) 1201 1208 labelAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.5, … … 1210 1217 labelAlignment.add(label) 1211 1218 table.attach(labelAlignment, 0, 1, 2, 3) 1212 1219 1213 1220 label = gtk.Label(bookedFlight.departureICAO) 1214 1221 labelAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.5, … … 1223 1230 labelAlignment.add(label) 1224 1231 table.attach(labelAlignment, 0, 1, 3, 4) 1225 1232 1226 1233 label = gtk.Label(bookedFlight.arrivalICAO) 1227 1234 labelAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.5, … … 1243 1250 else: 1244 1251 label.set_text("%.1f %%" % (rating,)) 1245 1252 1246 1253 labelAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.5, 1247 1254 xscale = 0.0, yscale = 0.0) … … 1252 1259 dialog.add_button(xstr("viewPIREP"), 1) 1253 1260 dialog.add_button(xstr("sendPIREP"), RESPONSETYPE_OK) 1254 1261 1255 1262 return dialog 1256 1263 1257 1264 def sendPIREP(self, pirep, callback = None): 1258 1265 """Send the given PIREP.""" … … 1287 1294 messageFormat = xstr("sendPIREP_failed") 1288 1295 secondaryMarkup = xstr("sendPIREP_failed_sec") 1289 1296 1290 1297 dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow, 1291 1298 type = type, message_format = messageFormat) … … 1365 1372 dialog.set_transient_for(self._mainWindow) 1366 1373 dialog.set_modal(True) 1367 1374 1368 1375 logoPath = os.path.join(self._programDirectory, "logo.png") 1369 1376 logo = pixbuf_new_from_file(logoPath) 1370 1377 dialog.set_logo(logo) 1371 1378 1372 1379 dialog.set_program_name(PROGRAM_NAME) 1373 1380 dialog.set_version(const.VERSION) … … 1396 1403 1397 1404 def _showAboutURL(self, dialog, link, user_data): 1398 """Show the about URL.""" 1405 """Show the about URL.""" 1399 1406 webbrowser.open(url = link, new = 1) -
src/mlx/logger.py
r315 r345 6 6 import sys 7 7 import time 8 import bisect 8 9 9 10 #-------------------------------------------------------------------------------------- … … 28 29 29 30 class Logger(object): 30 """The class with the interface to log the various events.""" 31 """The class with the interface to log the various events. 32 33 It contains a list of entries ordered by their timestamps and their ever 34 increasing IDs.""" 35 36 class Entry(object): 37 """An entry in the log.""" 38 39 # The ID of the next entry to be created 40 _nextID = 1 41 42 def __init__(self, timestamp, text, showTimestamp = True, 43 faultID = None, faultScore = 0, id = None): 44 """Construct the entry.""" 45 if id is None: 46 self._id = self._nextID 47 Logger.Entry._nextID += 1 48 else: 49 self._id = id 50 51 self._timestamp = timestamp 52 self._text = text 53 self._showTimestamp = showTimestamp 54 55 self._faultID = faultID 56 self._faultScore = faultScore 57 58 @property 59 def id(self): 60 """Get the ID of the entry.""" 61 return self._id 62 63 @property 64 def timestamp(self): 65 """Get the timestamp of this entry.""" 66 return self._timestamp 67 68 @property 69 def timestampString(self): 70 """Get the timestamp string of this entry. 71 72 It returns None, if the timestamp of the entry is not visible.""" 73 return util.getTimestampString(self._timestamp) \ 74 if self._showTimestamp else None 75 76 @property 77 def text(self): 78 """Get the text of this entry.""" 79 return self._text 80 81 @property 82 def isFault(self): 83 """Determine if this is a log entry about a fault.""" 84 return self._faultID is not None 85 86 @property 87 def faultID(self): 88 """Get the fault ID of the entry. 89 90 It may be None, if the entry is not a fault entry.""" 91 return self._faultID 92 93 @property 94 def faultScore(self): 95 """Get the fault score of the entry, if it is a fault.""" 96 return self._faultScore 97 98 def copy(self, text = None): 99 """Create a copy of this entry with the given values changed.""" 100 return Logger.Entry(self._timestamp, 101 self._text if text is None else text, 102 showTimestamp = self._showTimestamp, 103 faultID = self._faultID, 104 faultScore = self._faultScore, 105 id = self._id) 106 107 def __cmp__(self, other): 108 """Compare two entries 109 110 First their timestamps are compared, and if those are equal, then 111 their IDs.""" 112 result = cmp(self._timestamp, other.timestamp) 113 if result==0: 114 result = cmp(self._id, other._id) 115 return result 116 117 class Fault(object): 118 """Information about a fault. 119 120 It contains the list of log entries that belong to this fault. The list 121 is ordered so that the first element contains the entry with the 122 highest score, so that it should be easy to find the actual score.""" 123 def __init__(self, entry): 124 """Construct the fault info with the given log entry as its only 125 one.""" 126 self._entries = [entry] 127 128 @property 129 def score(self): 130 """Get the score of this fault, i.e. the score of the entry with 131 the highest score.""" 132 return self._entries[0].faultScore if self._entries else 0 133 134 def addEntry(self, entry): 135 """Add an entry to this fault. 136 137 The entries will be sorted.""" 138 entries = self._entries 139 entries.append(entry) 140 entries.sort(key = Logger.Entry.faultScore, reverse = True) 141 142 def removeEntry(self, entry): 143 """Remove the given entry. 144 145 Returns True if at least one entry remains, False otherwise.""" 146 entries = self._entries 147 for index in range(0, len(entries)): 148 if entry is entries[index]: 149 del entries[index] 150 break 151 152 return len(entries)>0 153 31 154 # FIXME: shall we use const.stage2string() instead? 32 155 _stages = { const.STAGE_BOARDING : "Boarding", … … 42 165 const.STAGE_GOAROUND : "Go-Around", 43 166 const.STAGE_END : "End" } 44 167 45 168 NO_GO_SCORE = 10000 46 169 47 170 def __init__(self, output): 48 171 """Construct the logger.""" 172 self._entries = {} 49 173 self._lines = [] 174 50 175 self._faults = {} 51 self._faultLineIndexes = [] 176 52 177 self._output = output 53 178 … … 55 180 def lines(self): 56 181 """Get the lines of the log.""" 57 return self._lines182 return [(entry.timestampString, entry.text) for entry in self._lines] 58 183 59 184 @property 60 185 def faultLineIndexes(self): 61 """Get the array of the indexes of the log line that contains a 62 fault.""" 63 return self._faultLineIndexes 186 """Get the sorted array of the indexes of those log lines that contain 187 a fault.""" 188 faultLineIndexes = [] 189 lines = self._lines 190 for index in range(0, len(lines)): 191 if lines[index].isFault: 192 faultLineIndexes.append(index) 193 return faultLineIndexes 64 194 65 195 def reset(self): … … 67 197 68 198 The faults logged so far will be cleared.""" 199 self._entries = {} 69 200 self._lines = [] 70 self._faults .clear()71 self._faultLineIndexes = [] 72 73 def message(self, timestamp, msg, isFault = False):74 """Put a simple textual message into the log with the given timestamp.""" 75 timeStr = util.getTimestampString(timestamp)76 return self._ logLine(msg, timeStr, isFault = isFault)77 78 def untimedMessage(self, msg , isFault = False):201 self._faults = {} 202 203 def message(self, timestamp, msg): 204 """Put a simple textual message into the log with the given timestamp. 205 206 Returns an ID of the message so that it could be referred to later.""" 207 return self._addEntry(Logger.Entry(timestamp, msg)) 208 209 def untimedMessage(self, msg): 79 210 """Put an untimed message into the log.""" 80 return self._logLine(msg, isFault = isFault) 211 timestamp = self._lines[-1].timestamp if self._lines else 0 212 return self._addEntry(Logger.Entry(timestamp, msg, 213 showTimestamp = False)) 81 214 82 215 def debug(self, msg): … … 97 230 else const.MESSAGETYPE_INFORMATION 98 231 sendMessage(messageType, "Flight stage: " + s, 3) 99 232 100 233 def fault(self, faultID, timestamp, what, score): 101 234 """Report a fault. … … 104 237 this ID has been reported earlier, it will be reported again only if 105 238 the score is greater than last time. This ID can be, e.g. the checker 106 the report comes from.""" 239 the report comes from. 240 241 Returns an ID of the fault, or -1 if it was not logged.""" 107 242 if faultID in self._faults: 108 if score<=self._faults[faultID] :109 return 110 self._faults[faultID] = score 243 if score<=self._faults[faultID].score: 244 return -1 245 111 246 text = "%s (NO GO)" % (what) if score==Logger.NO_GO_SCORE \ 112 247 else "%s (%.1f)" % (what, score) 113 lineIndex = self.message(timestamp, text, isFault = True) 114 self._faultLineIndexes.append(lineIndex) 248 249 id = self._addEntry(Logger.Entry(timestamp, text, faultID = faultID, 250 faultScore = score)) 251 115 252 (messageType, duration) = (const.MESSAGETYPE_NOGO, 10) \ 116 253 if score==Logger.NO_GO_SCORE \ 117 254 else (const.MESSAGETYPE_FAULT, 5) 118 sendMessage(messageType, text, duration) 255 sendMessage(messageType, text, duration) 256 257 return id 119 258 120 259 def noGo(self, faultID, timestamp, what): 121 260 """Report a No-Go fault.""" 122 self.fault(faultID, timestamp, what, Logger.NO_GO_SCORE)261 return self.fault(faultID, timestamp, what, Logger.NO_GO_SCORE) 123 262 124 263 def getRating(self): 125 264 """Get the rating of the flight so far.""" 126 265 totalScore = 100 127 for (id, score) in self._faults.iteritems(): 266 for fault in self._faults.itervalues(): 267 score = fault.score 128 268 if score==Logger.NO_GO_SCORE: 129 269 return -score … … 132 272 return totalScore 133 273 134 def updateLine(self, index, line): 135 """Update the line at the given index with the given string.""" 136 (timeStr, _line) = self._lines[index] 137 self._lines[index] = (timeStr, line) 138 self._output.updateFlightLogLine(index, timeStr, line) 139 140 def _logLine(self, line, timeStr = None, isFault = False): 141 """Log the given line.""" 142 index = len(self._lines) 143 self._lines.append((timeStr, line)) 144 self._output.addFlightLogLine(timeStr, line, isFault) 145 return index 146 274 def updateLine(self, id, line): 275 """Update the line with the given ID with the given string. 276 277 Note, that it does not change the status of the line as a fault!""" 278 self._updateEntry(id, self._entries[id].copy(text = line)) 279 280 def _addEntry(self, entry): 281 """Add the given entry to the log. 282 283 @return the ID of the new entry.""" 284 assert entry.id not in self._entries 285 286 self._entries[entry.id] = entry 287 288 if not self._lines or entry>self._lines[-1]: 289 index = len(self._lines) 290 self._lines.append(entry) 291 else: 292 index = bisect.bisect_left(self._lines, entry) 293 self._lines.insert(index, entry) 294 295 if entry.isFault: 296 self._addFault(entry) 297 298 self._output.insertFlightLogLine(index, entry.timestampString, 299 entry.text, entry.isFault) 300 301 return entry.id 302 303 def _updateEntry(self, id, newEntry): 304 """Update the entry with the given ID from the given new entry.""" 305 self._removeEntry(id) 306 self._addEntry(newEntry) 307 308 def _removeEntry(self, id): 309 """Remove the entry with the given ID.""" 310 assert id in self._entries 311 312 entry = self._entries[id] 313 del self._entries[id] 314 315 for index in range(len(self._lines)-1, -1, -1): 316 if self._lines[index] is entry: 317 break 318 del self._lines[index] 319 320 if entry.isFault: 321 faultID = entry.faultID 322 fault = self._faults[faultID] 323 if not fault.removeEntry(entry): 324 del self._faults[faultID] 325 326 self._output.removeFlightLogLine(index) 327 328 def _addFault(self, entry): 329 """Add the given fault entry to the fault with the given ID.""" 330 faultID = entry.faultID 331 if faultID in self._faults: 332 self._faults[faultID].addEntry(entry) 333 else: 334 self._faults[faultID] = Logger.Fault(entry) 335 147 336 #-------------------------------------------------------------------------------------- -
src/mlx/pirep.py
r303 r345 54 54 print "Failed loading PIREP from %s: %s" % (path, str(e)) 55 55 return None 56 56 57 57 def __init__(self, flight): 58 58 """Initialize the PIREP from the given flight.""" … … 64 64 self.cargoWeight = flight.cargoWeight 65 65 self.mailWeight = flight.mailWeight 66 66 67 67 self.filedCruiseAltitude = flight.filedCruiseAltitude 68 68 self.cruiseAltitude = flight.cruiseAltitude … … 86 86 self.flightDefects = flight.flightDefects 87 87 self.delayCodes = flight.delayCodes 88 88 89 89 self.blockTimeStart = flight.blockTimeStart 90 90 self.flightTimeStart = flight.flightTimeStart … … 98 98 self.logLines = logger.lines 99 99 self.faultLineIndexes = logger.faultLineIndexes 100 100 101 101 def getACARSText(self): 102 102 """Get the ACARS text. … … 121 121 if timeStr is not None: 122 122 text += PIREP._formatLine(timeStr, line) 123 text += "\n" 123 text += "\n" 124 124 125 125 text += "\n[Flight Rating: %.1f]" % (max(0.0, self.rating),) 126 126 127 127 return text 128 128 129 129 def getTimeComment(self): 130 130 """Get the time comment.
Note:
See TracChangeset
for help on using the changeset viewer.