def fetch_plugin(self): """Downloads the plugin""" url_dict = self.get_configured_url() busy_dlg = dialogs.progressDialog(dlg_title="Retrieving Archive", dlg_msg="Please wait, retrieving archive...") exception_queue = Queue.Queue() fetch_plugin_thd = workerthread.WorkerThread(exception_queue=exception_queue, target=self.model.get_plugin, args=(url_dict,)) fetch_plugin_thd.start() while True: fetch_plugin_thd.join(0.125) busy_dlg.update() if not fetch_plugin_thd.is_alive(): busy_dlg.close() try: exc_type, exc = exception_queue.get(block=False) err_str = str(exc) if len(err_str) == 0: err_str = exc_type.__name__ module_logger.error("Unable to read archive: {0}".format(err_str)) err_msg = "An error occurred while reading the archive:\n{0}".format(err_str) err_dlg = wx.MessageDialog(self.view, message=err_msg, caption="Unable To Read Archive", style=wx.ICON_ERROR) err_dlg.ShowModal() except Queue.Empty: pass break wx.GetApp().Yield()
def run_model(self, model_instance): """Runs the specified POD Model instance in a separate thread.""" exception_queue = Queue.Queue() model_thd = workerthread.WorkerThread(exception_queue=exception_queue, target=model_instance.run) model_thd.start() progress_dlg = dialogs.progressDialog(dlg_title="Running POD Model", dlg_msg="Please wait, running POD Model...") while True: model_thd.join(0.125) progress_dlg.update() if not model_thd.is_alive(): try: exc_type, exc = exception_queue.get(block=False) err_str = str(exc) if len(err_str) == 0: err_str = exc_type.__name__ module_logger.error("Unable to run POD Model: {0}".format(err_str)) err_msg = "An error occurred while running the POD Model:\n{0}".format(err_str) err_dlg = wx.MessageDialog(self.view.parent, message=err_msg, caption="Error In POD Model Execution", style=wx.ICON_ERROR) err_dlg.ShowModal() err_dlg.Destroy() return except Queue.Empty: # No errors occurred, continue processing model_instance.plot1(self.view.axes1) model_instance.plot2(self.view.axes2) if model_instance.data is not None: # Model returned data to display try: self.populate_spreadsheet(self.view.output_grid, model_instance.data) self.view.spreadsheet_nb.ChangeSelection(self.view.output_sheet_page) except MemoryError: # File too large to load module_logger.error("Unable to preview data, file too large to fit in memory.") err_msg = "The file is too large to load." err_dlg = wx.MessageDialog(self.view, message=err_msg, caption="Unable To Preview Data", style=wx.ICON_ERROR) err_dlg.ShowModal() err_dlg.Destroy() if model_instance.results is not None: # Model return output text to display self.view.txtoutput_tc.WriteText(model_instance.results) self.refresh_plots() break finally: progress_dlg.close() wx.GetApp().Yield(True)
def on_about_plugin(self, evt): """Handles the request to retrieve info about the plugin""" busy_dlg = dialogs.progressDialog(dlg_title="Retrieving Archive", dlg_msg="Please wait, retrieving archive...") try: self.fetch_plugin() readme = self.model.get_readme(self.get_configured_url()) text_display_dlg = dialogs.TextDisplayDialog(parent=self.view, text=readme, title='README', style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) text_display_dlg.Show() except Exception as err: module_logger.error("Failed to retrieve plugin README: {0}".format(err)) err_msg = "{0}".format(err) if err_msg == "": err_msg = "An error occurred attempting to retrieve the archive's README file." err_dlg = wx.MessageDialog(self.view, message=err_msg, caption="Unable To Retrieve README", style=wx.ICON_ERROR) err_dlg.ShowModal() err_dlg.Destroy() finally: busy_dlg.close()