Class PySystemState
- java.lang.Object
-
- org.python.core.PyObject
-
- org.python.core.PySystemState
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Serializable,java.lang.AutoCloseable,ClassDictInit,Traverseproc
public class PySystemState extends PyObject implements java.lang.AutoCloseable, ClassDictInit, java.io.Closeable, Traverseproc
The "sys" module.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPySystemState.PySystemStateCloser-
Nested classes/interfaces inherited from class org.python.core.PyObject
PyObject.ConversionException
-
-
Field Summary
Fields Modifier and Type Field Description PyObject__dict__PyObject__displayhook__PyObject__excepthook__PyObject__name__PyObject__stderr__PyObject__stdin__PyObject__stdout__static PyTuple_mercurialboolean_systemRestarttrue when a SystemRestart is triggered.PyListargvThe arguments passed to this program on the command line.static PyTuplebuiltin_module_namesPyObjectbuiltinsstatic PyStringbyteorderstatic PyObjectcopyrightThe copyright notice for this release.booleandont_write_bytecodeWhether bytecode should be written to disk on import.static PyObjectexec_prefixA string giving the site-specific directory prefix where the platform-dependent Python files are installed; by default, this is the same asexec_prefix.PyObjectexecutablestatic java.lang.Classflagsstatic PyObjectfloat_infostatic PyStringfloat_repr_stylestatic inthexversionstatic java.lang.StringJYTHON_DEV_JARstatic java.lang.StringJYTHON_JARPyObjectlast_tracebackPyObjectlast_typePyObjectlast_valuestatic PyObjectlong_infostatic intmaxintstatic intmaxsizestatic intmaxunicodePyListmeta_pathstatic intminintPyObjectmodulesjava.util.Map<java.lang.String,PyModule>modules_reloadingstatic PackageManagerpackageManagerPyListpathPyListpath_hooksPyObjectpath_importer_cachePyObjectplatformstatic PyObjectprefixA string giving the site-specific directory prefix where the platform independent Python files are installed; by default, this is based on the propertypython.homeor the location of the Jython JAR.PyObjectps1PyObjectps2static booleanpy3kwarningstatic java.lang.StringPYTHON_CACHEDIRstatic java.lang.StringPYTHON_CACHEDIR_SKIPstatic java.lang.StringPYTHON_CONSOLE_ENCODINGstatic java.lang.StringPYTHON_IO_ENCODINGstatic java.lang.StringPYTHON_IO_ERRORSstatic java.util.PropertiesregistryPyObjectstderrPyObjectstdinPyObjectstdoutstatic PyTuplesubversionstatic PyStringversionstatic PyVersionInfoversion_infoPyListwarnoptions-
Fields inherited from class org.python.core.PyObject
gcMonitorGlobal, TYPE
-
-
Constructor Summary
Constructors Constructor Description PySystemState()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void__delattr__(java.lang.String name)A variant of the __delattr__ method which accepts a String as the key.PyObject__findattr_ex__(java.lang.String name)Attribute lookup hook.void__rawdir__(PyDictionary accum)void__setattr__(java.lang.String name, PyObject value)A variant of the __setattr__ method which accepts a String as the key.static PyDictionary_current_frames()static PyFrame_getframe()static PyFrame_getframe(int depth)static voidadd_classdir(java.lang.String directoryPath)Add a classpath directory to the list of places that are searched for java packages.static voidadd_extdir(java.lang.String directoryPath)Add a .jar & .zip directory to the list of places that are searched for java .jar and .zip files.static voidadd_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.static PyJavaPackageadd_package(java.lang.String n)static PyJavaPackageadd_package(java.lang.String n, java.lang.String contents)voidcallExitFunc()static voidclassDictInit(PyObject dict)voidcleanup()voidclose()static PySystemStatedoInitialize(java.util.Properties preProperties, java.util.Properties postProperties, java.lang.String[] argv, java.lang.ClassLoader classLoader, ExtensiblePyObjectAdapter adapter)static voidexc_clear()static PyTupleexc_info()static voidexit()Exit a Python program with the status 0.static voidexit(PyObject status)Exit a Python program with the given status.static java.util.PropertiesgetBaseProperties()static java.lang.StringgetBuiltin(java.lang.String name)PyObjectgetBuiltins()PyIntegergetcheckinterval()java.lang.ClassLoadergetClassLoader()codecs.CodecStategetCodecState()java.lang.StringgetCurrentWorkingDir()Return a string representing the current working directory.static PyObjectgetDefaultBuiltins()PyStringgetdefaultencoding()java.io.FilegetFile(java.lang.String path)Resolve a path, returning aFile, taking the current working directory into account.PyObjectgetfilesystemencoding()java.util.concurrent.locks.ReentrantLockgetImportLock()static java.lang.StringgetNativePlatform()Emulates CPython's way to name sys.platform.java.lang.StringgetPath(java.lang.String path)Resolve a path.static java.lang.StringgetPathLazy(java.lang.String path)Resolve a path.PyObjectgetPlatform()PyObjectgetprofile()intgetrecursionlimit()java.lang.ClassLoadergetSyspathJavaLoader()static java.lang.StringgetSystemVersionString()Backed as follows: Windows: cmd.exe /C ver (part after "Windows") Other: uname -vPyObjectgettrace()PyObjectgetWarnoptions()org.python.core.WinVersiongetwindowsversion()static voidinitialize()static voidinitialize(java.util.Properties preProperties, java.util.Properties postProperties)static voidinitialize(java.util.Properties preProperties, java.util.Properties postProperties, java.lang.String[] argv)static voidinitialize(java.util.Properties preProperties, java.util.Properties postProperties, java.lang.String[] argv, java.lang.ClassLoader classLoader)static voidinitialize(java.util.Properties preProperties, java.util.Properties postProperties, java.lang.String[] argv, java.lang.ClassLoader classLoader, ExtensiblePyObjectAdapter adapter)static booleanisPackageCacheEnabled()booleanrefersDirectlyTo(PyObject ob)Optional operation.voidregisterCloser(java.util.concurrent.Callable<java.lang.Void> resourceCloser)voidsetBuiltins(PyObject value)voidsetcheckinterval(int interval)voidsetClassLoader(java.lang.ClassLoader classLoader)voidsetCurrentWorkingDir(java.lang.String path)Change the current working directory to the specified path.voidsetdefaultencoding(java.lang.String encoding)voidsetPlatform(PyObject value)voidsetprofile(PyObject profilefunc)voidsetrecursionlimit(int recursionlimit)voidsettrace(PyObject tracefunc)voidsetWarnoptions(PyObject value)voidshadow()Deprecated.java.lang.StringtoString()inttraverse(Visitproc visit, java.lang.Object arg)Traverses all directly containedPyObjects.booleanunregisterCloser(java.util.concurrent.Callable<java.lang.Void> resourceCloser)-
Methods inherited from class org.python.core.PyObject
__abs__, __add__, __and__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __call__, __cmp__, __coerce__, __coerce_ex__, __complex__, __contains__, __delattr__, __delete__, __delitem__, __delitem__, __delslice__, __delslice__, __dir__, __div__, __divmod__, __ensure_finalizer__, __eq__, __findattr__, __findattr__, __finditem__, __finditem__, __finditem__, __float__, __floordiv__, __format__, __ge__, __get__, __getattr__, __getattr__, __getitem__, __getitem__, __getnewargs__, __getslice__, __getslice__, __gt__, __hash__, __hex__, __iadd__, __iand__, __idiv__, __idivmod__, __ifloordiv__, __ilshift__, __imod__, __imul__, __index__, __int__, __invert__, __ior__, __ipow__, __irshift__, __isub__, __iter__, __iternext__, __itruediv__, __ixor__, __le__, __len__, __long__, __lshift__, __lt__, __mod__, __mul__, __ne__, __neg__, __nonzero__, __not__, __oct__, __or__, __pos__, __pow__, __pow__, __radd__, __rand__, __rdiv__, __rdivmod__, __reduce__, __reduce_ex__, __reduce_ex__, __repr__, __rfloordiv__, __rlshift__, __rmod__, __rmul__, __ror__, __rpow__, __rrshift__, __rshift__, __rsub__, __rtruediv__, __rxor__, __set__, __setattr__, __setitem__, __setitem__, __setitem__, __setslice__, __setslice__, __str__, __sub__, __tojava__, __truediv__, __trunc__, __unicode__, __xor__, _add, _and, _callextra, _cmp, _div, _divmod, _doget, _doget, _doset, _eq, _floordiv, _ge, _gt, _iadd, _iand, _idiv, _idivmod, _ifloordiv, _ilshift, _imod, _imul, _in, _ior, _ipow, _irshift, _is, _isnot, _isub, _itruediv, _ixor, _jcall, _jcallexc, _jthrow, _le, _lshift, _lt, _mod, _mul, _ne, _notin, _or, _pow, _rshift, _sub, _truediv, _xor, asDouble, asIndex, asIndex, asInt, asInt, asIterable, asLong, asLong, asName, asName, asString, asString, asStringOrNull, asStringOrNull, bit_length, conjugate, delDict, delType, dispatch__init__, equals, fastGetClass, fastGetDict, getDict, getType, hashCode, implementsDescrDelete, implementsDescrGet, implementsDescrSet, invoke, invoke, invoke, invoke, invoke, invoke, isCallable, isDataDescr, isIndex, isInteger, isMappingType, isNumberType, isSequenceType, noAttributeError, object___subclasshook__, readonlyAttributeError, setDict, setType
-
-
-
-
Field Detail
-
PYTHON_CACHEDIR
public static final java.lang.String PYTHON_CACHEDIR
- See Also:
- Constant Field Values
-
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
-
JYTHON_JAR
public static final java.lang.String JYTHON_JAR
- See Also:
- Constant Field Values
-
JYTHON_DEV_JAR
public static final java.lang.String JYTHON_DEV_JAR
- See Also:
- Constant Field Values
-
version
public static final PyString version
-
subversion
public static final PyTuple subversion
-
hexversion
public static final int hexversion
-
version_info
public static final PyVersionInfo version_info
-
maxunicode
public static final int maxunicode
- See Also:
- Constant Field Values
-
maxsize
public static final int maxsize
- See Also:
- Constant Field Values
-
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
-
packageManager
public static PackageManager packageManager
-
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 propertypython.homeor the location of the Jython JAR. The main collection of Python library modules is installed in the directoryprefix/Lib. This object should contain bytes in the file system encoding for consistency with use in the standard library (seesysconfig.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 asexec_prefix. This object should contain bytes in the file system encoding for consistency with use in the standard library (seesysconfig.py).
-
byteorder
public static final PyString byteorder
-
maxint
public static final int maxint
- See Also:
- Constant Field Values
-
minint
public static final int minint
- See Also:
- Constant Field Values
-
argv
public PyList argv
The arguments passed to this program on the command line.
-
modules
public PyObject modules
-
modules_reloading
public java.util.Map<java.lang.String,PyModule> modules_reloading
-
path
public PyList path
-
warnoptions
public PyList warnoptions
-
builtins
public PyObject builtins
-
platform
public PyObject platform
-
meta_path
public PyList meta_path
-
path_hooks
public PyList path_hooks
-
path_importer_cache
public PyObject path_importer_cache
-
ps1
public PyObject ps1
-
ps2
public PyObject ps2
-
executable
public PyObject executable
-
stdout
public PyObject stdout
-
stderr
public PyObject stderr
-
stdin
public PyObject stdin
-
__stdout__
public PyObject __stdout__
-
__stderr__
public PyObject __stderr__
-
__stdin__
public PyObject __stdin__
-
__displayhook__
public PyObject __displayhook__
-
__excepthook__
public PyObject __excepthook__
-
last_value
public PyObject last_value
-
last_type
public PyObject last_type
-
last_traceback
public PyObject last_traceback
-
__name__
public PyObject __name__
-
__dict__
public PyObject __dict__
-
_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
-
-
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()
-
getCodecState
public codecs.CodecState getCodecState()
-
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:PyObjectAttribute 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 usePyObject.__getattr__(String)orPyObject.__findattr__(String). Both methods have a clear policy for failed lookups.- Overrides:
__findattr_ex__in classPyObject- 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:PyObjectA variant of the __setattr__ method which accepts a String as the key. This String must be interned.- Overrides:
__setattr__in classPyObject- 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:PyObjectA 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 classPyObject- Parameters:
name- the name which will be removed - must be an interned string .- See Also:
PyObject.__delattr__(PyString)
-
__rawdir__
public void __rawdir__(PyDictionary accum)
-
getrecursionlimit
public int getrecursionlimit()
-
setrecursionlimit
public void setrecursionlimit(int recursionlimit)
-
gettrace
public PyObject gettrace()
-
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 aFile, taking the current working directory into account.- Parameters:
path- a pathString- Returns:
- a resolved
File
-
callExitFunc
public void callExitFunc() throws PyIgnoreMethodTag- Throws:
PyIgnoreMethodTag
-
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:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
getSystemVersionString
public static java.lang.String getSystemVersionString()
Backed as follows: Windows: cmd.exe /C ver (part after "Windows") Other: uname -v
-
traverse
public int traverse(Visitproc visit, java.lang.Object arg)
Description copied from interface:TraverseprocTraverses all directly containedPyObjects. Like in CPython,argmust be passed unmodified tovisitas its second parameter. IfVisitproc.visit(PyObject, Object)returns nonzero, this return value must be returned immediately by traverse.Visitproc.visit(PyObject, Object)must not be called with anullPyObject-argument.- Specified by:
traversein interfaceTraverseproc
-
refersDirectlyTo
public boolean refersDirectlyTo(PyObject ob)
Description copied from interface:TraverseprocOptional operation. Should only be implemented if it is more efficient than callingTraverseproc.traverse(Visitproc, Object)with a visitproc that just watches out forob. Must returnfalseifobisnull.- Specified by:
refersDirectlyToin interfaceTraverseproc
-
-