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)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.