Exemplo n.º 1
0
    def Start(self):
        '''Initialize CPA
        '''
        if hasattr(sys, "frozen") and sys.platform == "darwin":
            # Some versions of Macos like to put CPA in a sandbox. If we're frozen Java should be packed in,
            # so let's just figure out the directory on run time.
            os.environ["CP_JAVA_HOME"] = os.path.abspath(
                os.path.join(sys.prefix, "..", "Resources/Home"))
        '''List of tables created by the user during this session'''
        self.user_tables = []

        p = Properties()
        self.frame = MainGUI(p, None, size=(1000, -1))
        self.frame.Show()  # Show frame
        if not p.is_initialized():
            from cpa.guiutils import show_load_dialog
            try:
                if not show_load_dialog():
                    example_link_address = 'cellprofileranalyst.org'
                    dlg = wx.MessageDialog(
                        None,
                        'CellProfiler Analyst requires a properties file. Download an example at %s'
                        % (example_link_address), 'Properties file required',
                        wx.OK)
                    response = dlg.ShowModal()
                    logging.error(
                        'CellProfiler Analyst requires a properties file.')
                    return False
                else:
                    db = DBConnect()
                    db.connect()
                    db.register_gui_parent(self.frame)
            except Exception as e:
                p._initialized = False
                # Fully raising the exception during this startup sequence will crash CPA.
                # So we'll display it manually.
                show_exception_as_dialog(type(e),
                                         e,
                                         e.__traceback__,
                                         raisefurther=False)
                logging.critical(e)

        try:
            from cpa.updatechecker import check_update
            check_update(self.frame, event=False)
        except:
            logging.warn("CPA was unable to check for updates.")
        return True