view Sphinx/source/plugins/python/listening-changes.py @ 1089:b152822fc3cd

typo
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 03 Jul 2024 18:36:15 +0200
parents a589668768d7
children
line wrap: on
line source

import orthanc

def OnChange(changeType, level, resource):
    if changeType == orthanc.ChangeType.ORTHANC_STARTED:
        print('Started')

        with open('/tmp/sample.dcm', 'rb') as f:
            orthanc.RestApiPost('/instances', f.read())

    elif changeType == orthanc.ChangeType.ORTHANC_STOPPED:
        print('Stopped')

    elif changeType == orthanc.ChangeType.NEW_INSTANCE:
        print('A new instance was uploaded: %s' % resource)

orthanc.RegisterOnChangeCallback(OnChange)