void QgsGrassShell::readStdout( int socket ) { #ifdef QGISDEBUG // QgsDebugMsg("entered."); #endif char buf[4097]; int len; while (( len = read( mFdMaster, buf, 4096 ) ) > 0 ) { // Terminate string buf[len] = '\0'; mStdoutBuffer.append( buf ); } printStdout(); }
//----------------------------------------------------------------------------- void ctkAbstractPythonManager::initPythonQt(int flags) { Q_D(ctkAbstractPythonManager); PythonQt::init(flags); // Python maps SIGINT (control-c) to its own handler. We will remap it // to the default so that control-c works. #ifdef SIGINT signal(SIGINT, SIG_DFL); #endif PythonQtObjectPtr _mainContext = PythonQt::self()->getMainModule(); this->connect(PythonQt::self(), SIGNAL(pythonStdOut(QString)), SLOT(printStdout(QString))); this->connect(PythonQt::self(), SIGNAL(pythonStdErr(QString)), SLOT(printStderr(QString))); PythonQt_init_QtBindings(); QStringList initCode; // Update 'sys.path' initCode << "import sys"; foreach (const QString& path, this->pythonPaths()) { initCode << QString("sys.path.append('%1')").arg(QDir::fromNativeSeparators(path)); } _mainContext.evalScript(initCode.join("\n")); this->preInitialization(); if (d->InitFunction) { (*d->InitFunction)(); } emit this->pythonPreInitialized(); this->executeInitializationScripts(); emit this->pythonInitialized(); }