INNER CODE UNIT · Python
_redeem
cipi-sh/cipi · lib/cipi-crowdsec-rescue.py:94
def _redeem(ip: str) -> str:
env = os.environ.copy()
env["CIPI_RESCUE_REDEEM"] = "1"
try:
proc = subprocess.run(
[CIPI, "crowdsec", "redeem", ip],
check=False,
capture_output=True,
text=True,
env=env,
timeout=REDEEM_TIMEOUT,
)
except subprocess.TimeoutExpired as exc:
# redeem rotates the token before it does anything slow, so the new one
# is already in the partial output. Dropping it here would leave the
# operator with a burnt token and no replacement — the mail that also
# carries it is exactly what may be hanging.
sys.stderr.write("redeem timed out after %ss\n" % REDEEM_TIMEOUT)