|
| 1 | +From f812f6e11517337f7724a77ce745efe87cf53e4c Mon Sep 17 00:00:00 2001 |
| 2 | +From: Dylan McCall <dylan@endlessos.org> |
| 3 | +Date: Wed, 16 Nov 2022 13:49:03 -0800 |
| 4 | +Subject: [PATCH] WIP: Add more logging in channel_import |
| 5 | + |
| 6 | +--- |
| 7 | + kolibri/core/content/utils/channel_import.py | 8 +++++++- |
| 8 | + 1 file changed, 7 insertions(+), 1 deletion(-) |
| 9 | + |
| 10 | +diff --git a/kolibri/core/content/utils/channel_import.py b/kolibri/core/content/utils/channel_import.py |
| 11 | +index f61e843482..23cc652b15 100644 |
| 12 | +--- a/kolibri/core/content/utils/channel_import.py |
| 13 | ++++ b/kolibri/core/content/utils/channel_import.py |
| 14 | +@@ -655,11 +655,15 @@ class ChannelImport(object): |
| 15 | + # keep track of which model is currently being imported |
| 16 | + self.current_model_being_imported = model |
| 17 | + |
| 18 | ++ logger.info("ChannelImport table_import: {}".format(model.__name__)) |
| 19 | ++ |
| 20 | + if self.destination.engine.name == "postgresql": |
| 21 | + result = self.postgres_table_import(model, row_mapper, table_mapper) |
| 22 | + elif self.can_use_sqlite_attach_method(model, table_mapper): |
| 23 | ++ logger.info("ChannelImport using raw_attached_sqlite_table_import") |
| 24 | + result = self.raw_attached_sqlite_table_import(model, table_mapper) |
| 25 | + else: |
| 26 | ++ logger.warning("ChannelImport using sqlite_table_import") |
| 27 | + result = self.sqlite_table_import(model, row_mapper, table_mapper) |
| 28 | + |
| 29 | + self.current_model_being_imported = None |
| 30 | +@@ -845,6 +849,7 @@ class ChannelImport(object): |
| 31 | + def try_attaching_sqlite_database(self): |
| 32 | + # attach the external content database to our primary database so we can directly transfer records en masse |
| 33 | + if self.destination.engine.name == "sqlite": |
| 34 | ++ logger.info("ChannelImport attached sqlite db") |
| 35 | + try: |
| 36 | + self.destination.execute( |
| 37 | + text( |
| 38 | +@@ -852,7 +857,8 @@ class ChannelImport(object): |
| 39 | + ) |
| 40 | + ) |
| 41 | + self._sqlite_db_attached = True |
| 42 | +- except OperationalError: |
| 43 | ++ except OperationalError as error: |
| 44 | ++ logger.warning("ChannelImport failed to attach sqlite db: {}".format(error)) |
| 45 | + # silently ignore if we were unable to attach the database; we'll just fall back to other methods |
| 46 | + pass |
| 47 | + |
| 48 | +-- |
| 49 | +2.38.1 |
| 50 | + |
0 commit comments