static PyObject* py_stdout(PyObject* /*self*/, PyObject* args) { char* msg; int len; int isStderr; if (!PyArg_ParseTuple(args, "s#i", &msg, &len, &isStderr)) { LogWarnCustom("inviwo.Python.py_print", "failed to parse log message"); } else { if (len != 0) { if (!(len == 1 && (msg[0] == '\n' || msg[0] == '\r' || msg[0] == '\0'))) PythonExecutionOutputObservable::getPtr()->pythonExecutionOutputEvent( msg, (isStderr == 0) ? sysstdout : sysstderr); } } Py_RETURN_NONE; }
std::locale getCurrentStdLocale() { std::locale loc; try { // use the system locale provided by Qt #ifdef WIN32 // need to change locale given by Qt from underscore to hyphenated ("sv_SE" to "sv-SE") // although std::locale should only accept locales with underscore, e.g. "sv_SE" std::string localeName(QLocale::system().name().replace('_', '-').toStdString()); #else std::string localeName(QLocale::system().name().toStdString()); #endif loc = std::locale(localeName.c_str()); } catch (std::exception &e) { LogWarnCustom("getStdLocale", "Locale could not be set. " << e.what()); } return loc; }