PyObject, for example when creating
the first interpreter. When preparing an application (from the command line options, say) for
creation of the first interpreter, it useful to defer type system creation until pre-Python
configuration is complete. See PEP 432 for further rationale.
Creation of the type system may happen as a side effect of referring using (almost) any object
from a class that statically refers to a PyObject, for example Py or
PySystemState. The present class is intended to hold utility methods and configuration
useful in the pre-Python phase.
| Modifier and Type | Field and Description |
|---|---|
| public static final int | COMMENT
|
| public static final int | DEBUG
|
| public static final int | ERROR
|
| protected static final Logger | |
| private static final Level[] | LEVELS
A mapping from the traditional "verbosity" found in |
| protected static final Logger | logger
Our name-spaced root logger is "org.python". |
| public static final int | MESSAGE
|
| private static int | savedVerbosity
Used by |
| public static final int | WARNING
|
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private static String | Returns: the full name of the jar file containing this class,null if not
available.Utility-method to obtain the name (including absolute path) of the currently used jython-jar-file. |
| public static String | Returns: the first line with content, or ""as strings (as for command)ProcessBuilder)Run a command as a sub-process and return as the result the first line of output that consists of more than white space. |
| public static String | Returns: the first line with content, or ""as strings (as for command)ProcessBuilder)A specialised wrapper on |
| public static String | Returns: usual Jython bin-dir as absolute pathInfers the usual Jython bin-dir from the position of the jar-file returned by
|
| public static String | Returns: usual Jython-executable as absolute pathInfers the usual Jython executable name from the position of the jar-file returned by
|
| private static Level | getEffectiveLoggingLevel(Logger logger)
Convenience function to get the effective level of a given Logger, looking up the parent chain. |
| public static String | Returns: the full name of the jar file containing this class,null if not
available.Utility-method to obtain the name (including absolute path) of the currently used jython-jar-file. |
| public static String | Returns: the file path ornull in the event of a detectable errorinto the JAR url)Return the path in the file system (as a string) of a JAR located using the URL of a class file that it contains. |
| public static Level | |
| public static Properties | Returns: System properties or a new Properties objectGet the System properties if we are allowed to. |
| public static String | Returns: property value or given defaultof the entry to return key, String to return if null or disallowed defaultValue)Get a System property if it is defined, not null, and we are allowed to access it, otherwise return the given default. |
| public static boolean | |
| public static void | increaseLoggingLevel(int
increment on the scale n)1=INFO, 2=CONFIG, 3=FINE, ... Adjust the level of the Jython logger "org.python" using the traditional "verbosity" system: the bigger the number, the lower the logging threshold. |
| public static boolean | Returns: true if (we think) standard input is an interactive streamDetermine whether standard input is an interactive stream. |
| public static boolean | Returns: true iff thought to be interactivestream (tested only for fp, String filename)System.in)Check whether an input stream is interactive. |
| public static Level | levelFromVerbosity(int
any integer verbosity, where the runtime default verbosity)MESSAGE = 1Translate from the traditional "verbosity" system to JUL Level. |
| public static void | maybeWrite(String type, String msg, int verbosity)
Log a message at a specified level (if that level is not below the threshold). |
| public static Level | Returns: previous logging levelto set newLevel)Set the level of the Jython logger "org.python" using the standard |
| private static void | syncLoggingLevel()
Ensure that the logging system threshold is adjusted to match the legacy
|
| private static URL | Returns: corrected URLPossibly malformed URL url)If the argument is a |
| public static int | Returns: integer verbosity, where the runtime defaultINFO = 1java.util.logging.Level to translate.Translate from JUL Level to equivalent in the traditional "verbosity" system. |
| public static void | |
| public static void | |
| public static void | |
| public static void | |
| public static void |
| COMMENT | back to summary |
|---|---|
| public static final int COMMENT
| |
| DEBUG | back to summary |
|---|---|
| public static final int DEBUG
| |
| ERROR | back to summary |
|---|---|
| public static final int ERROR
| |
| importLogger | back to summary |
|---|---|
| protected static final Logger importLogger | |
| LEVELS | back to summary |
|---|---|
| private static final Level[] LEVELS A mapping from the traditional "verbosity" found in | |
| logger | back to summary |
|---|---|
| protected static final Logger logger Our name-spaced root logger is "org.python". | |
| MESSAGE | back to summary |
|---|---|
| public static final int MESSAGE
| |
| savedVerbosity | back to summary |
|---|---|
| private static int savedVerbosity Used by | |
| WARNING | back to summary |
|---|---|
| public static final int WARNING
| |
| PrePy | back to summary |
|---|---|
| public PrePy() | |
| _getJarFileName | back to summary |
|---|---|
| private static String _getJarFileName() Utility-method to obtain the name (including absolute path) of the currently used jython-jar-file. Usually this is jython.jar, but can also be jython-dev.jar or jython-standalone.jar or something custom.
| |
| getCommandResult | back to summary |
|---|---|
| public static String getCommandResult(String... command) Run a command as a sub-process and return as the result the first line of output that consists of more than white space. It returns "" on any kind of error. | |
| getCommandResultWindows | back to summary |
|---|---|
| public static String getCommandResultWindows(String... command) A specialised wrapper on | |
| getDefaultBinDir | back to summary |
|---|---|
| public static String getDefaultBinDir() Infers the usual Jython bin-dir from the position of the jar-file returned by
Note that this does not necessarily return the actual bin-directory, but instead infers the place where it is usually expected to be.
| |
| getDefaultExecutableName | back to summary |
|---|---|
| public static String getDefaultExecutableName() Infers the usual Jython executable name from the position of the jar-file returned by
Note that this does not necessarily return the actual executable, but instead infers the
place where it is usually expected to be. Use
| |
| getEffectiveLoggingLevel | back to summary |
|---|---|
| private static Level getEffectiveLoggingLevel(Logger logger) Convenience function to get the effective level of a given Logger, looking up the parent
chain. If the root logger is reached without an explicit level set, assume
| |
| getJarFileName | back to summary |
|---|---|
| public static String getJarFileName() Utility-method to obtain the name (including absolute path) of the currently used jython-jar-file. Usually this is jython.jar, but can also be jython-dev.jar or jython-standalone.jar or something custom.
| |
| getJarFileNameFromURL | back to summary |
|---|---|
| public static String getJarFileNameFromURL(URL url) Return the path in the file system (as a string) of a JAR located using the URL of a class file that it contains. Classes in Java can be asked for the URL of their associated resources (including their own class definition), and so the caller of this method may present such a URL as the basis for locating the JAR from which it came. Three protocols are supported, Java JAR-file protocol, and two JBoss protocols "vfs" and "vfszip".
The JAR-file protocol URL, which must be a
The JBoss URL must be a reference to a class in | |
| getLoggingLevel | back to summary |
|---|---|
| public static Level getLoggingLevel() Convenience function to get the effective level of Logger "org.python". | |
| getSystemProperties | back to summary |
|---|---|
| public static Properties getSystemProperties() Get the System properties if we are allowed to. Configuration values set via
| |
| getSystemProperty | back to summary |
|---|---|
| public static String getSystemProperty(String key, String defaultValue) Get a System property if it is defined, not null, and we are allowed to access it, otherwise return the given default. property value or given default | |
| haveConsole | back to summary |
|---|---|
| public static boolean haveConsole() Return | |
| increaseLoggingLevel | back to summary |
|---|---|
| public static void increaseLoggingLevel(int n) Adjust the level of the Jython logger "org.python" using the traditional "verbosity" system:
the bigger the number, the lower the logging threshold. This is primarily for the
command-line Jython, where each "-v" increases the verbosity by one, on the
| |
| isInteractive | back to summary |
|---|---|
| public static boolean isInteractive() Determine whether standard input is an interactive stream. If the Java system property
| |
| isInteractive | back to summary |
|---|---|
| public static boolean isInteractive(InputStream fp, String filename) Check whether an input stream is interactive. This emulates CPython
| |
| levelFromVerbosity | back to summary |
|---|---|
| public static Level levelFromVerbosity(int verbosity) Translate from the traditional "verbosity" system to JUL Level. We allow Jython verbosity
values beyond the conventional range, treating values < | |
| maybeWrite | back to summary |
|---|---|
| public static void maybeWrite(String type, String msg, int verbosity) Log a message at a specified level (if that level is not below the threshold).
| |
| setLoggingLevel | back to summary |
|---|---|
| public static Level setLoggingLevel(Level newLevel) Set the level of the Jython logger "org.python" using the standard
| |
| syncLoggingLevel | back to summary |
|---|---|
| private static void syncLoggingLevel() Ensure that the logging system threshold is adjusted to match the legacy
| |
| tweakWindowsFileURL | back to summary |
|---|---|
| private static URL tweakWindowsFileURL(URL url) throws MalformedURLException If the argument is a
This bug bites when a JAR file is at a (Windows) UNC location, and a | |
| verbosityFromLevel | back to summary |
|---|---|
| public static int verbosityFromLevel(Level level) Translate from JUL Level to equivalent in the traditional "verbosity" system. We return
Jython verbosity values beyond the conventional range, enough to enumerate the Java standard
levels (e.g
| |
| writeComment | back to summary |
|---|---|
| public static void writeComment(String type, String msg) Submit a message to logging at the severity level COMMENT. | |
| writeDebug | back to summary |
|---|---|
| public static void writeDebug(String type, String msg) Submit a message to logging at the severity level DEBUG. | |
| writeError | back to summary |
|---|---|
| public static void writeError(String type, String msg) Submit a message to logging at the severity level ERROR. | |
| writeMessage | back to summary |
|---|---|
| public static void writeMessage(String type, String msg) Submit a message to logging at the severity level MESSAGE. | |
| writeWarning | back to summary |
|---|---|
| public static void writeWarning(String type, String msg) Submit a message to logging at the severity level WARNING. | |