Class PySystemState

    • Field Detail

      • PYTHON_CACHEDIR_SKIP

        public static final java.lang.String PYTHON_CACHEDIR_SKIP
        See Also:
        Constant Field Values
      • PYTHON_CONSOLE_ENCODING

        public static final java.lang.String PYTHON_CONSOLE_ENCODING
        See Also:
        Constant Field Values
      • PYTHON_IO_ENCODING

        public static final java.lang.String PYTHON_IO_ENCODING
        See Also:
        Constant Field Values
      • PYTHON_IO_ERRORS

        public static final java.lang.String PYTHON_IO_ERRORS
        See Also:
        Constant Field Values
      • version

        public static final PyString version
      • subversion

        public static final PyTuple subversion
      • hexversion

        public static final int hexversion
      • float_repr_style

        public static final PyString float_repr_style
      • py3kwarning

        public static boolean py3kwarning
      • flags

        public static final java.lang.Class flags
      • _mercurial

        public static final PyTuple _mercurial
      • copyright

        public static final PyObject copyright
        The copyright notice for this release.
      • builtin_module_names

        public static PyTuple builtin_module_names
      • registry

        public static java.util.Properties registry
      • prefix

        public static PyObject prefix
        A string giving the site-specific directory prefix where the platform independent Python files are installed; by default, this is based on the property python.home or the location of the Jython JAR. The main collection of Python library modules is installed in the directory prefix/Lib. This object should contain bytes in the file system encoding for consistency with use in the standard library (see sysconfig.py).
      • exec_prefix

        public static PyObject exec_prefix
        A string giving the site-specific directory prefix where the platform-dependent Python files are installed; by default, this is the same as exec_prefix. This object should contain bytes in the file system encoding for consistency with use in the standard library (see sysconfig.py).
      • byteorder

        public static final PyString byteorder
      • argv

        public PyList argv
        The arguments passed to this program on the command line.
      • modules_reloading

        public java.util.Map<java.lang.String,​PyModule> modules_reloading
      • warnoptions

        public PyList warnoptions
      • meta_path

        public PyList meta_path
      • path_hooks

        public PyList path_hooks
      • path_importer_cache

        public PyObject path_importer_cache
      • executable

        public PyObject executable
      • __stdout__

        public PyObject __stdout__
      • __stderr__

        public PyObject __stderr__
      • __displayhook__

        public PyObject __displayhook__
      • __excepthook__

        public PyObject __excepthook__
      • last_value

        public PyObject last_value
      • last_traceback

        public PyObject last_traceback
      • _systemRestart

        public boolean _systemRestart
        true when a SystemRestart is triggered.
      • dont_write_bytecode

        public boolean dont_write_bytecode
        Whether bytecode should be written to disk on import.
      • float_info

        public static final PyObject float_info
      • long_info

        public static final PyObject long_info
    • Constructor Detail

      • PySystemState

        public PySystemState()
    • Method Detail

      • classDictInit

        public static void classDictInit​(PyObject dict)
      • shadow

        @Deprecated
        public void shadow()
        Deprecated.
      • getDefaultBuiltins

        public static PyObject getDefaultBuiltins()
      • getBuiltins

        public PyObject getBuiltins()
      • setBuiltins

        public void setBuiltins​(PyObject value)
      • getWarnoptions

        public PyObject getWarnoptions()
      • setWarnoptions

        public void setWarnoptions​(PyObject value)
      • getPlatform

        public PyObject getPlatform()
      • setPlatform

        public void setPlatform​(PyObject value)
      • getwindowsversion

        public org.python.core.WinVersion getwindowsversion()
      • getImportLock

        public java.util.concurrent.locks.ReentrantLock getImportLock()
      • getSyspathJavaLoader

        public java.lang.ClassLoader getSyspathJavaLoader()
      • __findattr_ex__

        public PyObject __findattr_ex__​(java.lang.String name)
        Description copied from class: PyObject
        Attribute lookup hook. If the attribute is not found, null may be returned or a Py.AttributeError can be thrown, whatever is more correct, efficient and/or convenient for the implementing class. Client code should use PyObject.__getattr__(String) or PyObject.__findattr__(String). Both methods have a clear policy for failed lookups.
        Overrides:
        __findattr_ex__ in class PyObject
        Returns:
        The looked up value. May return null if the attribute is not found
      • __setattr__

        public void __setattr__​(java.lang.String name,
                                PyObject value)
        Description copied from class: PyObject
        A variant of the __setattr__ method which accepts a String as the key. This String must be interned.
        Overrides:
        __setattr__ in class PyObject
        Parameters:
        name - the name whose value will be set - must be an interned string .
        value - the value to set this name to
        See Also:
        PyObject.__setattr__(PyString, PyObject)
      • __delattr__

        public void __delattr__​(java.lang.String name)
        Description copied from class: PyObject
        A variant of the __delattr__ method which accepts a String as the key. This String must be interned. By default, this will call __delattr__(PyString name) with the appropriate args. The only reason to override this method is for performance.
        Overrides:
        __delattr__ in class PyObject
        Parameters:
        name - the name which will be removed - must be an interned string .
        See Also:
        PyObject.__delattr__(PyString)
      • __rawdir__

        public void __rawdir__​(PyDictionary accum)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class PyObject
      • getrecursionlimit

        public int getrecursionlimit()
      • setrecursionlimit

        public void setrecursionlimit​(int recursionlimit)
      • settrace

        public void settrace​(PyObject tracefunc)
      • getprofile

        public PyObject getprofile()
      • setprofile

        public void setprofile​(PyObject profilefunc)
      • getdefaultencoding

        public PyString getdefaultencoding()
      • setdefaultencoding

        public void setdefaultencoding​(java.lang.String encoding)
      • getfilesystemencoding

        public PyObject getfilesystemencoding()
      • getcheckinterval

        public PyInteger getcheckinterval()
      • setcheckinterval

        public void setcheckinterval​(int interval)
      • setCurrentWorkingDir

        public void setCurrentWorkingDir​(java.lang.String path)
        Change the current working directory to the specified path. path is assumed to be absolute and canonical (via os.path.realpath).
        Parameters:
        path - a path String
      • getCurrentWorkingDir

        public java.lang.String getCurrentWorkingDir()
        Return a string representing the current working directory.
        Returns:
        a path String
      • getPath

        public java.lang.String getPath​(java.lang.String path)
        Resolve a path. Returns the full path taking the current working directory into account.
        Parameters:
        path - a path String
        Returns:
        a resolved path String
      • getPathLazy

        public static java.lang.String getPathLazy​(java.lang.String path)
        Resolve a path. Returns the full path taking the current working directory into account. Like getPath but called statically. The current PySystemState is only consulted for the current working directory when it's necessary (when the path is relative).
        Parameters:
        path - a path String
        Returns:
        a resolved path String
      • getFile

        public java.io.File getFile​(java.lang.String path)
        Resolve a path, returning a File, taking the current working directory into account.
        Parameters:
        path - a path String
        Returns:
        a resolved File
      • getClassLoader

        public java.lang.ClassLoader getClassLoader()
      • setClassLoader

        public void setClassLoader​(java.lang.ClassLoader classLoader)
      • getNativePlatform

        public static java.lang.String getNativePlatform()
        Emulates CPython's way to name sys.platform.
      • getBaseProperties

        public static java.util.Properties getBaseProperties()
      • initialize

        public static void initialize()
      • initialize

        public static void initialize​(java.util.Properties preProperties,
                                      java.util.Properties postProperties)
      • initialize

        public static void initialize​(java.util.Properties preProperties,
                                      java.util.Properties postProperties,
                                      java.lang.String[] argv)
      • initialize

        public static void initialize​(java.util.Properties preProperties,
                                      java.util.Properties postProperties,
                                      java.lang.String[] argv,
                                      java.lang.ClassLoader classLoader)
      • initialize

        public static void initialize​(java.util.Properties preProperties,
                                      java.util.Properties postProperties,
                                      java.lang.String[] argv,
                                      java.lang.ClassLoader classLoader,
                                      ExtensiblePyObjectAdapter adapter)
      • doInitialize

        public static PySystemState doInitialize​(java.util.Properties preProperties,
                                                 java.util.Properties postProperties,
                                                 java.lang.String[] argv,
                                                 java.lang.ClassLoader classLoader,
                                                 ExtensiblePyObjectAdapter adapter)
      • isPackageCacheEnabled

        public static boolean isPackageCacheEnabled()
      • getBuiltin

        public static java.lang.String getBuiltin​(java.lang.String name)
      • add_package

        public static PyJavaPackage add_package​(java.lang.String n)
      • add_package

        public static PyJavaPackage add_package​(java.lang.String n,
                                                java.lang.String contents)
      • add_classdir

        public static void add_classdir​(java.lang.String directoryPath)
        Add a classpath directory to the list of places that are searched for java packages.

        Note. Classes found in directory and sub-directory are not made available to jython by this call. It only makes the java package found in the directory available. This call is mostly useful if jython is embedded in an application that deals with its own class loaders. A servlet container is a very good example. Calling add_classdir("/WEB-INF/classes") makes the java packages in WEB-INF classes available to jython import. However the actual classloading is completely handled by the servlet container's context classloader.

      • add_extdir

        public static void add_extdir​(java.lang.String directoryPath)
        Add a .jar & .zip directory to the list of places that are searched for java .jar and .zip files. The .jar and .zip files found will not be cached.

        Note. Classes in .jar and .zip files found in the directory are not made available to jython by this call. See the note for add_classdir(dir) for more details.

        Parameters:
        directoryPath - The name of a directory.
        See Also:
        add_classdir(java.lang.String)
      • add_extdir

        public static void add_extdir​(java.lang.String directoryPath,
                                      boolean cache)
        Add a .jar & .zip directory to the list of places that are searched for java .jar and .zip files.

        Note. Classes in .jar and .zip files found in the directory are not made available to jython by this call. See the note for add_classdir(dir) for more details.

        Parameters:
        directoryPath - The name of a directory.
        cache - Controls if the packages in the zip and jar file should be cached.
        See Also:
        add_classdir(java.lang.String)
      • exit

        public static void exit​(PyObject status)
        Exit a Python program with the given status.
        Parameters:
        status - the value to exit with
        Throws:
        Py.SystemExit - always throws this exception. When caught at top level the program will exit.
      • exit

        public static void exit()
        Exit a Python program with the status 0.
      • exc_info

        public static PyTuple exc_info()
      • exc_clear

        public static void exc_clear()
      • _getframe

        public static PyFrame _getframe()
      • _getframe

        public static PyFrame _getframe​(int depth)
      • _current_frames

        public static PyDictionary _current_frames()
      • registerCloser

        public void registerCloser​(java.util.concurrent.Callable<java.lang.Void> resourceCloser)
      • unregisterCloser

        public boolean unregisterCloser​(java.util.concurrent.Callable<java.lang.Void> resourceCloser)
      • cleanup

        public void cleanup()
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
      • getSystemVersionString

        public static java.lang.String getSystemVersionString()
        Backed as follows: Windows: cmd.exe /C ver (part after "Windows") Other: uname -v