Examples of PySystemState


Examples of org.python.core.PySystemState

        throw Py.ImportError("No module named " + name);
    }

    public static PyObject load_module(String name, PyObject file, PyObject filename, PyTuple data) {
        PyObject mod = Py.None;
        PySystemState sys = Py.getSystemState();
        int type = data.__getitem__(2).asInt();
        while(mod == Py.None) {
            String compiledName;
            switch (type) {
                case PY_SOURCE:
                    Object o = file.__tojava__(InputStream.class);
                    if (o == Py.NoConversion) {
                        throw Py.TypeError("must be a file-like object");
                    }

                    // XXX: This should load the accompanying byte code file instead, if it exists
                    String resolvedFilename = sys.getPath(filename.toString());
                    compiledName = org.python.core.imp.makeCompiledFilename(resolvedFilename);
                    if (name.endsWith(".__init__")) {
                        name = name.substring(0, name.length() - ".__init__".length());
                    } else if (name.equals("__init__")) {
                        name = new File(sys.getCurrentWorkingDir()).getName();
                    }

                    File fp = new File(resolvedFilename);
                    long mtime = -1;
                    if (fp.isFile()) {
View Full Code Here

Examples of org.python.core.PySystemState

    public static PyList __all__ = new PyList(new PyString[] { new PyString("compile") });

    public static boolean compile(String filename, String cfile, String dfile) {
        // Resolve relative path names. dfile is only used for error messages and should not be
        // resolved
        PySystemState sys = Py.getSystemState();
        filename = sys.getPath(filename);
        cfile = sys.getPath(cfile);

        File file = new File(filename);
        if (!file.exists()) {
            throw Py.IOError(Errno.ENOENT, Py.newString(filename));
        }
View Full Code Here

Examples of org.python.core.PySystemState

        PyList basic = basicDoDir(jpkg, instantiate, exclpkgs);
        PyList ret = new PyList();

        doDir(this.searchPath, ret, jpkg, instantiate, exclpkgs);

        PySystemState system = Py.getSystemState();

        if (system.getClassLoader() == null) {
            doDir(system.path, ret, jpkg, instantiate, exclpkgs);
        }

        return merge(basic, ret);
    }
View Full Code Here

Examples of org.python.core.PySystemState

    public boolean packageExists(String pkg, String name) {
        if (packageExists(this.searchPath, pkg, name)) {
            return true;
        }

        PySystemState system = Py.getSystemState();

        if (system.getClassLoader() == null
                && packageExists(Py.getSystemState().path, pkg, name)) {
            return true;
        }

        return false;
View Full Code Here

Examples of org.python.core.PySystemState

  protected PyDictionary globals = new PyDictionary();

  public JythonEngine() {
    super("Python", "py");
    PySystemState.initialize();
    PySystemState state = new PySystemState();
    state.setClassLoader(Thread.currentThread().getContextClassLoader());
    Py.setSystemState(state);
  }
View Full Code Here

Examples of org.python.core.PySystemState

    private PythonInterpreter interp;
    private PySystemState sys;

    private void resetInterpreter() {
        interp = new PythonInterpreter(null, new PySystemState());
        sys = Py.getSystemState();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.