From: Dana Jansens Date: Sun, 16 Feb 2003 18:16:55 +0000 (+0000) Subject: supply more information about errors when running scripts X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=93ea4c4d2ea2b1ff3dfee40fb114f3080001e4ce;p=chaz%2Fopenbox supply more information about errors when running scripts --- diff --git a/src/python.cc b/src/python.cc index eb08775e..0741f2da 100644 --- a/src/python.cc +++ b/src/python.cc @@ -35,12 +35,12 @@ void python_destroy() Py_Finalize(); } -bool python_exec(const std::string &path) +int python_exec(const std::string &path) { FILE *rcpyfd = fopen(path.c_str(), "r"); if (!rcpyfd) { fprintf(stderr, _("Unabled to open python file %s\n"), path.c_str()); - return false; + return 1; } //PyRun_SimpleFile(rcpyfd, const_cast(path.c_str())); @@ -51,7 +51,7 @@ bool python_exec(const std::string &path) assert(dict); PyObject *result = PyRun_File(rcpyfd, const_cast(path.c_str()), Py_file_input, dict, dict); - bool ret = result != NULL; + int ret = result == NULL ? 2 : 0; if (result == NULL) PyErr_Print(); diff --git a/src/python.hh b/src/python.hh index 8c383904..f1d701a8 100644 --- a/src/python.hh +++ b/src/python.hh @@ -231,7 +231,8 @@ typedef void (*EventCallback)(EventData*, void*); void python_init(char *argv0); void python_destroy(); -bool python_exec(const std::string &path); +//! Returns 0 for success, 1 for failing to open the file, 2 for an exception +int python_exec(const std::string &path); #endif // SWIG