← back to Wallco Ai
generate_room_mockups: platform-aware psql (sudo -u postgres on prod) — bare psql fails as root on Kamatera
ade7c0b14a90662ab66a61956b2f900abe19d4ce · 2026-05-30 20:57:08 -0700 · Steve Abrams
Files touched
M scripts/generate_room_mockups.py
Diff
commit ade7c0b14a90662ab66a61956b2f900abe19d4ce
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Sat May 30 20:57:08 2026 -0700
generate_room_mockups: platform-aware psql (sudo -u postgres on prod) — bare psql fails as root on Kamatera
---
scripts/generate_room_mockups.py | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/scripts/generate_room_mockups.py b/scripts/generate_room_mockups.py
index 82e1cf3..4dd14ef 100644
--- a/scripts/generate_room_mockups.py
+++ b/scripts/generate_room_mockups.py
@@ -19,8 +19,15 @@ ROOT = Path(__file__).resolve().parent.parent
OUT_DIR = ROOT / 'data' / 'rooms'
OUT_DIR.mkdir(parents=True, exist_ok=True)
+# Platform-aware psql base: on prod (linux) this script runs as root, which has no
+# PG login role — bare `psql dw_unified` exits 2 ("role root does not exist"). Route
+# through the postgres superuser there. On Mac2 the invoking user owns dw_unified, so
+# a plain psql works. (Same fix pattern as publish-gate.py, 2026-05-30.)
+_PSQL = (['sudo','-u','postgres','psql','dw_unified'] if sys.platform.startswith('linux')
+ else ['psql','dw_unified'])
+
def psql(sql):
- r = subprocess.run(['psql','dw_unified','-At','-q'], input=sql, capture_output=True, text=True, check=True, timeout=15)
+ r = subprocess.run(_PSQL + ['-At','-q'], input=sql, capture_output=True, text=True, check=True, timeout=15)
return r.stdout.strip()
def esc(s):
@@ -167,7 +174,7 @@ else:
print(f'Generating {ROOM_TYPES} mockups for top {len(top)} saturated designs')
# Ensure column
-subprocess.run(['psql','dw_unified','-q','-c',
+subprocess.run(_PSQL + ['-q','-c',
'ALTER TABLE all_designs ADD COLUMN IF NOT EXISTS room_mockups JSONB;'], check=True)
# --dry-run: print the planned batch + cost estimate and exit BEFORE any spend.
← e7466ba Add settlement-guard sweep: event-driven removal-only compli
·
back to Wallco Ai
·
TODO: 2026-05-30 session — 4763 rooms shipped free local ful a50db3b →