src/dirbs/importer/abstract_importer.py
def _do_final_cleanup(self):
        """An opportunity for an importer to clean up any temporary resources consumed during an import."""
        self._release_import_lock()
        if not self._no_cleanup:
            self._logger.debug('Cleanup: deleting intermediate data files...')
            for fn in self._files_to_delete:
                os.remove(fn)
                self._logger.debug('Deleted intermediate file {0}'.format(fn))
            self._logger.debug('Cleanup: deleted intermediate data files')
            with self._conn.cursor() as cursor:
                remaining_tables_to_delete = copy.copy(self._tables_to_cleanup_list)
                for t in self._tables_to_cleanup_list:
                    try:
                        cursor.execute(sql.SQL('DROP TABLE IF EXISTS {0} CASCADE').format(sql.Identifier(t)))
                        self._conn.commit()
                        remaining_tables_to_delete.remove(t)
                    except:  # noqa: E722
                        for t_not_deleted in remaining_tables_to_delete:
                            self._logger.warn('Failed to drop table {0} due to exception. Please issue '
                                              "\'DROP TABLE IF EXISTS {0}\' manually!".format(t_not_deleted))
                        raise
        else:
            self._logger.warn('Skipping staging tables/intermediate files cleanup due to command-line option')
An opportunity for an importer to clean up any temporary resources consumed during an import.
An opportunity for an importer to clean up any temporary resources consumed during an import.
An opportunity for an importer to clean up any temporary resources consumed during an import .
def _do_final_cleanup(self):
        self._release_import_lock()
        if not self._no_cleanup:
            self._logger.debug('Cleanup: deleting intermediate data files...')
            for fn in self._files_to_delete:
                os.remove(fn)
                self._logger.debug('Deleted intermediate file {0}'.format(fn))
            self._logger.debug('Cleanup: deleted intermediate data files')
            with self._conn.cursor() as cursor:
                remaining_tables_to_delete = copy.copy(self._tables_to_cleanup_list)
                for t in self._tables_to_cleanup_list:
                    try:
                        cursor.execute(sql.SQL('DROP TABLE IF EXISTS {0} CASCADE').format(sql.Identifier(t)))
                        self._conn.commit()
                        remaining_tables_to_delete.remove(t)
                    except:  
                        for t_not_deleted in remaining_tables_to_delete:
                            self._logger.warn('Failed to drop table {0} due to exception. Please issue '
                                              "\'DROP TABLE IF EXISTS {0}\' manually!".format(t_not_deleted))
                        raise
        else:
            self._logger.warn('Skipping staging tables/intermediate files cleanup due to command-line option')
def _do_final_cleanup ( self ) : self . _release_import_lock ( ) if not self . _no_cleanup : self . _logger . debug ( 'Cleanup: deleting intermediate data files...' ) for fn in self . _files_to_delete : os . remove ( fn ) self . _logger . debug ( 'Deleted intermediate file {0}' . format ( fn ) ) self . _logger . debug ( 'Cleanup: deleted intermediate data files' ) with self . _conn . cursor ( ) as cursor : remaining_tables_to_delete = copy . copy ( self . _tables_to_cleanup_list ) for t in self . _tables_to_cleanup_list : try : cursor . execute ( sql . SQL ( 'DROP TABLE IF EXISTS {0} CASCADE' ) . format ( sql . Identifier ( t ) ) ) self . _conn . commit ( ) remaining_tables_to_delete . remove ( t ) except : for t_not_deleted in remaining_tables_to_delete : self . _logger . warn ( 'Failed to drop table {0} due to exception. Please issue ' "\'DROP TABLE IF EXISTS {0}\' manually!" . format ( t_not_deleted ) ) raise else : self . _logger . warn ( 'Skipping staging tables/intermediate files cleanup due to command-line option' )
An opportunity for an importer to clean up any temporary resources consumed during an import.
An opportunity for an importer to clean up any temporary resources consumed during an import .
"""An opportunity for an importer to clean up any temporary resources consumed during an import.""" # noqa: E722
self