Changeset 692:eea9d6135944


Ignore:
Timestamp:
10/22/15 18:43:58 (9 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
cef
Phase:
public
Message:

Progress reporting is more detailed and uses translatable strings (re #279)

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • locale/en/mlx.po

    r691 r692  
    741741"your files will be able to read it."
    742742
     743msgid "simbrief_progress_searching_browser"
     744msgstr "Searching browser..."
     745
     746msgid "simbrief_progress_loading_form"
     747msgstr "Loading form..."
     748
     749msgid "simbrief_progress_filling_form"
     750msgstr "Filling form..."
     751
     752msgid "simbrief_progress_waiting_login"
     753msgstr "Waiting login..."
     754
     755msgid "simbrief_progress_logging_in"
     756msgstr "Logging in..."
     757
     758msgid "simbrief_progress_waiting_result"
     759msgstr "Waiting for the result..."
     760
     761msgid "simbrief_progress_retrieving_briefing"
     762msgstr "Retrieving briefing..."
     763
     764msgid "simbrief_progress_unknown"
     765msgstr "?????"
     766
     767msgid "simbrief_result_error_other"
     768msgstr "Some error occured, see debug logs."
     769
     770msgid "simbrief_result_error_no_form"
     771msgstr "No form could be loaded."
     772
     773msgid "simbrief_result_error_no_popup"
     774msgstr "No login window appeared."
     775
     776msgid "simbrief_result_login_failed"
     777msgstr "Login failed."
     778
     779msgid "simbrief_result_unknown"
     780msgstr "Unknown error occured."
     781
     782msgid "simbrief_cancelled"
     783msgstr "Reverting to the old-style briefing."
     784
    743785msgid "briefing_title"
    744786msgstr "Briefing (%d/2): %s"
  • locale/hu/mlx.po

    r691 r692  
    739739"tároljuk, ezért bárki elolvashatja, aki hozzáfér a fájljaidhoz."
    740740
     741msgid "simbrief_progress_searching_browser"
     742msgstr "Böngésző keresése..."
     743
     744msgid "simbrief_progress_loading_form"
     745msgstr "Űrlap letöltése..."
     746
     747msgid "simbrief_progress_filling_form"
     748msgstr "Űrlap kitöltése..."
     749
     750msgid "simbrief_progress_waiting_login"
     751msgstr "Várakozás a bejelentkező ablakra..."
     752
     753msgid "simbrief_progress_logging_in"
     754msgstr "Bejelentkezés..."
     755
     756msgid "simbrief_progress_waiting_result"
     757msgstr "Várakozás az eredményre..."
     758
     759msgid "simbrief_progress_retrieving_briefing"
     760msgstr "Az eligazítás letöltése..."
     761
     762msgid "simbrief_progress_unknown"
     763msgstr "?????"
     764
     765msgid "simbrief_result_error_other"
     766msgstr "Valamilyen hiba történt, lásd a hibanaplót."
     767
     768msgid "simbrief_result_error_no_form"
     769msgstr "Nem sikerült letölteni az űrlapot."
     770
     771msgid "simbrief_result_error_no_popup"
     772msgstr "Nem jelent meg a bejelentkező ablak."
     773
     774msgid "simbrief_result_login_failed"
     775msgstr "A bejelentkezés nem sikerült."
     776
     777msgid "simbrief_result_unknown"
     778msgstr "Ismeretlen hiba történt."
     779
     780msgid "simbrief_cancelled"
     781msgstr "Áttérünk a régi eligazításra."
     782
    741783msgid "briefing_title"
    742784msgstr "Eligazítás (%d/2): %s"
  • src/mlx/gui/cef.py

    r685 r692  
    7777#------------------------------------------------------------------------------
    7878
     79SIMBRIEF_PROGRESS_SEARCHING_BROWSER = MavaSimbriefIntegrator.PROGRESS_SEARCHING_BROWSER
     80SIMBRIEF_PROGRESS_LOADING_FORM = MavaSimbriefIntegrator.PROGRESS_LOADING_FORM
     81SIMBRIEF_PROGRESS_FILLING_FORM = MavaSimbriefIntegrator.PROGRESS_FILLING_FORM
     82SIMBRIEF_PROGRESS_WAITING_LOGIN = MavaSimbriefIntegrator.PROGRESS_WAITING_LOGIN
     83SIMBRIEF_PROGRESS_LOGGING_IN = MavaSimbriefIntegrator.PROGRESS_LOGGING_IN
     84SIMBRIEF_PROGRESS_WAITING_RESULT = MavaSimbriefIntegrator.PROGRESS_WAITING_RESULT
     85
     86SIMBRIEF_PROGRESS_RETRIEVING_BRIEFING = MavaSimbriefIntegrator.PROGRESS_MAX + 1
     87SIMBRIEF_PROGRESS_DONE = 1000
     88
     89SIMBRIEF_RESULT_NONE = MavaSimbriefIntegrator.RESULT_NONE
     90SIMBRIEF_RESULT_OK = MavaSimbriefIntegrator.RESULT_OK
     91SIMBRIEF_RESULT_ERROR_OTHER = MavaSimbriefIntegrator.RESULT_ERROR_OTHER
     92SIMBRIEF_RESULT_ERROR_NO_FORM = MavaSimbriefIntegrator.RESULT_ERROR_NO_FORM
     93SIMBRIEF_RESULT_ERROR_NO_POPUP = MavaSimbriefIntegrator.RESULT_ERROR_NO_POPUP
     94SIMBRIEF_RESULT_ERROR_LOGIN_FAILED = MavaSimbriefIntegrator.RESULT_ERROR_LOGIN_FAILED
     95
     96#------------------------------------------------------------------------------
     97
    7998class SeleniumHandler(threading.Thread):
    8099    """Thread to handle Selenium operations."""
     
    158177                                       local_html_debug = False)
    159178
    160         updateProgress("Retrieving briefing...", False)
    161 
    162         flight_info = integrator.get_results(link,
    163                                              html_file_path = htmlFilePath)
    164 
    165         updateProgress("Done", True)
     179        if link is not None:
     180            updateProgress(SIMBRIEF_PROGRESS_RETRIEVING_BRIEFING,
     181                           SIMBRIEF_RESULT_NONE, None)
     182
     183            try:
     184                flight_info = integrator.get_results(link,
     185                                                     html_file_path =
     186                                                     htmlFilePath)
     187
     188                updateProgress(SIMBRIEF_PROGRESS_DONE,
     189                               SIMBRIEF_RESULT_OK, flight_info)
     190            except Exception, e:
     191                print "Failed retrieving the briefing:", e
     192                updateProgress(SIMBRIEF_PROGRESS_RETRIEVING_BRIEFING,
     193                               SIMBRIEF_RESULT_ERROR_OTHER, None)
    166194
    167195    def _quit(self):
  • src/mlx/gui/flight.py

    r691 r692  
    15431543        self._cruiseLevel.set_text("")
    15441544        self._route.get_buffer().set_text(self._wizard._bookedFlight.route)
     1545        self._alternate.set_text("")
    15451546        self._updateForwardButton()
    15461547
     
    15941595    def _forwardClicked(self, button):
    15951596        """Called when the Forward button is clicked."""
    1596         if self._wizard.gui.config.useSimBrief:
     1597        if self._wizard.gui.config.useSimBrief and \
     1598           self._wizard.usingSimBrief is not False:
    15971599            self._wizard.nextPage()
    15981600        else:
     
    16181620        ]
    16191621
     1622    progress2Message = {
     1623        cef.SIMBRIEF_PROGRESS_SEARCHING_BROWSER: "simbrief_progress_searching_browser",
     1624        cef.SIMBRIEF_PROGRESS_LOADING_FORM: "simbrief_progress_loading_form",
     1625        cef.SIMBRIEF_PROGRESS_FILLING_FORM: "simbrief_progress_filling_form",
     1626        cef.SIMBRIEF_PROGRESS_WAITING_LOGIN: "simbrief_progress_waiting_login",
     1627        cef.SIMBRIEF_PROGRESS_LOGGING_IN: "simbrief_progress_logging_in",
     1628        cef.SIMBRIEF_PROGRESS_WAITING_RESULT: "simbrief_progress_waiting_result",
     1629        cef.SIMBRIEF_PROGRESS_RETRIEVING_BRIEFING: "simbrief_progress_retrieving_briefing"
     1630        }
     1631
     1632    result2Message = {
     1633        cef.SIMBRIEF_RESULT_ERROR_OTHER: "simbrief_result_error_other",
     1634        cef.SIMBRIEF_RESULT_ERROR_NO_FORM: "simbrief_result_error_no_form",
     1635        cef.SIMBRIEF_RESULT_ERROR_NO_POPUP: "simbrief_result_error_no_popup",
     1636        cef.SIMBRIEF_RESULT_ERROR_LOGIN_FAILED: "simbrief_result_error_login_failed"
     1637        }
     1638
    16201639    @staticmethod
    16211640    def getHTMLFilePath():
     
    17381757            startSound(const.SOUND_NOTAM)
    17391758
    1740     def _simBriefProgressCallback(self, message, done):
     1759    def _simBriefProgressCallback(self, progress, result, flightInfo):
    17411760        """Called by the SimBrief handling thread."""
    1742         gobject.idle_add(self._simBriefProgress, message, done)
    1743 
    1744     def _simBriefProgress(self, message, done):
     1761        gobject.idle_add(self._simBriefProgress, progress, result, flightInfo)
     1762
     1763    def _simBriefProgress(self, progress, result, flightInfo):
    17451764        """The real SimBrief progress handler."""
    1746         if done:
     1765        print "_simBriefProgress", progress, result, flightInfo
     1766        if result==cef.SIMBRIEF_RESULT_NONE:
     1767            message = SimBriefSetupPage.progress2Message.get(progress,
     1768                                                             "simbrief_progress_unknown")
     1769            self._wizard.gui.updateBusyState(xstr(message))
     1770        else:
    17471771            self._wizard.gui.endBusy()
    1748             self._wizard.nextPage()
    1749         else:
    1750             self._wizard.gui.updateBusyState(message)
     1772
     1773            if result==cef.SIMBRIEF_RESULT_OK:
     1774                self._wizard.nextPage()
     1775            else:
     1776                message = SimBriefSetupPage.result2Message.get(result,
     1777                                                               "simbrief_result_unknown")
     1778                dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
     1779                                           type = MESSAGETYPE_ERROR,
     1780                                           message_format =
     1781                                           xstr(message) + "\n"+
     1782                                           xstr("simbrief_cancelled"))
     1783
     1784                dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
     1785                dialog.set_title(WINDOW_TITLE_BASE)
     1786                secondary = xstr("flightsel_save_failed_sec")
     1787                dialog.format_secondary_markup(secondary)
     1788                dialog.run()
     1789                dialog.hide()
     1790
     1791                self._wizard.usingSimBrief = False
     1792                self._wizard.jumpPage(2, fromPageShift = 1)
    17511793
    17521794    def _getPlan(self):
     
    39513993        return self._loginResult
    39523994
    3953     def setCurrentPage(self, index, finalize = False):
    3954         """Set the current page to the one with the given index."""
     3995    def setCurrentPage(self, index, finalize = False, fromPageShift = None):
     3996        """Set the current page to the one with the given index.
     3997
     3998        @param fromPageShift if given, the relative index of one of the
     3999        previous pages that should be used as the from-page of the next
     4000        page. E.g. if fromPageShift is 1, the previous page will be the
     4001        from-page."""
    39554002        assert index < len(self._pages)
    39564003
     
    39614008                page.complete()
    39624009            self.remove(page)
     4010            if fromPageShift is not None:
     4011                fromPage -= fromPageShift
    39634012
    39644013        self._currentPage = index
     
    41574206        self.jumpPage(1, finalize)
    41584207
    4159     def jumpPage(self, count, finalize = True):
     4208    def jumpPage(self, count, finalize = True, fromPageShift = None):
    41604209        """Go to the page which is 'count' pages after the current one."""
    4161         self.setCurrentPage(self._currentPage + count, finalize = finalize)
     4210        self.setCurrentPage(self._currentPage + count,
     4211                            finalize = finalize, fromPageShift = fromPageShift)
    41624212
    41634213    def grabDefault(self):
     
    42084258        self._arrivalNOTAMs = None
    42094259        self._arrivalMETAR = None
    4210         self._usingSimBrief = False
     4260        self._usingSimBrief = None
    42114261
    42124262        firstPage = 0 if self._loginResult is None else 1
  • src/mlx/gui/mava_simbrief.py

    r685 r692  
    2121    """Implements the integration with the excellent Simbrief pilot briefing
    2222    system for MALEV Virtual."""
     23
     24    # Progress stage: searching the suitable browser window
     25    PROGRESS_SEARCHING_BROWSER = 1
     26
     27    # Progress stage: retrieving the form from the server
     28    PROGRESS_LOADING_FORM = 2
     29
     30    # Progress stage: filling the form
     31    PROGRESS_FILLING_FORM = 3
     32
     33    # Progress stage: waiting for the login
     34    PROGRESS_WAITING_LOGIN = 4
     35
     36    # Progress stage: logging in
     37    PROGRESS_LOGGING_IN = 5
     38
     39    # Progress stage: waiting for result
     40    PROGRESS_WAITING_RESULT = 6
     41
     42    # The maximal reserved progress stage
     43    PROGRESS_MAX = 16
     44
     45    # Result code: none (i.e. the SimBrief query is in progress).
     46    RESULT_NONE = 0
     47
     48    # Result code: success
     49    RESULT_OK = 1
     50
     51    # Result code: other error
     52    RESULT_ERROR_OTHER = 2
     53
     54    # Result code: form could not be loaded
     55    RESULT_ERROR_NO_FORM = 11
     56
     57    # Result code: no popup (i.e. login) window found
     58    RESULT_ERROR_NO_POPUP = 12
     59
     60    # Result code: login failed
     61    RESULT_ERROR_LOGIN_FAILED = 13
     62
     63    # The maximal reserved result code
     64    RESULT_MAX = 32
    2365
    2466    def __init__(self,
     
    114156            is_briefing_available = True
    115157        else:
    116             update_progress("Looking for a browser...", False)
     158            update_progress(MavaSimbriefIntegrator.PROGRESS_SEARCHING_BROWSER,
     159                            MavaSimbriefIntegrator.RESULT_NONE, None)
    117160            # There must be window whose title is 'SimBrief' so that we
    118161            # could find our one among several
    119162            if self._find_window_by_title("SimBrief") is None:
    120163                print "No SimBrief window was found!"
     164                update_progress(MavaSimbriefIntegrator.PROGRESS_SEARCHING_BROWSER,
     165                                MavaSimbriefIntegrator.RESULT_ERROR_OTHER, None)
    121166                return None
    122167
    123168            # normal operation with a real xml file
    124             update_progress("Retrieving form...", False)
     169            update_progress(MavaSimbriefIntegrator.PROGRESS_LOADING_FORM,
     170                            MavaSimbriefIntegrator.RESULT_NONE, None)
    125171            if local_html_debug:
    126172                self.driver.get(
     
    133179            if main_handle is None:
    134180                print "No SimBrief Integration window was found!"
     181                update_progress(MavaSimbriefIntegrator.PROGRESS_LOADING_FORM,
     182                                MavaSimbriefIntegrator.RESULT_ERROR_NO_FORM, None)
    135183                return None
    136184
     
    140188
    141189            # Entering form data
    142             update_progress("Filling form...", False)
     190            update_progress(MavaSimbriefIntegrator.PROGRESS_FILLING_FORM,
     191                            MavaSimbriefIntegrator.RESULT_NONE, None)
    143192            self.driver.switch_to_window(main_handle)
    144193            self.fill_form(self.plan,
     
    149198            button.send_keys(Keys.RETURN)
    150199
    151             update_progress("Waiting for login...", False)
     200            update_progress(MavaSimbriefIntegrator.PROGRESS_WAITING_LOGIN,
     201                            MavaSimbriefIntegrator.RESULT_NONE, None)
    152202            popup_handle = self._find_popup(handles)
    153203            if popup_handle is None:
    154                 print "No popup window was found!"
     204                update_progress(MavaSimbriefIntegrator.PROGRESS_WAITING_LOGIN,
     205                                MavaSimbriefIntegrator.RESULT_ERROR_NO_POPUP, None)
    155206                return None
    156207
     
    164215
    165216                    if userElement is not None:
    166                         update_progress("Logging in...", False)
     217                        update_progress(MavaSimbriefIntegrator.PROGRESS_LOGGING_IN,
     218                                        MavaSimbriefIntegrator.RESULT_NONE, None)
    167219                        (userName, password) = get_credentials(login_count)
     220                        if userName is None or password is None:
     221                            update_progress(MavaSimbriefIntegrator.PROGRESS_WAITING_LOGIN,
     222                                            MavaSimbriefIntegrator.RESULT_ERROR_LOGIN_FAILED, None)
     223                            return None
     224
    168225                        userElement.send_keys(userName)
    169226                        self.driver.find_element_by_name("pass").send_keys(password)
     
    178235                    pass
    179236
    180                 update_progress("Waiting for the result...", False)
     237                update_progress(MavaSimbriefIntegrator.PROGRESS_WAITING_RESULT,
     238                                MavaSimbriefIntegrator.RESULT_NONE, None)
    181239                self.driver.switch_to.window(main_handle)
    182240                try:
Note: See TracChangeset for help on using the changeset viewer.