Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug points to database utils #511

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions plugin/teksi_wastewater/utils/database_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import collections
import configparser
import os
import re
from typing import List

from .plugin_utils import logger
Expand Down Expand Up @@ -87,10 +88,13 @@ def read_pgservice(service_name):
# Path for pg_service.conf
if os.environ.get("PGSERVICEFILE"):
PG_CONFIG_PATH = os.environ.get("PGSERVICEFILE")
logger.debug(f"PGSERVICEFILE: {PG_CONFIG_PATH}")
elif os.environ.get("PGSYSCONFDIR"):
PG_CONFIG_PATH = os.path.join(os.environ.get("PGSYSCONFDIR"), "pg_service.conf")
logger.debug(f"PGSYSCONFDIR: {PG_CONFIG_PATH}")
else:
PG_CONFIG_PATH = os.path.expanduser("~/.pg_service.conf")
logger.debug(f"PG_CONFIG_PATH: {PG_CONFIG_PATH}")

config = configparser.ConfigParser()
if os.path.exists(PG_CONFIG_PATH):
Expand Down Expand Up @@ -134,6 +138,8 @@ def get_pgconf_as_psycopg_dsn() -> List[str]:
parts = []
for key in pgconf:
parts.append(f"{key}={pgconf[key]}")
dsn_masked_pwd = re.sub(r"(password=).+", r"\1[PASSWORD]", " ".join(parts))
logger.debug(f"psycopg dsn: {dsn_masked_pwd}")
return " ".join(parts)

@staticmethod
Expand Down