예제 #1
0
 def _find_ctrl(self, parent, name=None, label=None, wxid=None, pos=None, wx_classname=None):
     try:
         self.find_wx_ctrl(parent, name, label, wxid, pos, wx_classname)
         self.find_win_ctrl(parent, name, label, wxid, pos, wx_classname)
     except Found, ex:
         Logger.add_debug(ex.message)
         return
예제 #2
0
 def _test(self):
     Logger.set_path(self.manuscript.get_log_path())
     Logger.set_log_dialog_descriptions(self.appargs.log_dialog_descriptions())
     Logger.add_debug("Application arguments")
     Logger.add_debug(" ".join(sys.argv))
     Logger.add_section("Manuscript", u"%s" % self.manuscript)
     instructions = Instructions(self.manuscript, self.appargs.timedelay())
     start_app(instructions, self.appargs.program())
예제 #3
0
 def _test(self):
     Logger.set_path(self.manuscript.get_log_path())
     Logger.set_log_dialog_descriptions(
         self.appargs.log_dialog_descriptions())
     Logger.add_debug("Application arguments")
     Logger.add_debug(" ".join(sys.argv))
     Logger.add_section("Manuscript", u"%s" % self.manuscript)
     instructions = Instructions(self.manuscript, self.appargs.timedelay())
     start_app(instructions, self.appargs.program())
예제 #4
0
 def register_dialog(self, win=None):
     if win is None:
         return
     Logger.add_debug("Registering window: %s" % win)
     self.windows.append(win)
     if not self.execution_started:
         Logger.add_instruction("Execution of instructions start")
         self.execution_started = True
         wx.CallLater(TIME_TO_WAIT_BEFORE_CONTINUING_IN_MILLISECONDS, self.execute_next_instruction)
예제 #5
0
 def find_menu(self, args):
     try:
         win = wx.GetApp().GetTopWindow()
         item_id = self._find_menu_item_id(args)
         if item_id != wx.NOT_FOUND:
             self.item_id = item_id
             raise Found("Menu found")
     except Found, ex:
         Logger.add_debug(ex.message)
         return
예제 #6
0
 def register_dialog(self, win=None):
     if win is None:
         return
     Logger.add_debug("Registering window: %s" % win)
     self.windows.append(win)
     if not self.execution_started:
         Logger.add_instruction("Execution of instructions start")
         self.execution_started = True
         wx.CallLater(TIME_TO_WAIT_BEFORE_CONTINUING_IN_MILLISECONDS,
                      self.execute_next_instruction)
예제 #7
0
 def find_win_by_name_or_label(self, name_or_label):
     self.wxctrl = None
     self.winctrl = None
     try:
         if name_or_label is None:
             self.wxctrl = wx.GetApp().GetTopWindow()
             raise Found("Top window")
         for name in name_or_label.split("|"):
             name = name.strip()
             self.find_wx_win(name, name)
             self.find_win_win(name)
     except Found, ex:
         Logger.add_debug(ex.message)
         return
예제 #8
0
 def execute_next_instruction(self):
     try:
         instruction = self._next_instruction()
         instruction._replace_placeholders()
         self._display_instruction_in_popup_window(instruction)
         if isinstance(instruction, AddPlaceholderInstruction):
             delay = 0
         else:
             # TODO: We have some timing problem so we can't set
             #       waiting time to 0. 40 seems to be ok,
             delay = max(40, self.timedelay * 1000)
         Logger.add_debug("Preparing instruction '%s' for execution with delay %d" % (instruction, delay))
         wx.CallLater(delay, self._execute_instruction, instruction)
     except NoMoreInstructionsException:
         Logger.add_instruction("The last instruction has been executed")
예제 #9
0
 def execute_next_instruction(self):
     try:
         instruction = self._next_instruction()
         instruction._replace_placeholders()
         self._display_instruction_in_popup_window(instruction)
         if isinstance(instruction, AddPlaceholderInstruction):
             delay = 0
         else:
             # TODO: We have some timing problem so we can't set
             #       waiting time to 0. 40 seems to be ok,
             delay = max(40, self.timedelay * 1000)
         Logger.add_debug(
             "Preparing instruction '%s' for execution with delay %d" %
             (instruction, delay))
         wx.CallLater(delay, self._execute_instruction, instruction)
     except NoMoreInstructionsException:
         Logger.add_instruction("The last instruction has been executed")
예제 #10
0
 def _validate_windows(self):
     """Make sure the topmost window in the list self.windows is still
     valid. If not, remove it from the list and continue checking the
     list until the list is exhausted or a valid dialog is found.
     """
     self.windows.reverse()
     while len(self.windows) > 1:
         win = self.windows[0]
         try:
             win.get_label()
             try:
                 if not win.IsShown():
                     self.windows = self.windows[1:]
                 else:
                     break
             except:
                 Logger.add_debug("Window is not visible")
                 break
         except:
             Logger.add_debug("get_window_text fails")
             self.windows = self.windows[1:]
     self.windows.reverse()
예제 #11
0
 def _validate_windows(self):
     """Make sure the topmost window in the list self.windows is still
     valid. If not, remove it from the list and continue checking the
     list until the list is exhausted or a valid dialog is found.
     """
     self.windows.reverse()
     while len(self.windows) > 1:
         win = self.windows[0]
         try:
             win.get_label()
             try:
                 if not win.IsShown():
                     self.windows = self.windows[1:]
                 else:
                     break
             except:
                 Logger.add_debug("Window is not visible")
                 break
         except:
             Logger.add_debug("get_window_text fails")
             self.windows = self.windows[1:]
     self.windows.reverse()
예제 #12
0
def get_environment_path(environment_variable, filename):
    try:
        home = os.environ[environment_variable]
        path = os.path.join(home, filename)
        Logger.add_debug("   Path: %s" % path)
        if os.path.exists(path):
            Logger.add_debug("   Found")
            return path
    except:
        pass
    Logger.add_debug("   Not found")
예제 #13
0
 def _get_current_window(self):
     Logger.add_debug("self.windows: %s" % self.windows)
     self._validate_windows()
     Logger.add_debug("self.windows: %s" % self.windows)
     try:
         current_window = self.windows[-1]
     except:
         current_window = None
     # MessageBox windows seems to to return ok on get_window_text(win.hwnd)
     # even though the dialog is closed!
     # So we remove it here because the only thing you can do is clicking a
     # a button and thereafter the dialog is closed.
     if current_window.messagebox:
         del (self.windows[-1])
     Logger.add_debug("current_window: %s" % current_window)
     return current_window
예제 #14
0
 def _get_current_window(self):
     Logger.add_debug("self.windows: %s" % self.windows)
     self._validate_windows()
     Logger.add_debug("self.windows: %s" % self.windows)
     try:
         current_window = self.windows[-1]
     except:
         current_window = None
     # MessageBox windows seems to to return ok on get_window_text(win.hwnd)
     # even though the dialog is closed!
     # So we remove it here because the only thing you can do is clicking a
     # a button and thereafter the dialog is closed.
     if current_window.messagebox:
         del (self.windows[-1])
     Logger.add_debug("current_window: %s" % current_window)
     return current_window
예제 #15
0
 def execute(self, manuscript, win):
     self.wrapper_win = win
     manuscript.execute_next_instruction()
     Logger.add_debug("Executing instruction '%s'" % (self))
     self._execute()
예제 #16
0
def find_path(manuscript, paths):
    Logger.add_debug("Searching data as given: %s" % manuscript)
    if os.path.exists(manuscript):
        Logger.add_debug("   Found")
        return manuscript
    Logger.add_debug("   Not found")
    Logger.add_debug("Searching data with given paths")
    if len(paths) == 0:
        Logger.add_debug("   No paths given")
    for path in paths:
        Logger.add_debug("   Path: %s" % os.path.join(path, manuscript))
        if os.path.exists(os.path.join(path, manuscript)):
            Logger.add_debug("   Found")
            return os.path.join(path, manuscript)
        Logger.add_debug("   Not found")
    Logger.add_debug("Searching data with environment var paths")
    for envar in ["USER_HOME", "AUTOPILOT_HOME"]:
        path = get_environment_path(envar, manuscript)
        if path is not None:
            return path