(core) Show proper message on empty Excel import, rather than a code error

Summary:
- Previously showed "UnboundLocalError". Now will show:
    Import failed: Failed to parse Excel file.
    Error: No tables found (1 empty tables skipped)
- Also fix logging for import code

Test Plan: Added a test case

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D3396
This commit is contained in:
Dmitry S
2022-04-26 01:50:57 -04:00
parent dcafa96b5b
commit e59dcc142d
4 changed files with 14 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ import sys
sys.path.append('thirdparty')
# pylint: disable=wrong-import-position
import logging
import marshal
import functools
@@ -25,6 +26,9 @@ from imports.register import register_import_parsers
import logger
log = logger.Logger(__name__, logger.INFO)
# Configure logging module to behave similarly to logger. (It may be OK to get rid of logger.)
logging.basicConfig(format="[%(levelname)s] [%(name)s] %(message)s")
def table_data_from_db(table_name, table_data_repr):
if table_data_repr is None:
return actions.TableData(table_name, [], {})