Spaces:
Configuration error
Configuration error
Download examples/PCSWMM_connection_test.py from razaali10/PCSWMM-MCP-Server: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/spaces/razaali10/PCSWMM-MCP-Server/resolve/main/examples/PCSWMM_connection_test.py
- Command line
-
hf download hf://spaces/razaali10/PCSWMM-MCP-Server/examples/PCSWMM_connection_test.py
-
curl -L -o PCSWMM_connection_test.py https://huggingface.co/spaces/razaali10/PCSWMM-MCP-Server/resolve/main/examples/PCSWMM_connection_test.py
1.21 kB
| """PCSWMM Script Editor connection test. | |
| PCSWMM injects pcpy. Do not import pcpy. | |
| """ | |
| def safe_count(collection): | |
| try: | |
| return len(collection) | |
| except Exception: | |
| try: | |
| return int(collection.Count) | |
| except Exception: | |
| return None | |
| try: | |
| swmm = pcpy.SWMM | |
| information = { | |
| "project_open": True, | |
| "project_name": str(swmm.ProjectName), | |
| "project_folder": str(swmm.ProjectFolder), | |
| "model_file": str(swmm.FilePath), | |
| "swmm_version": str(swmm.Version), | |
| "scenario_count": safe_count(swmm.Scenarios), | |
| "node_count": safe_count(swmm.Nodes), | |
| "link_count": safe_count(swmm.Links), | |
| "subcatchment_count": safe_count(swmm.Subcatchments), | |
| "storage_count": safe_count(swmm.Storages), | |
| "outfall_count": safe_count(swmm.Outfalls), | |
| } | |
| except Exception as exc: | |
| information = { | |
| "project_open": False, | |
| "error": str(exc), | |
| } | |
| print("=" * 60) | |
| print("PCSWMM CONNECTION TEST") | |
| print("=" * 60) | |
| for key, value in information.items(): | |
| print("{:<25} {}".format(key, value)) | |
| print("\nCONNECTION STATUS:", "SUCCESS" if information["project_open"] else "FAILED") | |