| 45 | |
| 46 | |
| 47 | def reportable_unexpected_error_msg( |
| 48 | msg="", # type: str |
| 49 | *args, # type: Any |
| 50 | **kwargs # type: Any |
| 51 | ): |
| 52 | # type: (...) -> str |
| 53 | |
| 54 | message = [msg.format(*args, **kwargs), "---", _ASSERT_DETAILS] |
| 55 | pex = os.environ.get("PEX") |
| 56 | if pex: |
| 57 | try: |
| 58 | import json |
| 59 | |
| 60 | from pex.pex_info import PexInfo |
| 61 | |
| 62 | pex_info = PexInfo.from_pex(pex) |
| 63 | pex_info.update(PexInfo.from_env()) |
| 64 | pex_info_json = json.dumps(pex_info.as_json_dict(), indent=2) |
| 65 | except Exception: |
| 66 | pass |
| 67 | else: |
| 68 | message.append("PEX-INFO:") |
| 69 | message.append(pex_info_json) |
| 70 | message.append("---") |
| 71 | message.append(_ASSERT_ADVICE) |
| 72 | |
| 73 | return "\n".join(message) |
| 74 | |
| 75 | |
| 76 | def production_assert( |