Mercurial > hg > orthanc-python
annotate Sources/PythonLock.h @ 95:c17cdaf687e3
use debian:buster-slim to compile Windows binaries
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 15 Sep 2021 11:52:30 +0200 |
parents | cbfc72a53970 |
children | eb6ac5a801d1 |
rev | line source |
---|---|
0 | 1 /** |
2 * Python plugin for Orthanc | |
56
23f3099bed47
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
28
diff
changeset
|
3 * Copyright (C) 2020-2021 Osimis S.A., Belgium |
0 | 4 * |
5 * This program is free software: you can redistribute it and/or | |
6 * modify it under the terms of the GNU Affero General Public License | |
7 * as published by the Free Software Foundation, either version 3 of | |
8 * the License, or (at your option) any later version. | |
9 * | |
10 * This program is distributed in the hope that it will be useful, but | |
11 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 * Affero General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU Affero General Public License | |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 **/ | |
18 | |
19 | |
20 #pragma once | |
21 | |
22 #include <orthanc/OrthancCPlugin.h> | |
23 | |
24 #define PY_SSIZE_T_CLEAN /* Make "s#" use Py_ssize_t rather than int. */ | |
26
b0d1308280d8
Added the PYTHON_WINDOWS_USE_RELEASE_LIBS CMake option
Benjamin Golinvaux <bgo@osimis.io>
parents:
0
diff
changeset
|
25 #include "PythonHeaderWrapper.h" |
0 | 26 |
27 #include <boost/noncopyable.hpp> | |
28 #include <string> | |
29 | |
30 class PythonLock : public boost::noncopyable | |
31 { | |
32 private: | |
33 PyGILState_STATE gstate_; | |
34 | |
35 public: | |
36 typedef void (*ModuleClassesInstaller) (PyObject* module); | |
37 | |
38 typedef PyMethodDef* (*ModuleFunctionsInstaller) (); | |
39 | |
40 PythonLock(); | |
41 | |
42 ~PythonLock(); | |
43 | |
44 void ExecuteCommand(const std::string& s); | |
45 | |
46 void ExecuteFile(const std::string& path); | |
47 | |
48 bool HasErrorOccurred(std::string& traceback); | |
49 | |
63
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
50 OrthancPluginErrorCode CheckCallbackSuccess(const std::string& callbackDetails); |
32de70a1e4c7
New functions from the SDK wrapped in Python: CreateDicom, RegisterFindCallback, RegisterMoveCallback
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
56
diff
changeset
|
51 |
0 | 52 static void GlobalInitialize(const std::string& moduleName, |
53 const std::string& exceptionName, | |
54 ModuleFunctionsInstaller moduleFunctions, | |
55 ModuleClassesInstaller moduleClasses, | |
56 bool verbose); | |
57 | |
58 static void GlobalFinalize(); | |
59 | |
60 static void AddSysPath(const std::string& path); | |
61 | |
75
cbfc72a53970
refactoring calls to PythonLock::RaiseException()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
62 static void RaiseException(OrthancPluginErrorCode code); |
28
b2bbb516056e
The "Calling Python..." info logs are disabled if "PythonVerbose" is "false"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
63 |
b2bbb516056e
The "Calling Python..." info logs are disabled if "PythonVerbose" is "false"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
26
diff
changeset
|
64 static void LogCall(const std::string& message); |
0 | 65 }; |