예제 #1
0
void PyInviwo::initPythonCInterface() {
    if (isInit_) return;

    isInit_ = true;
    LogInfo("Python version: " + toString(Py_GetVersion()));
    wchar_t programName[] = L"PyInviwo";
    Py_SetProgramName(programName);
#ifdef WIN32
    Py_NoSiteFlag = 1;
#endif
    Py_InitializeEx(false);

    if (!Py_IsInitialized()) {
        LogError("Python is not Initialized");
        return;
    }

    PyEval_InitThreads();
    mainDict_ = PyDict_New();
    modulesDict_ = PyImport_GetModuleDict();
    importModule("builtins");
    importModule("sys");
    importModule("os");
    importModule("glob");
    importModule("random");


    addModulePath(InviwoApplication::getPtr()->getBasePath() + "/modules/python3/scripts");

    initDefaultInterfaces();

    initOutputRedirector();
}
예제 #2
0
void PyInviwo::initPythonCInterface(Python3Module* module) {
    if (isInit_) return;

    isInit_ = true;
    LogInfo("Python version: " + toString(Py_GetVersion()));
    wchar_t programName[] = L"PyInviwo";
    Py_SetProgramName(programName);

    Py_InitializeEx(false);

    if (!Py_IsInitialized()) {
        LogError("Python is not Initialized");
        return;
    }

    PyEval_InitThreads();
    importModule("builtins");
    importModule("sys");

    dict_ = PyImport_GetModuleDict();
    registerPyModule(&Inviwo_Internals_Module_Def, "inviwo_internal");
    registerPyModule(&Inviwo_Module_Def, "inviwo");

    addModulePath(module->getPath() + "/scripts");
    initOutputRedirector(module);
}
예제 #3
0
// --------------------------------------------------------------------
//  Reads a vox scene file from the stream
// --------------------------------------------------------------------
Bitmap BmpImg::importer(std::istream & source, OptionSet const& options)
{
    // Parse XML format input file into boost::property_tree
    filescope::ImgImporter importModule(source, options, m_handle);

    // Read property tree and load scene
    return importModule.readImageFile();
}
예제 #4
0
파일: VM.cpp 프로젝트: relrod/magpie
  gc<Object> VM::evaluateReplExpression(gc<Expr> expr)
  {
    ErrorReporter reporter;

    if (replModule_ == NULL)
    {
      replModule_ = new Module(String::create("<repl>"), String::create(""));
      modules_.add(replModule_);

      // Implicitly import core.
      importModule(reporter, replModule_, NULL, String::create("core"));
    }

    // Compile it.
    Compiler::compileExpression(*this, reporter, expr, replModule_);
    if (reporter.numErrors() > 0) return gc<Object>();

    return scheduler_.runModule(replModule_);
  }