Exemplo n.º 1
0
    def __init__(self):
        self.DELAY = 1000
        self.search_dialogs = {}
        self.activate_dialogs = {}

        wxgui_api.install_bundled_icon("wxoldalarms", '@oldalarmsdialog',
                                                        ("oldalarms48.png", ))

        organism_alarms_api.install_unique_old_alarms_interface(
                                                self._choose_old_alarms_unique)
        wxgui_api.register_aborted_save_warning(
                    organism_timer_api.get_old_occurrences_search_exception(),
                    "The database cannot be saved while the old "
                    "alarms are being searched and activated.")

        # Enabling and closing do not race, i.e. it's impossible that first a
        # dialog is started to be created, but it's tried to be closed *while*
        # it's creating, *before* it's shown; this is because these two events
        # run sequentially on the same thread, and they both trigger actions
        # on the GUI (creating the dialog and closing it) that run on the main
        # thread, so while the dialog is creating, the call for closing it,
        # even if triggered, has to wait for the dialog to be created
        organism_timer_api.bind_to_search_old_alarms(self._enable_search)
        organism_timer_api.bind_to_search_old_alarms_end(self._disable_search)

        organism_alarms_api.bind_to_activate_alarms_range(
                                                        self._enable_activate)
        organism_alarms_api.bind_to_activate_alarms_range_end(
                                                        self._disable_activate)

        core_api.bind_to_closing_database(self._handle_closing_database)
Exemplo n.º 2
0
    def _continue(self):
        # It's important that the databases are blocked on this thread, and not
        # on the main thread, otherwise the program would hang if some
        # occurrences are activated while the user is performing an action
        core_api.block_databases(block=True)
        search_old_occurrences_event.signal(filename=self.filename,
                                                    last_search=self.exclmint)
        self.state = 0

        while self.state < 1:
            self.search = organism_api.get_occurrences_range(
                                        mint=self.exclmint, maxt=self.whileago,
                                        filenames=(self.filename, ))
            self.state = 2

            # Make sure to bind *after* self.search is instantiated and
            # self.state is set to 2, but *before* it's started
            core_api.bind_to_closing_database(self._handle_closing_database)

            self.search.start()

        if self.state == 1:
            self._abort()
        else:
            self._process_results()

        core_api.release_databases()
Exemplo n.º 3
0
    def _continue(self):
        # It's important that the databases are blocked on this thread, and not
        # on the main thread, otherwise the program would hang if some
        # occurrences are activated while the user is performing an action
        core_api.block_databases(block=True)
        search_old_occurrences_event.signal(filename=self.filename,
                                                    last_search=self.exclmint)
        self.state = 0

        while self.state < 1:
            self.search = organism_api.get_occurrences_range(
                                        mint=self.exclmint, maxt=self.whileago,
                                        filenames=(self.filename, ))
            self.state = 2

            # Make sure to bind *after* self.search is instantiated and
            # self.state is set to 2, but *before* it's started
            core_api.bind_to_closing_database(self._handle_closing_database)

            self.search.start()

        if self.state == 1:
            self._abort()
        else:
            self._process_results()

        core_api.release_databases()
Exemplo n.º 4
0
    def __init__(self):
        self.DELAY = 1000
        self.search_dialogs = {}
        self.activate_dialogs = {}

        wxgui_api.install_bundled_icon("wxoldalarms", '@oldalarmsdialog',
                                       ("oldalarms48.png", ))

        organism_alarms_api.install_unique_old_alarms_interface(
            self._choose_old_alarms_unique)
        wxgui_api.register_aborted_save_warning(
            organism_timer_api.get_old_occurrences_search_exception(),
            "The database cannot be saved while the old "
            "alarms are being searched and activated.")

        # Enabling and closing do not race, i.e. it's impossible that first a
        # dialog is started to be created, but it's tried to be closed *while*
        # it's creating, *before* it's shown; this is because these two events
        # run sequentially on the same thread, and they both trigger actions
        # on the GUI (creating the dialog and closing it) that run on the main
        # thread, so while the dialog is creating, the call for closing it,
        # even if triggered, has to wait for the dialog to be created
        organism_timer_api.bind_to_search_old_alarms(self._enable_search)
        organism_timer_api.bind_to_search_old_alarms_end(self._disable_search)

        organism_alarms_api.bind_to_activate_alarms_range(
            self._enable_activate)
        organism_alarms_api.bind_to_activate_alarms_range_end(
            self._disable_activate)

        core_api.bind_to_closing_database(self._handle_closing_database)
Exemplo n.º 5
0
 def _handle_closing_database(self, kwargs):
     if kwargs['filename'] == self.filename:
         self.abort()
         core_api.bind_to_closing_database(self._handle_closing_database,
                                                                     False)
Exemplo n.º 6
0
 def _handle_closing_database(self, kwargs):
     if kwargs['filename'] == self.filename:
         self.abort()
         core_api.bind_to_closing_database(self._handle_closing_database,
                                                                     False)