X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Fpython.cc;h=179e737264e9b0c2da1df04a95d8b029b5a1756f;hb=b9ac2d30cf65fc3147f23d023942b3e6f8a4f29c;hp=2a9a912a2b583bd457b9000bd99078a528bb92a6;hpb=f7a0eb7624fa323a37f9fb0e306d7e1bbc745e15;p=chaz%2Fopenbox diff --git a/src/python.cc b/src/python.cc index 2a9a912a..179e7372 100644 --- a/src/python.cc +++ b/src/python.cc @@ -26,12 +26,12 @@ void python_init(char *argv0) // 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(("sys.path.append('" + + PyRun_SimpleString("sys.path.insert(0, '" SCRIPTDIR "')"); + PyRun_SimpleString(const_cast(("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()"); @@ -45,13 +45,14 @@ void python_init(char *argv0) 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(path.c_str()));