diff --git a/tiled/catalog/adapter.py b/tiled/catalog/adapter.py index 5cfefed36..343fe3df5 100644 --- a/tiled/catalog/adapter.py +++ b/tiled/catalog/adapter.py @@ -1,6 +1,7 @@ import collections import importlib import itertools as it +import logging import operator import os import re @@ -62,6 +63,8 @@ from .explain import ExplainAsyncSession from .utils import compute_structure_id +logger = logging.getLogger(__name__) + DEFAULT_ECHO = bool(int(os.getenv("TILED_ECHO_SQL", "0") or "0")) INDEX_PATTERN = re.compile(r"^[A-Za-z0-9_-]+$") @@ -1281,11 +1284,17 @@ def from_uri( import subprocess # TODO Check if catalog exists. - subprocess.run( + process = subprocess.run( [sys.executable, "-m", "tiled", "catalog", "init", "--if-not-exists", uri], - capture_output=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, check=True, ) + # Capture stdout and stderr from the subprocess and write to logging + stdout = process.stdout.decode() + stderr = process.stderr.decode() + logging.info(f"Subprocess stdout: {stdout}") + logging.error(f"Subprocess stderr: {stderr}") if not SCHEME_PATTERN.match(uri): # Interpret URI as filepath. uri = f"sqlite+aiosqlite:///{uri}"