controller

exception rivia.controller.controller.HecRasComputeError(message, messages=(), com_error=None)[source]

Bases: RuntimeError

Raised when a HEC-RAS computation fails or the COM call errors.

Variables:
  • messages (tuple[str, ...]) – Messages returned by HEC-RAS at the time of failure. Empty when the version does not expose messages or when the error is COM-level.

  • com_error (pywintypes.com_error or None) – The underlying COM exception, if the failure was a COM-level error. None when HEC-RAS returned success=False without a COM error.

Parameters:
rivia.controller.controller.connect(version)[source]

Return a version-appropriate HEC-RAS controller, reusing a live one if available.

If a controller for the requested version is already alive (process running and COM responsive), it is returned directly without killing or relaunching HEC-RAS. Only when no live controller exists is a new one launched; any stale HEC-RAS process for that version is terminated first.

Parameters:

version (str or int) – HEC-RAS version to connect to. Accepts a version string (e.g. "6.3", "5.0.3") or an integer version code (e.g. 6030). Must match an installed HEC-RAS entry in the Windows registry.

Returns:

A controller instance connected to the requested HEC-RAS version. The exact type depends on the resolved version number: _Controller400 for versions below 5000, _Controller500 for 5000-5029, and _Controller503 for 5030 and above.

Return type:

_Controller400 or _Controller500 or _Controller503

Raises:

RuntimeError – If the requested HEC-RAS version is not found in the Windows registry.