@@ -1465,7 +1465,7 @@ def discard_changes(self) -> None:
1465
1465
1466
1466
def rpc_send_ly (
1467
1467
self , rpc_input : libyang .DNode , timeout_ms : int = 0
1468
- ) -> libyang .DNode :
1468
+ ) -> Optional [ libyang .DNode ] :
1469
1469
"""
1470
1470
Send an RPC/action and wait for the result.
1471
1471
@@ -1480,7 +1480,7 @@ def rpc_send_ly(
1480
1480
1481
1481
:returns:
1482
1482
The RPC/action output tree. Allocated dynamically and must be freed by the
1483
- caller.
1483
+ caller. If the RPC/action did not return any output, None is returned.
1484
1484
:raises SysrepoError:
1485
1485
If the RPC/action callback failed.
1486
1486
"""
@@ -1491,7 +1491,7 @@ def rpc_send_ly(
1491
1491
sr_data_p = ffi .new ("sr_data_t **" )
1492
1492
check_call (lib .sr_rpc_send_tree , self .cdata , in_dnode , timeout_ms , sr_data_p )
1493
1493
if not sr_data_p [0 ]:
1494
- raise SysrepoInternalError ( "sr_rpc_send_tree returned NULL" )
1494
+ return None
1495
1495
1496
1496
ctx = self .acquire_context ()
1497
1497
dnode = libyang .DNode .new (ctx , sr_data_p [0 ].tree )
@@ -1515,7 +1515,7 @@ def rpc_send(
1515
1515
include_implicit_defaults : bool = False ,
1516
1516
trim_default_values : bool = False ,
1517
1517
keep_empty_containers : bool = False ,
1518
- ) -> Dict :
1518
+ ) -> Optional [ Dict ] :
1519
1519
"""
1520
1520
Same as rpc_send_ly() but takes a python dictionary and a YANG module name as
1521
1521
input arguments.
@@ -1539,7 +1539,8 @@ def rpc_send(
1539
1539
Include empty (non-presence) containers.
1540
1540
1541
1541
:returns:
1542
- A python dictionary with the RPC/action output tree.
1542
+ A python dictionary with the RPC/action output tree or None if the RPC/action
1543
+ did not return any output.
1543
1544
"""
1544
1545
rpc = {}
1545
1546
libyang .xpath_set (rpc , xpath , input_dict )
@@ -1553,6 +1554,9 @@ def rpc_send(
1553
1554
finally :
1554
1555
in_dnode .free ()
1555
1556
1557
+ if out_dnode is None :
1558
+ return None
1559
+
1556
1560
try :
1557
1561
out_dict = out_dnode .print_dict (
1558
1562
strip_prefixes = strip_prefixes ,
0 commit comments