Skip to content

Commit c5655eb

Browse files
committed
Fix #35. Propagate error messages through UO cluster
Also, update copyright years in example files.
1 parent cfd8404 commit c5655eb

File tree

6 files changed

+661
-615
lines changed

6 files changed

+661
-615
lines changed

ghpythonremote/examples/GH_python_remote.ghx

Lines changed: 78 additions & 56 deletions
Large diffs are not rendered by default.

ghpythonremote/examples/GH_python_remote_numba.ghx

Lines changed: 348 additions & 347 deletions
Large diffs are not rendered by default.

ghpythonremote/examples/GH_python_remote_plt_example.ghx

Lines changed: 103 additions & 102 deletions
Large diffs are not rendered by default.

ghpythonremote/examples/GH_python_remote_test.ghx

Lines changed: 113 additions & 109 deletions
Large diffs are not rendered by default.

ghpythonremote/examples/GH_to_CPython.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import ghpythonremote
1010
from ghpythonremote.connectors import GrasshopperToPythonRemote
11+
from Grasshopper.Kernel.GH_RuntimeMessageLevel import Error, Warning
1112

1213
local_log_level = getattr(logging, log_level, logging.WARNING)
1314
logger = logging.getLogger("ghpythonremote")
@@ -23,6 +24,8 @@
2324
ROOT = path.abspath(path.dirname(inspect.getfile(ghpythonremote)))
2425
rpyc_server_py = path.join(ROOT, "pythonservice.py")
2526

27+
cluster_comp = ghenv.Component.OnPingDocument().Owner
28+
2629
# Set connection to CLOSED if this is the first run
2730
# and initialize set of linked modules
2831
try:
@@ -43,10 +46,13 @@
4346
pass
4447
remote_python_status = "CLOSED"
4548
lkd_modules = set()
46-
raise RuntimeError(
49+
message = (
4750
"Connection left in an inconsistent state and not returning. Reset "
4851
"everything."
4952
)
53+
if cluster_comp is not None:
54+
cluster_comp.AddRuntimeMessage(Warning, message)
55+
raise RuntimeError(message)
5056

5157
if run:
5258
if not remote_python_status == "OPEN":
@@ -73,6 +79,18 @@
7379
lkd_modules.add(mod)
7480
except ImportError:
7581
gh2py_manager.__exit__(*sys.exc_info())
82+
if cluster_comp is not None:
83+
cluster_comp.AddRuntimeMessage(
84+
Error,
85+
'Could not import module "{}" in remote Python.'.format(mod)
86+
)
87+
raise
88+
except EOFError:
89+
if cluster_comp is not None:
90+
cluster_comp.AddRuntimeMessage(
91+
Error,
92+
'Remote Python has been closed unexpectedly'
93+
)
7694
raise
7795

7896
elif not remote_python_status == "CLOSED":
334 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)