dmppythonutils.h
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**************************************************************************
* file: dmppythonutils.h
* Author: wanzhongping
* Date: 2021-02-20 16:20:53
* Email: zhongpingw@chinadci.com
* copyright: 广州城市信息研究所有限公司
***************************************************************************/
#ifndef __dmppythonutils_h__
#define __dmppythonutils_h__
#define BOOST_BIND_GLOBAL_PLACEHOLDERS
#include <boost/python.hpp>
#include "dmpconfig.h"
#include <boost/dll/shared_library.hpp>
#include "dmap_server.h"
#include "../dmpserverinterface.h"
#include <string>
#include <vector>
class SERVER_EXPORT DmpPythonUtils
{
public:
DmpPythonUtils();
~DmpPythonUtils();
void InitServerPython( DmpServerInterface *iface );
bool StartServerPlugin( std::string package_name );
void ExitPython();
bool LoadPlugin(const std::string &package_name);
std::vector<std::string> PluginList();
bool RunString(const std::string &command, bool single = true);
bool EvalString(const std::string &command, std::string &result);
std::string GetPluginMetadata(const std::string &pluginName, const std::string &function);
bool IsEnabled();
std::vector<std::string> ExtraPluginsPaths() const;
std::string PythonPath() const;
std::string PluginsPath() const;
std::string HomePythonPath() const;
std::string HomePluginsPath() const;
protected:
void Init();
bool CheckSystemImports();
void UninstallErrorHook();
boost::python::object main_module_;
boost::python::object main_namespace_;
bool python_enabled_ = false;
//! cleanup Python context
void Finish();
private:
bool error_hook_installed_ = false;
};
#endif //__dmppythonutils_h__