Example #1
0
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));
    }
Example #2
0
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));
    }