python - Python 绑定到 sysrepo 给出了无效的参数异常
问题描述
我正在尝试将一些现有的 Python 2 代码与sysrepo
OpenWrt 中的包绑定。Python 绑定使用 SWIG 与底层 C/C++ 交互。
我尝试通过调用该Session.set_item()
函数来创建一个 YANG 对象,但出现异常。
但是,请注意删除相同的 YANG 对象可以正常工作。
这是一些失败的代码:
import libsysrepoPython2 as sr
def delete_configuration_ntp(session):
print('Deleting')
session.delete_item('/ietf-system:system/ntp/enabled')
print('Deleted')
def create_configuration_ntp(session, enabled):
print('Creating')
value = sr.Val(enabled, sr.SR_BOOL_T)
print(' boolean value created')
session.set_item('/ietf-system:system/ntp/enabled', value)
print(' boolean value set')
print('Created')
try:
connection = sr.Connection("example_application")
session = sr.Session(connection, sr.SR_DS_RUNNING)
subscribe = sr.Subscribe(session)
delete_configuration_ntp(session)
create_configuration_ntp(session, True)
except Exception as e:
print('Main program exception:', e)
我希望这个 Python2 程序能够工作,但它失败并出现以下异常:
root@OpenWrt:~# python -V
Python 2.7.15
root@OpenWrt:~# ./minimal.py
Deleting
Deleted
Creating
boolean value created
('Main program exception:', RuntimeError('Invalid argument',))
root@OpenWrt:~#
是否有任何指示,例如如何调试 SWIG?
我可以获得有关此异常原因的更多信息吗?
解决方案
推荐阅读
- node.js - [next-auth][error][client_fetch_error] NextAuthJS CredentialsProvider "providers SyntaxError: Unexpected token < in JSON at position 0"
- python - 通过处理 N 行其他 DataFrame 创建新的 DataFrame
- extjs - Extjs 7.4.0 - 过滤器操作符的远程过滤问题
- deck.gl - 如何使用位图图层旋转图像(@deck.gl/layers 库)
- flutter - 如何管理同一集团中的不同国家?扑
- javascript - 单元测试:如何模拟浏览器中的后退按钮单击
- node.js - 为什么要使用扩展运算符将变量扩展到自身?
- linux - 如何使用访问令牌从 Gitlab 推送和拉取 docker 图像
- infinispan - CVE 2021-31917 的修复方法是什么?这仅适用于 infinispan-server 吗?
- c++ - C++ 中构造函数从 char 到 int 的隐式转换