Changeset 760:733c148959e9
- Timestamp:
- 02/14/16 09:17:27 (9 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/flight.py
r759 r760 301 301 xscale = 0.0, yscale = 0.0) 302 302 303 table = gtk.Table( 4, 2)303 table = gtk.Table(3, 2) 304 304 table.set_row_spacings(4) 305 305 table.set_col_spacings(32) … … 339 339 table.attach(self._rememberButton, 1, 2, 2, 3, ypadding = 8) 340 340 341 self._entranceExam = gtk.CheckButton(xstr("login_entranceExam"))342 self._entranceExam.set_use_underline(True)343 self._entranceExam.set_tooltip_text(xstr("login_entranceExam_tooltip"))344 self._entranceExam.connect("toggled", self._setControls)345 table.attach(self._entranceExam, 1, 2, 3, 4, ypadding = 12)346 347 341 self.addButton(xstr("button_login_register"), 348 342 clicked = self._registerClicked, … … 357 351 self._loginButton.set_tooltip_text(xstr("login_button_tooltip")) 358 352 359 360 @property361 def entranceExam(self):362 """Get whether an entrance exam is being performed."""363 return self._entranceExam.get_active() and \364 self._pilotID.get_text()!=""365 353 366 354 @property … … 401 389 pilotID = self._pilotID.get_text() 402 390 password = self._password.get_text() 403 entranceExam = self._entranceExam.get_active() 404 self._password.set_sensitive(not entranceExam) 405 self._rememberButton.set_sensitive(password!="" and not entranceExam) 406 self._entranceExam.set_sensitive(pilotID!="") 407 self._loginButton.set_sensitive(pilotID!="" and 408 (password!="" or entranceExam)) 391 self._rememberButton.set_sensitive(password!="") 392 self._loginButton.set_sensitive(pilotID!="" and password!="") 409 393 410 394 def _registerClicked(self, button): … … 422 406 self._wizard.login(self._handleLoginResult, 423 407 self._pilotID.get_text(), 424 self._password.get_text(), 425 self.entranceExam) 408 self._password.get_text()) 426 409 427 410 def _handleLoginResult(self, returned, result): … … 439 422 440 423 config.save() 441 self._wizard.nextPage() 424 if result.rank=="STU": 425 self._wizard.jumpPage("student") 426 else: 427 self._wizard.nextPage() 442 428 443 429 #----------------------------------------------------------------------------- … … 4839 4825 def entranceExam(self): 4840 4826 """Get whether an entrance exam is about to be taken.""" 4841 return self._login Page.entranceExam4827 return self._loginResult is not None and self._loginResult.rank=="STU" 4842 4828 4843 4829 @property … … 5132 5118 #self.setCurrentPage(10) 5133 5119 5134 def login(self, callback, pilotID, password , entranceExam):5120 def login(self, callback, pilotID, password): 5135 5121 """Called when the login button was clicked.""" 5136 5122 self._loginCallback = callback … … 5140 5126 pilotID = loginResult.pilotID 5141 5127 password = loginResult.password 5142 entranceExam = loginResult.entranceExam5143 5128 busyMessage = xstr("reload_busy") 5144 5129 else: … … 5149 5134 5150 5135 self.gui.webHandler.login(self._loginResultCallback, 5151 pilotID, password, 5152 entranceExam = entranceExam) 5136 pilotID, password) 5153 5137 5154 5138 def reloadFlights(self, callback): -
src/mlx/rpc.py
r759 r760 239 239 self._loginCount += 1 240 240 self._sessionID = reply.value["sessionID"] 241 return reply.value["name"]241 return (reply.value["name"], reply.value["rank"]) 242 242 else: 243 243 return None -
src/mlx/web.py
r756 r760 659 659 iso88592decoder = codecs.getdecoder("iso-8859-2") 660 660 661 def __init__(self, callback, pilotID, password , entranceExam):661 def __init__(self, callback, pilotID, password): 662 662 """Construct the login request with the given pilot ID and 663 663 password.""" … … 666 666 self._pilotID = pilotID 667 667 self._password = password 668 self._entranceExam = entranceExam669 668 670 669 def run(self): … … 678 677 password = md5.hexdigest() 679 678 680 if self._entranceExam: 681 url = MAVA_BASE_URL + "/ellenorzo/getflightplan.php?pid=%s" % \ 682 (pilotID,) 683 else: 684 url = MAVA_BASE_URL + "/leker2.php?pid=%s&psw=%s" % \ 685 (pilotID, password) 679 url = MAVA_BASE_URL + "/leker2.php?pid=%s&psw=%s" % (pilotID, password) 686 680 687 681 result = Result() 688 result.entranceExam = self._entranceExam689 682 690 683 f = urllib2.urlopen(url, timeout = 10.0) 691 684 692 685 status = readline(f) 693 if self._entranceExam: 694 result.loggedIn = status != "#NOEXAM" 695 else: 696 result.loggedIn = status == ".OK." 686 result.loggedIn = status == ".OK." 697 687 698 688 if result.loggedIn: 699 689 result.pilotID = self._pilotID 700 690 result.password = self._password 691 result.rank = "FO" 701 692 result.flights = [] 702 # FIXME: this may not be the correct behaviour 703 # for an entrance exam, but the website returns 704 # an error 705 if self._entranceExam: 706 result.pilotName = result.pilotID 707 result.exams = "" 708 else: 709 result.pilotName = self.iso88592decoder(readline(f))[0] 710 result.exams = readline(f) 711 712 while True: 713 line = readline(f) 714 if not line or line == "#ENDPIREP": break 715 716 flight = BookedFlight(line) 717 flight.readFromWeb(f) 718 result.flights.append(flight) 693 694 result.pilotName = self.iso88592decoder(readline(f))[0] 695 result.exams = readline(f) 696 697 while True: 698 line = readline(f) 699 if not line or line == "#ENDPIREP": break 700 701 flight = BookedFlight(line) 702 flight.readFromWeb(f) 703 result.flights.append(flight) 719 704 720 705 result.flights.sort(cmp = lambda flight1, flight2: … … 730 715 class LoginRPC(RPCRequest): 731 716 """An RPC-based login request.""" 732 def __init__(self, client, callback, pilotID, password , entranceExam):717 def __init__(self, client, callback, pilotID, password): 733 718 """Construct the login request with the given pilot ID and 734 719 password.""" … … 737 722 self._pilotID = pilotID 738 723 self._password = password 739 self._entranceExam = entranceExam740 724 741 725 def run(self): 742 726 """Perform the login request.""" 743 727 result = Result() 744 # FIXME: handle the entrance exam case745 result.entranceExam = self._entranceExam746 728 747 729 self._client.setCredentials(self._pilotID, self._password) 748 pilotName= self._client.login()749 result.loggedIn = pilotNameis not None730 loginResult = self._client.login() 731 result.loggedIn = loginResult is not None 750 732 if result.loggedIn: 751 733 result.pilotID = self._pilotID 752 result.pilotName = pilotName 734 result.pilotName = loginResult[0] 735 result.rank = loginResult[1] 753 736 result.password = self._password 754 737 result.flights = self._client.getFlights() … … 1170 1153 self._addRequest(Register(self._rpcClient, callback, registrationData)) 1171 1154 1172 def login(self, callback, pilotID, password , entranceExam = False):1155 def login(self, callback, pilotID, password): 1173 1156 """Enqueue a login request.""" 1174 1157 request = \ 1175 LoginRPC(self._rpcClient, callback, pilotID, password, entranceExam) \ 1176 if self._config.useRPC and not entranceExam \ 1177 else Login(callback, pilotID, password, entranceExam) 1158 LoginRPC(self._rpcClient, callback, pilotID, password) \ 1159 if self._config.useRPC else Login(callback, pilotID, password) 1178 1160 1179 1161 self._addRequest(request)
Note:
See TracChangeset
for help on using the changeset viewer.