mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-27 07:30:20 -05:00
Instance.launch and Instance.find now always either return a connected Instance or raise RipsError, so their return type narrows from Optional[Instance] to Instance. In launch(), the unreachable `if pid:` guard around the Popen result and the trailing `return None` are removed; the only failure paths raise RipsError. Update the PythonExamples that previously branched on a None return: - Drop `if resinsight is None: exit(1)` style guards and `if resinsight is not None:` wrappers; dedent the body where applicable. - export_corner_point_grid.py used the None check as a fallback to launch ResInsight; rewrite as try/except rips.RipsError so the fallback still works. - instance_example.py is repurposed as a try/except example for reporting connection failure.
18 lines
715 B
Python
18 lines
715 B
Python
############################################################################
|
|
# This example returns the currently selected cases in ResInsight
|
|
# Because running this script in the GUI takes away the selection
|
|
# This script does not run successfully from within the ResInsight GUI
|
|
# And will need to be run from the command line separately from ResInsight
|
|
############################################################################
|
|
|
|
import rips
|
|
|
|
resinsight = rips.Instance.find()
|
|
cases = resinsight.project.selected_cases()
|
|
|
|
print("Got " + str(len(cases)) + " cases: ")
|
|
for case in cases:
|
|
print(case.name)
|
|
for property in case.available_properties(rips.PropertyType.DYNAMIC_NATIVE):
|
|
print(property)
|