virtual void threadProc() { PythonInterpreter* interp = SystemManager::instance()->getScriptInterpreter(); while(!SystemManager::instance()->isExitRequested()) { osleep(100); String line; #ifdef OMEGA_READLINE_FOUND String prompt = ostr("%1%>>", %SystemManager::instance()->getApplication()->getName()); char *inp_c = readline(prompt.c_str()); //Instead of getline() // THE COMMAND OF DEATH if(inp_c[0] == 'D' && inp_c[1] == 'I' && inp_c[2] == 'E') exit(-1); line = (const char *)(inp_c); //Because C strings stink if(strlen(inp_c) != 0) { add_history(inp_c); } free(inp_c); #else getline(std::cin, line); #endif //ofmsg("line read: %1%", %line); interp->queueCommand(line); } omsg("Ending console interactive thread"); }
void OmegaViewer::initialize() { // String orunInitScriptName = "default_init.py"; myAppStartFunctionCall = "from euclid import *; from omegaToolkit import *; _onAppStart()"; Config* cfg = SystemManager::instance()->getAppConfig(); if(cfg->exists("config/orun")) { Setting& s = cfg->lookup("config/orun"); orunInitScriptName = Config::getStringValue("initScript", s, orunInitScriptName); myAppStartFunctionCall = Config::getStringValue("appStart", s, myAppStartFunctionCall); } // Initialize the python wrapper module for this class. PythonInterpreter* interp = SystemManager::instance()->getScriptInterpreter(); interp->lockInterpreter(); initomegaViewer(); interp->unlockInterpreter(); // Run the init script. if(orunInitScriptName != "") { interp->runFile(orunInitScriptName, PythonInterpreter::NoRunFlags); } if(myAppStartFunctionCall != "") { interp->eval(myAppStartFunctionCall); } // If a default script passed through -s is missing, but the first argument // to orun is a script (file ends with .py), use that as the script name. if(sDefaultScript == "" && oxargv().size() > 0 && StringUtils::endsWith(oxargv()[0], ".py")) { sDefaultScript = oxargv()[0]; } // If a default script has been passed to orun, queue it's execution through the python // interpreter. Queuing it will make sure the script is launched on all nodes when running // in a cluster environment. if(sDefaultScript != "") { interp->queueCommand(ostr(":r %1%", %sDefaultScript)); }
void OmegaViewer::initialize() { #ifdef omegaVtk_ENABLED omegaVtkPythonApiInit(); #endif omegaToolkitPythonApiInit(); #ifdef cyclops_ENABLED cyclopsPythonApiInit(); #endif // String orunInitScriptName = "default_init.py"; myAppStartFunctionCall = "from euclid import *; from omegaToolkit import *; _onAppStart()"; Config* cfg = SystemManager::instance()->getAppConfig(); if(cfg->exists("config/orun")) { Setting& s = cfg->lookup("config/orun"); orunInitScriptName = Config::getStringValue("initScript", s, orunInitScriptName); myAppStartFunctionCall = Config::getStringValue("appStartFunction", s, myAppStartFunctionCall); } // Initialize the python wrapper module for this class. initomegaViewer(); // Run the init script. PythonInterpreter* interp = SystemManager::instance()->getScriptInterpreter(); if(orunInitScriptName != "") { interp->runFile(orunInitScriptName, PythonInterpreter::NoRunFlags); interp->eval(myAppStartFunctionCall); } // If a default script has been passed to orun, queue it's execution through the python // interpreter. Queuing it will make sure the script is launched on all nodes when running // in a cluster environment. if(sDefaultScript != "") { interp->queueCommand(ostr(":r %1%", %sDefaultScript)); }