← back to Fentucci
add Python catalog refresh script + updated shell wrapper
82ff46bf22030530db1251bdeb1fee0b272acf36 · 2026-06-24 08:46:43 -0700 · Steve Abrams
Files touched
A scripts/refresh-catalog.pyM scripts/refresh-catalog.sh
Diff
commit 82ff46bf22030530db1251bdeb1fee0b272acf36
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Wed Jun 24 08:46:43 2026 -0700
add Python catalog refresh script + updated shell wrapper
---
scripts/refresh-catalog.py | 43 +++++++++++++++++++++++++++++++++++++++++++
scripts/refresh-catalog.sh | 31 +++++--------------------------
2 files changed, 48 insertions(+), 26 deletions(-)
diff --git a/scripts/refresh-catalog.py b/scripts/refresh-catalog.py
new file mode 100644
index 0000000..7857a4d
--- /dev/null
+++ b/scripts/refresh-catalog.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python3
+"""
+refresh-catalog.py — export Fentucci ACTIVE products from dw_unified to products.json
+Run on Kamatera: python3 /root/Projects/Designer-Wallcoverings/DW-Websites/Fentucci/scripts/refresh-catalog.py
+"""
+import subprocess, json, sys, os
+
+SQL = """SELECT row_to_json(p) FROM (
+ SELECT id, title, vendor, handle, dw_sku, mfr_sku,
+ price::numeric as price, image_url, tags,
+ pattern_name, product_type
+ FROM shopify_products
+ WHERE vendor = 'Fentucci' AND status = 'ACTIVE'
+ ORDER BY title
+) p"""
+
+result = subprocess.run(
+ ['sudo', '-u', 'postgres', 'psql', '-d', 'dw_unified', '-t', '-A', '-c', SQL],
+ capture_output=True, text=True
+)
+
+if result.returncode != 0:
+ print(f"[catalog] psql error: {result.stderr}", file=sys.stderr)
+ sys.exit(1)
+
+rows = []
+skipped = 0
+for line in result.stdout.splitlines():
+ line = line.strip()
+ if line:
+ try:
+ rows.append(json.loads(line))
+ except Exception as e:
+ skipped += 1
+ print(f"[catalog] skip line: {e}", file=sys.stderr)
+
+outpath = os.path.join(os.path.dirname(__file__), '..', 'data', 'products.json')
+outpath = os.path.abspath(outpath)
+
+with open(outpath, 'w') as f:
+ json.dump(rows, f)
+
+print(f"[catalog] wrote {len(rows)} products to {outpath}" + (f" ({skipped} skipped)" if skipped else ""))
diff --git a/scripts/refresh-catalog.sh b/scripts/refresh-catalog.sh
index 9ac30b6..cd69a1b 100755
--- a/scripts/refresh-catalog.sh
+++ b/scripts/refresh-catalog.sh
@@ -1,30 +1,9 @@
#!/bin/bash
-# refresh-catalog.sh — pull a fresh products.json snapshot from dw_unified
-# Run on Kamatera: bash /root/Projects/Designer-Wallcoverings/DW-Websites/Fentucci/scripts/refresh-catalog.sh
-
+# refresh-catalog.sh — pull fresh products.json from dw_unified on Kamatera
+# Usage: bash /root/Projects/Designer-Wallcoverings/DW-Websites/Fentucci/scripts/refresh-catalog.sh
set -euo pipefail
DIR="$(cd "$(dirname "$0")/.." && pwd)"
-OUT="$DIR/data/products.json"
-
-echo "[catalog] refreshing from dw_unified → $OUT"
-
-sudo -u postgres psql -d dw_unified -c "
-COPY (
- SELECT json_agg(row_to_json(p)) FROM (
- SELECT
- id, title, vendor, handle, dw_sku, mfr_sku,
- price::numeric as price, image_url, tags,
- pattern_name, product_type
- FROM shopify_products
- WHERE vendor = 'Fentucci' AND status = 'ACTIVE'
- ORDER BY title
- ) p
-) TO STDOUT;
-" > "$OUT"
-
-COUNT=$(python3 -c "import json,sys; d=json.load(open('$OUT')); print(len(d) if isinstance(d,list) else 0)" 2>/dev/null || echo "?")
-echo "[catalog] wrote $COUNT products to $OUT"
-
-# Reload pm2 to pick up new catalog
-pm2 reload fentucci-website 2>/dev/null && echo "[pm2] reloaded" || echo "[pm2] not running — start manually"
+echo "[catalog] refreshing from dw_unified → $DIR/data/products.json"
+python3 "$DIR/scripts/refresh-catalog.py"
+pm2 reload fentucci-website 2>/dev/null && echo "[pm2] reloaded" || echo "[pm2] not running"
← 7c3fc1b initial scaffold: Fentucci DW-spec storefront (358 ACTIVE SK
·
back to Fentucci
·
add 6 large room-setting hero renders (1344x768, Gemini 2.5 0be89e6 →