// initialize the C python module
init_otk();
init_ob();
- // include the openbox directories for python scripts in the sys path
+ // prepend the openbox directories for python scripts to the sys path
PyRun_SimpleString("import sys");
- PyRun_SimpleString(const_cast<char*>(("sys.path.append('" +
+ PyRun_SimpleString("sys.path.insert(0, '" SCRIPTDIR "')");
+ PyRun_SimpleString(const_cast<char*>(("sys.path.insert(0, '" +
otk::expandTilde("~/.openbox/python") +
"')").c_str()));
- PyRun_SimpleString("sys.path.append('" SCRIPTDIR "')");
PyRun_SimpleString("import ob; import otk; import config;");
// set up convenience global variables
PyRun_SimpleString("ob.openbox = ob.Openbox_instance()");
void python_destroy()
{
- Py_DECREF(obdict);
+ Py_Finalize();
}
bool python_exec(const std::string &path)
{
FILE *rcpyfd = fopen(path.c_str(), "r");
if (!rcpyfd) {
- printf("failed to load python file %s\n", path.c_str());
+ printf("Failed to load python file %s\n", path.c_str());
return false;
}
PyRun_SimpleFile(rcpyfd, const_cast<char*>(path.c_str()));