1

I'm trying to bind some existing Python 2 code with the sysrepo package in OpenWrt. The Python binding uses SWIG to interface with the underlying C/C++.

I try to create a YANG object by calling the Session.set_item() function, but I get an exception.

However, note that deleting the same YANG object works OK.

Here is some code that fails:

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)

I expect this Python2 program to work, but it fails with an exception as follows:

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:~#

Are there any pointers, e.g. how can I debug SWIG?

Can I get any more information as to the reason for this exception?

NetHead
  • 71
  • 1
  • 10

0 Answers0