Changeset 184:0a000ef19c3a for src
- Timestamp:
- 05/16/12 18:04:55 (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/acft.py
r170 r184 66 66 # queried from it, so the model should have a reference to the GUI as 67 67 # well and access such data via the GUI! 68 if flight.config.onlineACARS :68 if flight.config.onlineACARS and not flight.entranceExam: 69 69 self._checkers.append(checks.ACARSSender(flight._gui)) 70 70 … … 173 173 self._logV1R2() 174 174 elif newStage==const.STAGE_TAXIAFTERLAND: 175 bookedFlight = self._flight.bookedFlight 176 config = self._flight.config 175 flight = self._flight 176 bookedFlight = flight.bookedFlight 177 config = flight.config 177 178 if config.onlineGateSystem and \ 179 not flight.entranceExam and \ 178 180 bookedFlight.arrivalICAO=="LHBP" and \ 179 181 config.isMessageTypeFS(const.MESSAGETYPE_GATE_SYSTEM): -
src/mlx/checks.py
r183 r184 750 750 """Get the limit if we are in the right state.""" 751 751 return aircraft.mlw if flight.stage==const.STAGE_LANDING and \ 752 state.onTheGround else None 752 state.onTheGround and \ 753 not flight.entranceExam else None 753 754 754 755 #--------------------------------------------------------------------------------------- … … 762 763 def getLimit(self, flight, aircraft, state): 763 764 """Get the limit if we are in the right state.""" 764 return aircraft.mtow if flight.stage==const.STAGE_TAKEOFF else None 765 return aircraft.mtow if flight.stage==const.STAGE_TAKEOFF and \ 766 not flight.entranceExam else None 765 767 766 768 #--------------------------------------------------------------------------------------- … … 774 776 def getLimit(self, flight, aircraft, state): 775 777 """Get the limit if we are in the right state.""" 776 return aircraft.mzfw 778 return aircraft.mzfw if not flight.entranceExam else None 777 779 778 780 def getWeight(self, state): … … 829 831 def isCondition(self, flight, aircraft, oldState, state): 830 832 """Check if the fault condition holds.""" 831 return flight.stage==const.STAGE_PUSHANDTAXI and \ 833 return not flight.entranceExam and \ 834 flight.stage==const.STAGE_PUSHANDTAXI and \ 832 835 PayloadChecker.isZFWFaulty(state.zfw, flight.zfw) 833 836 -
src/mlx/flight.py
r183 r184 29 29 30 30 self.flareTimeFromFS = False 31 self.entranceExam = False32 31 33 32 self.aircraftType = None … … 67 66 """Get the flight stage.""" 68 67 return self._stage 68 69 @property 70 def entranceExam(self): 71 """Get whether an entrance exam is being performed.""" 72 return self._gui.entranceExam 69 73 70 74 @property -
src/mlx/gui/checklist.py
r175 r184 72 72 73 73 filter = gtk.FileFilter() 74 filter.set_name(xstr(" chklst_filter_all"))74 filter.set_name(xstr("file_filter_all")) 75 75 filter.add_pattern("*.*") 76 76 self._fileChooser.add_filter(filter) -
src/mlx/gui/flight.py
r170 r184 11 11 from mlx.i18n import xstr 12 12 from mlx.sound import startSound 13 import mlx.web as web 13 14 14 15 import datetime … … 215 216 xscale = 0.0, yscale = 0.0) 216 217 217 table = gtk.Table( 2, 3)218 table = gtk.Table(4, 2) 218 219 table.set_row_spacings(4) 219 220 table.set_col_spacings(32) … … 229 230 230 231 self._pilotID = gtk.Entry() 231 self._pilotID.connect("changed", self._set LoginButton)232 self._pilotID.connect("changed", self._setControls) 232 233 self._pilotID.set_tooltip_text(xstr("login_pilotID_tooltip")) 233 234 table.attach(self._pilotID, 1, 2, 0, 1) … … 243 244 self._password = gtk.Entry() 244 245 self._password.set_visibility(False) 245 self._password.connect("changed", self._set LoginButton)246 self._password.connect("changed", self._setControls) 246 247 self._password.set_tooltip_text(xstr("login_password_tooltip")) 247 248 table.attach(self._password, 1, 2, 1, 2) … … 253 254 table.attach(self._rememberButton, 1, 2, 2, 3, ypadding = 8) 254 255 256 self._entranceExam = gtk.CheckButton(xstr("login_entranceExam")) 257 self._entranceExam.set_use_underline(True) 258 self._entranceExam.set_tooltip_text(xstr("login_entranceExam_tooltip")) 259 self._entranceExam.connect("toggled", self._setControls) 260 table.attach(self._entranceExam, 1, 2, 3, 4, ypadding = 12) 261 255 262 self._loginButton = self.addButton(xstr("button_login"), default = True) 256 self._loginButton.set_sensitive(False)257 263 self._loginButton.connect("clicked", self._loginClicked) 258 self._loginButton.set_tooltip_text(xstr("login_button_tooltip")) 264 self._loginButton.set_tooltip_text(xstr("login_button_tooltip")) 265 266 267 @property 268 def entranceExam(self): 269 """Get whether an entrance exam is being performed.""" 270 return self._entranceExam.get_active() and \ 271 self._pilotID.get_text()!="" 259 272 260 273 def activate(self): … … 264 277 self._password.set_text(config.password) 265 278 self._rememberButton.set_active(config.rememberPassword) 266 267 def _setLoginButton(self, entry): 268 """Set the login button's sensitivity. 269 270 The button is sensitive only if both the pilot ID and the password 271 fields contain values.""" 272 self._loginButton.set_sensitive(self._pilotID.get_text()!="" and 273 self._password.get_text()!="") 279 self._setControls(None) 280 281 def _setControls(self, entry = None): 282 """Set the sensitivity of the various controls. 283 284 The login button is sensitive only if both the pilot ID and the 285 password fields contain values. 286 287 The password field is sensitive only, if the entrance exam checkbox is 288 not selected. 289 290 The remember password checkbox is sensitive only, if the password field 291 contains text. 292 293 The entrance exam checkbox is senstive only, if the pilot ID is not 294 empty.""" 295 pilotID = self._pilotID.get_text() 296 password = self._password.get_text() 297 entranceExam = self._entranceExam.get_active() 298 self._password.set_sensitive(not entranceExam) 299 self._rememberButton.set_sensitive(password!="" and not entranceExam) 300 self._entranceExam.set_sensitive(pilotID!="") 301 self._loginButton.set_sensitive(pilotID!="" and 302 (password!="" or entranceExam)) 274 303 275 304 def _loginClicked(self, button): 276 305 """Called when the login button was clicked.""" 277 self._loginButton.set_sensitive(False)278 306 gui = self._wizard.gui 279 307 gui.beginBusy(xstr("login_busy")) 280 308 gui.webHandler.login(self._loginResultCallback, 281 self._pilotID.get_text(), 282 self._password.get_text()) 309 self._pilotID.get_text(), 310 self._password.get_text(), 311 entranceExam = self.entranceExam) 283 312 284 313 def _loginResultCallback(self, returned, result): … … 306 335 self._wizard.nextPage() 307 336 else: 337 message = xstr("login_entranceExam_invalid" 338 if self.entranceExam else 339 xstr("login_invalid")) 308 340 dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow, 309 341 type = MESSAGETYPE_ERROR, 310 message_format = xstr("login_invalid"))342 message_format = message) 311 343 dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK) 312 344 dialog.set_title(WINDOW_TITLE_BASE) 313 dialog.format_secondary_markup(xstr("login_invalid_sec")) 345 secondary = xstr("login_entranceExam_invalid_sec" 346 if self.entranceExam else 347 xstr("login_invalid_sec")) 348 dialog.format_secondary_markup(secondary) 314 349 dialog.run() 315 350 dialog.hide() … … 375 410 self.setMainWidget(alignment) 376 411 412 self._loadButton = self.addButton(xstr("flightsel_load"), 413 sensitive = True, 414 tooltip = xstr("flightsel_load_tooltip")) 415 self._loadButton.connect("clicked", self._loadButtonClicked) 416 self._loadDialog = None 417 377 418 self._button = self.addNextButton(sensitive = False, 378 419 clicked = self._forwardClicked) 420 421 self._flights = [] 379 422 380 423 def activate(self): 381 424 """Fill the flight list.""" 382 425 self._flightList.set_sensitive(True) 426 self._flights = [] 383 427 self._listStore.clear() 384 428 for flight in self._wizard.loginResult.flights: 385 self._listStore.append([str(flight.departureTime), 386 flight.callsign, 387 flight.departureICAO, 388 flight.arrivalICAO]) 389 429 self._addFlight(flight) 430 390 431 def finalize(self): 391 432 """Finalize the page.""" 392 433 self._flightList.set_sensitive(False) 393 434 435 def _addFlight(self, flight): 436 """Add the given file to the list of flights.""" 437 self._flights.append(flight) 438 self._listStore.append([str(flight.departureTime), 439 flight.callsign, 440 flight.departureICAO, 441 flight.arrivalICAO]) 442 394 443 def _selectionChanged(self, selection): 395 444 """Called when the selection is changed.""" 396 445 self._button.set_sensitive(selection.count_selected_rows()==1) 397 446 447 def _loadButtonClicked(self, loadButton): 448 """Called when the load a flight button is clicked.""" 449 dialog = self._getLoadDialog() 450 dialog.show_all() 451 response = dialog.run() 452 dialog.hide() 453 454 if response==RESPONSETYPE_OK: 455 fileName = dialog.get_filename() 456 print "Loading", fileName 457 bookedFlight = web.BookedFlight() 458 try: 459 with open(fileName, "rt") as f: 460 bookedFlight.readFromFile(f) 461 self._addFlight(bookedFlight) 462 except Exception, e: 463 print "Failed to load flight:", str(e) 464 dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow, 465 type = MESSAGETYPE_ERROR, 466 message_format = 467 xstr("flightsel_load_failed")) 468 dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK) 469 dialog.set_title(WINDOW_TITLE_BASE) 470 secondary = xstr("flightsel_load_failed_sec") 471 dialog.format_secondary_markup(secondary) 472 dialog.run() 473 dialog.hide() 474 398 475 def _forwardClicked(self, button): 399 476 """Called when the forward button was clicked.""" … … 406 483 [index] = path.get_indices() if pygobject else path 407 484 408 flight = self._ wizard.loginResult.flights[index]485 flight = self._flights[index] 409 486 self._wizard._bookedFlight = flight 410 487 self._wizard.gui.enableFlightInfo() … … 415 492 """Update the departure gate for the booked flight.""" 416 493 flight = self._wizard._bookedFlight 417 if self._wizard.gui.config.onlineGateSystem: 494 if self._wizard.gui.config.onlineGateSystem and \ 495 not self._wizard.entranceExam: 418 496 if flight.departureICAO=="LHBP": 419 497 self._wizard.getFleet(self._fleetRetrieved) … … 449 527 self._nextDistance = 2 450 528 self._wizard.jumpPage(2) 451 529 530 def _getLoadDialog(self): 531 """Get the dialog to load a flight file.""" 532 if self._loadDialog is not None: 533 return self._loadDialog 534 535 gui = self._wizard.gui 536 dialog = gtk.FileChooserDialog(title = WINDOW_TITLE_BASE + " - " + 537 xstr("flightsel_load_title"), 538 action = FILE_CHOOSER_ACTION_OPEN, 539 buttons = (gtk.STOCK_CANCEL, 540 RESPONSETYPE_CANCEL, 541 gtk.STOCK_OK, RESPONSETYPE_OK), 542 parent = gui.mainWindow) 543 dialog.set_modal(True) 544 545 filter = gtk.FileFilter() 546 filter.set_name(xstr("flightsel_filter_flights")) 547 filter.add_pattern("*.vaflight") 548 dialog.add_filter(filter) 549 550 filter = gtk.FileFilter() 551 filter.set_name(xstr("file_filter_all")) 552 filter.add_pattern("*.*") 553 dialog.add_filter(filter) 554 555 self._loadDialog = dialog 556 557 return dialog 558 452 559 #----------------------------------------------------------------------------- 453 560 … … 2036 2143 if self._wizard.gui.config.onlineGateSystem and \ 2037 2144 not self._completed and \ 2038 self._wizard.bookedFlight.arrivalICAO=="LHBP": 2145 self._wizard.bookedFlight.arrivalICAO=="LHBP" and \ 2146 not self._wizard.entranceExam: 2039 2147 self._wizard.getFleet(callback = self._fleetRetrieved, 2040 2148 force = True) … … 2238 2346 self._gatesModel.clear() 2239 2347 if self._wizard.gui.config.onlineGateSystem and \ 2240 self._wizard.bookedFlight.arrivalICAO=="LHBP": 2348 self._wizard.bookedFlight.arrivalICAO=="LHBP" and \ 2349 not self._wizard.entranceExam: 2241 2350 occupiedGates = self._wizard._fleet.getOccupiedGateNumbers() 2242 2351 for gateNumber in const.lhbpGateNumbers: … … 2261 2370 2262 2371 self._saveButton.set_sensitive(sensitive) 2263 self._sendButton.set_sensitive(sensitive) 2372 self._sendButton.set_sensitive(sensitive and 2373 self._wizard.bookedFlight.id is not None) 2264 2374 2265 2375 def _flightTypeChanged(self, comboBox): … … 2339 2449 2340 2450 filter = gtk.FileFilter() 2341 filter.set_name(xstr(" loadPIREP_filter_pireps"))2451 filter.set_name(xstr("file_filter_pireps")) 2342 2452 filter.add_pattern("*.pirep") 2343 2453 dialog.add_filter(filter) 2344 2454 2345 2455 filter = gtk.FileFilter() 2346 filter.set_name(xstr(" loadPIREP_filter_all"))2456 filter.set_name(xstr("file_filter_all")) 2347 2457 filter.add_pattern("*.*") 2348 2458 dialog.add_filter(filter) … … 2361 2471 def _handlePIREPSent(self, returned, result): 2362 2472 """Callback for the PIREP sending result.""" 2363 if self._wizard.gui.config.onlineGateSystem and returned and result.success: 2473 if self._wizard.gui.config.onlineGateSystem and \ 2474 not self._wizard.entranceExam and \ 2475 returned and result.success: 2364 2476 bookedFlight = self._wizard.bookedFlight 2365 2477 if bookedFlight.arrivalICAO=="LHBP": … … 2394 2506 self._pages = [] 2395 2507 self._currentPage = None 2396 2397 self._pages.append(LoginPage(self)) 2508 2509 self._loginPage = LoginPage(self) 2510 self._pages.append(self._loginPage) 2398 2511 self._pages.append(FlightSelectionPage(self)) 2399 2512 self._pages.append(GateSelectionPage(self)) … … 2432 2545 2433 2546 self._initialize() 2547 2548 @property 2549 def entranceExam(self): 2550 """Get whether an entrance exam is about to be taken.""" 2551 return self._loginPage.entranceExam 2434 2552 2435 2553 @property -
src/mlx/gui/gui.py
r182 r184 179 179 return self._flight 180 180 181 @property 182 def entranceExam(self): 183 """Get whether an entrance exam is about to be taken.""" 184 return self._wizard.entranceExam 185 181 186 @property 182 187 def loginResult(self): … … 977 982 978 983 filter = gtk.FileFilter() 979 filter.set_name(xstr(" loadPIREP_filter_pireps"))984 filter.set_name(xstr("file_filter_pireps")) 980 985 filter.add_pattern("*.pirep") 981 986 dialog.add_filter(filter) 982 987 983 988 filter = gtk.FileFilter() 984 filter.set_name(xstr(" loadPIREP_filter_all"))989 filter.set_name(xstr("file_filter_all")) 985 990 filter.add_pattern("*.*") 986 991 dialog.add_filter(filter) -
src/mlx/i18n.py
r183 r184 147 147 self.add("aircraft_t154", "Tupolev Tu-154") 148 148 self.add("aircraft_yk40", "Yakovlev Yak-40") 149 150 self.add("file_filter_all", "All files") 151 self.add("file_filter_pireps", "PIREP files") 149 152 150 153 self.add("button_ok", "_OK") … … 221 224 "is stored as text, and anybody who can access your files will " 222 225 "be able to read it.") 226 self.add("login_entranceExam", "_Entrance Exam") 227 self.add("login_entranceExam_tooltip", 228 "Check this to log in to take your entrance exam.") 223 229 self.add("button_login", "Logi_n") 224 230 self.add("login_button_tooltip", "Click to log in.") 225 231 self.add("login_busy", "Logging in...") 226 232 self.add("login_invalid", "Invalid pilot's ID or password.") 233 self.add("login_entranceExam_invalid", 234 "Invalid pilot's ID or not registered for exam.") 227 235 self.add("login_invalid_sec", 228 236 "Check the ID and try to reenter the password.") 237 self.add("login_entranceExam_invalid_sec", 238 "Check the ID and make sure that you are " 239 "allowed to take your entrance exam.") 229 240 self.add("login_failconn", 230 241 "Failed to connect to the MAVA website.") … … 243 254 self.add("flightsel_from", "From") 244 255 self.add("flightsel_to", "To") 256 self.add("flightsel_load", "Load flight from _file") 257 self.add("flightsel_load_tooltip", 258 "Click here to load a flight from a file, " 259 "and add it to the list above.") 260 self.add("flightsel_load_title", "Load flight from file") 261 self.add("flightsel_filter_flights", "Flight files") 262 self.add("flightsel_load_failed", 263 "Could not load the flight file") 264 self.add("flightsel_load_failed_sec", 265 "Check the debug log for more details.") 245 266 246 267 self.add("fleet_busy", "Retrieving fleet...") … … 665 686 "Move down the selected file(s) in the checklist.") 666 687 self.add("chklst_filter_audio", "Audio files") 667 self.add("chklst_filter_all", "All files")668 688 self.add("chklst_header", "Checklist files") 669 689 … … 758 778 759 779 self.add("loadPIREP_browser_title", "Select the PIREP to load") 760 self.add("loadPIREP_filter_pireps", "PIREP files")761 self.add("loadPIREP_filter_all", "All files")762 780 self.add("loadPIREP_failed", "Failed to load the PIREP") 763 781 self.add("loadPIREP_failed_sec", "See the debug log for the details.") … … 821 839 self.add("aircraft_t154", "Tupoljev Tu-154") 822 840 self.add("aircraft_yk40", "Jakovlev Jak-40") 841 842 self.add("file_filter_all", "Összes fájl") 843 self.add("file_filter_pireps", "PIREP fájlok") 823 844 824 845 self.add("button_ok", "_OK") … … 1286 1307 "Az ellenőrzőlistából kijelölt fájl(ok) eggyel lejjebb mozgatása.") 1287 1308 self.add("chklst_filter_audio", "Audio fájlok") 1288 self.add("chklst_filter_all", "Összes fájl")1289 1309 self.add("chklst_header", "Ellenőrzőlista fájljai") 1290 1310 … … 1446 1466 1447 1467 self.add("loadPIREP_browser_title", "Válaszd ki a betöltendő PIREP-et") 1448 self.add("loadPIREP_filter_pireps", "PIREP fájlok")1449 self.add("loadPIREP_filter_all", "Összes fájl")1450 1468 self.add("loadPIREP_failed", "Nem tudtam betölteni a PIREP-et") 1451 1469 self.add("loadPIREP_failed_sec", -
src/mlx/web.py
r151 r184 65 65 const.AIRCRAFT_T154 : "TU5", 66 66 const.AIRCRAFT_YK40 : "YK4" } 67 68 def __init__(self, id, f): 69 """Construct a booked flight with the given ID. 70 71 The rest of the data is read from the given file.""" 72 67 68 @staticmethod 69 def getDateTime(date, time): 70 """Get a datetime object from the given textual date and time.""" 71 return datetime.datetime.strptime(date + " " + time, 72 "%Y-%m-%d %H:%M:%S") 73 74 def __init__(self, id = None): 75 """Construct a booked flight with the given ID.""" 73 76 self.id = id 77 78 def readFromWeb(self, f): 79 """Read the data of the flight from the web via the given file 80 object.""" 74 81 self.callsign = readline(f) 75 82 … … 89 96 90 97 departureTime = readline(f) 91 self.departureTime = datetime.datetime.strptime(date + " " + departureTime, 92 "%Y-%m-%d %H:%M:%S") 98 self.departureTime = BookedFlight.getDateTime(date, departureTime) 93 99 94 100 arrivalTime = readline(f) 95 self.arrivalTime = datetime.datetime.strptime(date + " " + arrivalTime, 96 "%Y-%m-%d %H:%M:%S") 101 self.arrivalTime = BookedFlight.getDateTime(date, arrivalTime) 97 102 98 103 if not readline(f)==".NEXT.": 99 104 raise Exception("Invalid line in flight data") 100 105 106 def readFromFile(self, f): 107 """Read the data of the flight from a file via the given file 108 object.""" 109 date = None 110 departureTime = None 111 arrivalTime = None 112 113 line = f.readline() 114 lineNumber = 0 115 while line: 116 lineNumber += 1 117 line = line.strip() 118 119 hashIndex = line.find("#") 120 if hashIndex>=0: line = line[:hashIndex] 121 if line: 122 equalIndex = line.find("=") 123 lineOK = equalIndex>0 124 125 if lineOK: 126 key = line[:equalIndex].strip() 127 value = line[equalIndex+1:].strip().replace("\:", ":") 128 129 lineOK = key and value 130 131 if lineOK: 132 if key=="callsign": self.callsign = value 133 elif key=="date": date = value 134 elif key=="dep_airport": self.departureICAO = value 135 elif key=="dest_airport": self.arrivalICAO = value 136 elif key=="planecode": self.aircraftType = \ 137 self._decodeAircraftType(value) 138 elif key=="tail_nr": self.tailNumber = value 139 elif key=="passenger": self.numPassengers = int(value) 140 elif key=="crew": self.numCrew = int(value) 141 elif key=="bag": self.bagWeight = int(value) 142 elif key=="cargo": self.cargoWeight = int(value) 143 elif key=="mail": self.mailWeight = int(value) 144 elif key=="flight_route": self.route = value 145 elif key=="departure_time": departureTime = value 146 elif key=="arrival_time": arrivalTime = value 147 elif key=="foglalas_id": pass 148 elif key=="planetype": pass 149 else: lineOK = False 150 151 if not lineOK: 152 print "web.BookedFlight.readFromFile: line %d is invalid" % \ 153 (lineNumber,) 154 155 line = f.readline() 156 157 if date is not None: 158 if departureTime is not None: 159 self.departureTime = BookedFlight.getDateTime(date, 160 departureTime) 161 if arrivalTime is not None: 162 self.arrivalTime = BookedFlight.getDateTime(date, 163 arrivalTime) 164 165 d = dir(self) 166 for attribute in ["callsign", "departureICAO", "arrivalICAO", 167 "aircraftType", "tailNumber", 168 "numPassengers", "numCrew", 169 "bagWeight", "cargoWeight", "mailWeight", 170 "route", "departureTime", "arrivalTime"]: 171 if attribute not in d: 172 raise Exception("Attribute %s could not be read" % (attribute,)) 173 101 174 def _readAircraftType(self, f): 102 175 """Read the aircraft type from the given file.""" 103 176 line = readline(f) 104 177 typeCode = line[:3] 178 self.aircraftType = self._decodeAircraftType(typeCode) 179 180 def _decodeAircraftType(self, typeCode): 181 """Decode the aircraft type from the given typeCode.""" 105 182 if typeCode in self.TYPECODE2TYPE: 106 self.aircraftType =self.TYPECODE2TYPE[typeCode]183 return self.TYPECODE2TYPE[typeCode] 107 184 else: 108 185 raise Exception("Invalid aircraft type code: '" + typeCode + "'") … … 346 423 iso88592decoder = codecs.getdecoder("iso-8859-2") 347 424 348 def __init__(self, callback, pilotID, password ):425 def __init__(self, callback, pilotID, password, entranceExam): 349 426 """Construct the login request with the given pilot ID and 350 427 password.""" … … 353 430 self._pilotID = pilotID 354 431 self._password = password 432 self._entranceExam = entranceExam 355 433 356 434 def run(self): … … 364 442 password = md5.hexdigest() 365 443 366 url = "http://www.virtualairlines.hu/leker2.php?pid=%s&psw=%s" % \ 367 (pilotID, password) 444 if self._entranceExam: 445 url = "http://www.virtualairlines.hu/ellenorzo/getflightplan.php?pid=%s" % \ 446 (pilotID,) 447 else: 448 url = "http://www.virtualairlines.hu/leker2.php?pid=%s&psw=%s" % \ 449 (pilotID, password) 368 450 369 451 result = Result() 452 result.entranceExam = self._entranceExam 370 453 371 454 f = urllib2.urlopen(url, timeout = 10.0) 372 455 373 456 status = readline(f) 374 result.loggedIn = status == ".OK." 457 if self._entranceExam: 458 result.loggedIn = status != "#NOEXAM" 459 else: 460 result.loggedIn = status == ".OK." 375 461 376 462 if result.loggedIn: 377 463 result.pilotID = self._pilotID 378 result.pilotName = self.iso88592decoder(readline(f))[0]379 result.exams = readline(f)380 464 result.flights = [] 381 382 while True: 383 line = readline(f) 384 if not line or line == "#ENDPIREP": break 385 386 flight = BookedFlight(line, f) 387 result.flights.append(flight) 465 # FIXME: this may not be the correct behaviour 466 # for an entrance exam, but the website returns 467 # an error 468 if self._entranceExam: 469 result.pilotName = result.pilotID 470 result.exams = "" 471 else: 472 result.pilotName = self.iso88592decoder(readline(f))[0] 473 result.exams = readline(f) 474 475 while True: 476 line = readline(f) 477 if not line or line == "#ENDPIREP": break 478 479 flight = BookedFlight(line) 480 flight.readFromWeb(f) 481 result.flights.append(flight) 388 482 389 483 result.flights.sort(cmp = lambda flight1, flight2: … … 740 834 self.daemon = True 741 835 742 def login(self, callback, pilotID, password ):836 def login(self, callback, pilotID, password, entranceExam = False): 743 837 """Enqueue a login request.""" 744 self._addRequest(Login(callback, pilotID, password ))838 self._addRequest(Login(callback, pilotID, password, entranceExam)) 745 839 746 840 def getFleet(self, callback):
Note:
See TracChangeset
for help on using the changeset viewer.