comparison Sources/StorageArea.cpp @ 171:c8de83fe7faa

removed deprecation warnings
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 27 Jun 2024 15:52:51 +0200
parents 6fada29b6759
children 2db6c1f6417f
comparison
equal deleted inserted replaced
170:b49eeb36cd0d 171:c8de83fe7faa
38 PythonObject result(lock, PyObject_CallObject(callback, args.GetPyObject())); 38 PythonObject result(lock, PyObject_CallObject(callback, args.GetPyObject()));
39 39
40 std::string traceback; 40 std::string traceback;
41 if (lock.HasErrorOccurred(traceback)) 41 if (lock.HasErrorOccurred(traceback))
42 { 42 {
43 OrthancPlugins::LogError("Error in the Python " + name + " callback, traceback:\n" + traceback); 43 ORTHANC_PLUGINS_LOG_ERROR("Error in the Python " + name + " callback, traceback:\n" + traceback);
44 return OrthancPluginErrorCode_Plugin; 44 return OrthancPluginErrorCode_Plugin;
45 } 45 }
46 else 46 else
47 { 47 {
48 return OrthancPluginErrorCode_Success; 48 return OrthancPluginErrorCode_Success;
103 PythonObject result(lock, PyObject_CallObject(readCallback_, args.GetPyObject())); 103 PythonObject result(lock, PyObject_CallObject(readCallback_, args.GetPyObject()));
104 104
105 std::string traceback; 105 std::string traceback;
106 if (lock.HasErrorOccurred(traceback)) 106 if (lock.HasErrorOccurred(traceback))
107 { 107 {
108 OrthancPlugins::LogError("Error in the Python StorageRead callback, traceback:\n" + traceback); 108 ORTHANC_PLUGINS_LOG_ERROR("Error in the Python StorageRead callback, traceback:\n" + traceback);
109 return OrthancPluginErrorCode_Plugin; 109 return OrthancPluginErrorCode_Plugin;
110 } 110 }
111 else if (!PyBytes_Check(result.GetPyObject())) 111 else if (!PyBytes_Check(result.GetPyObject()))
112 { 112 {
113 OrthancPlugins::LogError("The Python StorageRead callback has not returned a byte array as expected"); 113 ORTHANC_PLUGINS_LOG_ERROR("The Python StorageRead callback has not returned a byte array as expected");
114 return OrthancPluginErrorCode_Plugin; 114 return OrthancPluginErrorCode_Plugin;
115 } 115 }
116 else 116 else
117 { 117 {
118 char* pythonBuffer = NULL; 118 char* pythonBuffer = NULL;
119 Py_ssize_t pythonSize = 0; 119 Py_ssize_t pythonSize = 0;
120 if (PyBytes_AsStringAndSize(result.GetPyObject(), &pythonBuffer, &pythonSize) == 1) 120 if (PyBytes_AsStringAndSize(result.GetPyObject(), &pythonBuffer, &pythonSize) == 1)
121 { 121 {
122 OrthancPlugins::LogError("Cannot access the byte buffer returned by the Python StorageRead callback"); 122 ORTHANC_PLUGINS_LOG_ERROR("Cannot access the byte buffer returned by the Python StorageRead callback");
123 return OrthancPluginErrorCode_Plugin; 123 return OrthancPluginErrorCode_Plugin;
124 } 124 }
125 else 125 else
126 { 126 {
127 if (pythonSize == 0) 127 if (pythonSize == 0)
202 PyErr_SetString(PyExc_RuntimeError, "Cannot register twice a custom storage area"); 202 PyErr_SetString(PyExc_RuntimeError, "Cannot register twice a custom storage area");
203 return NULL; 203 return NULL;
204 } 204 }
205 else 205 else
206 { 206 {
207 OrthancPlugins::LogInfo("Registering a custom storage area in Python"); 207 ORTHANC_PLUGINS_LOG_INFO("Registering a custom storage area in Python");
208 208
209 OrthancPluginRegisterStorageArea(OrthancPlugins::GetGlobalContext(), 209 OrthancPluginRegisterStorageArea(OrthancPlugins::GetGlobalContext(),
210 StorageCreate, StorageRead, StorageRemove); 210 StorageCreate, StorageRead, StorageRemove);
211 211
212 createCallback_ = a; 212 createCallback_ = a;