mirror of https://github.com/Icinga/icinga2.git
Pass argc and argv to the Python interpreter.
This commit is contained in:
parent
4a89f69990
commit
d3928a7e69
|
@ -140,6 +140,10 @@ int main(int argc, char **argv)
|
|||
* in the base library. */
|
||||
Application::SetMainThread();
|
||||
|
||||
/* Set command-line arguments. */
|
||||
Application::SetArgC(argc);
|
||||
Application::SetArgV(argv);
|
||||
|
||||
/* Install exception handlers to make debugging easier. */
|
||||
Application::InstallExceptionHandlers();
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ String Application::m_PrefixDir;
|
|||
String Application::m_LocalStateDir;
|
||||
String Application::m_PkgLibDir;
|
||||
String Application::m_PkgDataDir;
|
||||
int Application::m_ArgC;
|
||||
char **Application::m_ArgV;
|
||||
|
||||
/**
|
||||
* Constructor for the Application class.
|
||||
|
@ -87,6 +89,26 @@ Application::Ptr Application::GetInstance(void)
|
|||
return Application::Ptr();
|
||||
}
|
||||
|
||||
int Application::GetArgC(void)
|
||||
{
|
||||
return m_ArgC;
|
||||
}
|
||||
|
||||
void Application::SetArgC(int argc)
|
||||
{
|
||||
m_ArgC = argc;
|
||||
}
|
||||
|
||||
char **Application::GetArgV(void)
|
||||
{
|
||||
return m_ArgV;
|
||||
}
|
||||
|
||||
void Application::SetArgV(char **argv)
|
||||
{
|
||||
m_ArgV = argv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs one iteration of the event loop.
|
||||
*
|
||||
|
|
|
@ -48,6 +48,12 @@ public:
|
|||
*/
|
||||
virtual int Main(void) = 0;
|
||||
|
||||
static int GetArgC(void);
|
||||
static void SetArgC(int argc);
|
||||
|
||||
static char **GetArgV(void);
|
||||
static void SetArgV(char **argv);
|
||||
|
||||
static void InstallExceptionHandlers(void);
|
||||
|
||||
static void RequestShutdown(void);
|
||||
|
@ -89,7 +95,8 @@ private:
|
|||
|
||||
static bool m_ShuttingDown; /**< Whether the application is in the process of
|
||||
shutting down. */
|
||||
vector<String> m_Arguments; /**< Command-line arguments */
|
||||
static int m_ArgC; /**< The number of command-line arguments. */
|
||||
static char **m_ArgV; /**< Command-line arguments. */
|
||||
FILE *m_PidFile; /**< The PID file */
|
||||
static bool m_Debugging; /**< Whether debugging is enabled. */
|
||||
static boost::thread::id m_MainThreadID; /**< ID of the main thread. */
|
||||
|
|
|
@ -29,7 +29,11 @@ PythonLanguage::PythonLanguage(void)
|
|||
Py_Initialize();
|
||||
PyEval_InitThreads();
|
||||
|
||||
//PySys_SetArgv(argc, argv);
|
||||
Py_SetProgramName(Application::GetArgV()[0]);
|
||||
PySys_SetArgv(Application::GetArgC(), Application::GetArgV());
|
||||
|
||||
// See http://docs.python.org/2/c-api/init.html for an explanation.
|
||||
PyRun_SimpleString("import sys; sys.path.pop(0)\n");
|
||||
|
||||
m_MainThreadState = PyThreadState_Get();
|
||||
|
||||
|
|
Loading…
Reference in New Issue