Changeset 106:5d81096406c0 for src/mlx


Ignore:
Timestamp:
04/22/12 14:45:55 (13 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

The METAR of the arrival airport is downloaded in the landing stage.

Location:
src/mlx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/flight.py

    r105 r106  
    12121212        self._metar.set_accepts_tab(False)
    12131213        self._metar.set_wrap_mode(gtk.WrapMode.WORD if pygobject else gtk.WRAP_WORD)
     1214        self._metar.get_buffer().connect("changed", self._metarChanged)
    12141215        scrolledWindow.add(self._metar)
    12151216        alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
     
    12201221        self._metarFrame.add(alignment)
    12211222        mainBox.pack_start(self._metarFrame, True, True, 4)
     1223        self.metarEdited = False
    12221224
    12231225        button = self.addButton(gtk.STOCK_GO_BACK)
     
    12351237        return buffer.get_text(buffer.get_start_iter(),
    12361238                               buffer.get_end_iter(), True)       
     1239
     1240    def setMETAR(self, metar):
     1241        """Set the metar."""
     1242        self._metar.get_buffer().set_text(metar)
     1243        self.metarEdited = False
    12371244
    12381245    def activate(self):
     
    12791286            buffer.set_text(metar)
    12801287
     1288        self.metarEdited = False
     1289
    12811290    def _backClicked(self, button):
    12821291        """Called when the Back button is pressed."""
     
    12931302
    12941303        self._wizard.nextPage()
     1304
     1305    def _metarChanged(self, buffer):
     1306        """Called when the METAR has changed."""
     1307        self.metarEdited = True
     1308        self._button.set_sensitive(buffer.get_text(buffer.get_start_iter(),
     1309                                                   buffer.get_end_iter(),
     1310                                                   True)!="")
    12951311
    12961312#-----------------------------------------------------------------------------
     
    21232139        if stage==const.STAGE_TAKEOFF:
    21242140            self._takeoffPage.allowForward()
     2141        elif stage==const.STAGE_LANDING:
     2142            if not self._arrivalBriefingPage.metarEdited:
     2143                print "Downloading arrival METAR again"
     2144                self.gui.webHandler.getMETARs(self._arrivalMETARCallback,
     2145                                              [self._bookedFlight.arrivalICAO])
     2146           
     2147            self._takeoffPage.allowForward()
    21252148        elif stage==const.STAGE_END:
    21262149            self._landingPage.flightEnded()
     
    22172240        """Connect to the simulator."""
    22182241        self.gui.connectSimulator(self._bookedFlight.aircraftType)
     2242
     2243    def _arrivalMETARCallback(self, returned, result):
     2244        """Called when the METAR of the arrival airport is retrieved."""
     2245        gobject.idle_add(self._handleArrivalMETAR, returned, result)
     2246   
     2247    def _handleArrivalMETAR(self, returned, result):
     2248        """Called when the METAR of the arrival airport is retrieved."""
     2249        icao = self._bookedFlight.arrivalICAO
     2250        if returned and icao in result.metars:
     2251            metar = result.metars[icao]
     2252            if metar!="":
     2253                self._arrivalBriefingPage.setMETAR(metar)
    22192254   
    22202255#-----------------------------------------------------------------------------
  • src/mlx/web.py

    r104 r106  
    1414import datetime
    1515import codecs
     16import traceback
    1617import xml.sax
    1718
     
    301302            returned = True
    302303        except Exception, e:
     304            traceback.print_exc()
    303305            result = e
    304306            returned = False
     
    308310        except Exception, e:
    309311            print >> sys.stderr, "web.Handler.Request.perform: callback throwed an exception: " + str(e)
     312            traceback.print_exc()
    310313
    311314#------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.