Skip to content
Open
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
11 changes: 5 additions & 6 deletions src/rapidata/rapidata_client/config/_qr_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ def build_campaign_preview_url(environment: str, campaign_id: str) -> str:


def print_campaign_preview_qr(environment: str, campaign_id: str) -> None:
"""Print a terminal QR code that links to the campaign preview page.
"""Print the preview URL and a terminal QR code linking to it.

Respects ``rapidata_config.logging.silent_mode``. If QR rendering fails for
any reason we still surface the preview URL via ``managed_print`` so the
user can open it manually.
Respects ``rapidata_config.logging.silent_mode``. The URL is always
printed so the user can copy-paste it; the QR code below is a convenience
for opening on a phone. If QR rendering fails the URL stays visible.

Args:
environment: The Rapidata environment (e.g. ``rapidata.ai``).
Expand All @@ -47,6 +47,7 @@ def print_campaign_preview_qr(environment: str, campaign_id: str) -> None:
return

url = build_campaign_preview_url(environment, campaign_id)
managed_print(f"Preview at: {url}")

try:
import qrcode
Expand All @@ -60,15 +61,13 @@ def print_campaign_preview_qr(environment: str, campaign_id: str) -> None:
qr.add_data(url)
qr.make(fit=True)

managed_print(f"Preview:")
qr.print_ascii(invert=True)
except Exception:
logger.warning(
"Failed to render preview QR code for %s",
url,
exc_info=True,
)
managed_print(f"Preview at: {url}")


def _resolve_campaign_id_from_pipeline(
Expand Down
Loading