Coverage for polar/email/react.py: 75%
12 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 12:42 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 12:42 +0000
1import subprocess
2from typing import TYPE_CHECKING
4from polar.config import settings
6if TYPE_CHECKING: 6 ↛ 7line 6 didn't jump to line 7 because the condition on line 6 was never true
7 from .schemas import Email
10def render_email_template(email: "Email") -> str:
11 process = subprocess.Popen(
12 [
13 settings.EMAIL_RENDERER_BINARY_PATH,
14 email.template,
15 email.props.model_dump_json(),
16 ],
17 stdout=subprocess.PIPE,
18 stderr=subprocess.PIPE,
19 )
20 stdout, stderr = process.communicate()
21 if process.returncode != 0: 21 ↛ 22line 21 didn't jump to line 22 because the condition on line 21 was never true
22 raise Exception(f"Error in react-email process: {stderr.decode('utf-8')}")
23 return stdout.decode("utf-8")
26__all__ = ["render_email_template"]