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.
29 lines
898 B
Python
29 lines
898 B
Python
#############################################################
|
|
# This example will alter the views of all cases
|
|
# By setting the background color and toggle the grid box
|
|
# Also clones the first view
|
|
#############################################################
|
|
import rips
|
|
|
|
# Connect to ResInsight instance
|
|
resinsight = rips.Instance.find()
|
|
|
|
# Get a list of all cases
|
|
cases = resinsight.project.cases()
|
|
for case in cases:
|
|
# Get a list of all views
|
|
views = case.views()
|
|
for view in views:
|
|
# Set some parameters for the view
|
|
view.show_grid_box = not view.show_grid_box
|
|
view.background_color = "#3388AA"
|
|
# Update the view in ResInsight
|
|
view.update()
|
|
# Clone the first view
|
|
new_view = views[0].clone()
|
|
new_view.background_color = "#FFAA33"
|
|
new_view.update()
|
|
view.show_grid_box = False
|
|
view.set_visible(False)
|
|
view.update()
|