Alternatives - command /usr/bin/alternatives
output
- class insights.parsers.alternatives.AlternativesOutput(context, extra_bad_lines=None)[source]
Bases:
CommandParser
Read the output of
/usr/sbin/alternatives --display *program*
and convert into information about the given program’s alternatives.Typical input is:
java - status is auto. link currently points to /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-1.b15.el7_2.x86_64/jre/bin/java /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.111-2.6.7.2.el7_2.x86_64/jre/bin/java - priority 1700111 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.111-1.b15.el7_2.x86_64/jre/bin/java - priority 1800111 /usr/lib/jvm/jre-1.6.0-ibm.x86_64/bin/java - priority 16091 slave ControlPanel: /usr/lib/jvm/jre-1.6.0-ibm.x86_64/bin/ControlPanel slave keytool: /usr/lib/jvm/jre-1.6.0-ibm.x86_64/bin/keytool slave policytool: /usr/lib/jvm/jre-1.6.0-ibm.x86_64/bin/policytool slave rmid: /usr/lib/jvm/jre-1.6.0-ibm.x86_64/bin/rmid Current 'best' version is /usr/lib/jvm/jre-1.6.0-ibm.x86_64/bin/java.
Lines are interpreted this way:
Program lines are of the form ‘name - status is status’, and start the information for a program. Lines before this are ignored.
The current link to this program is found on lines starting with ‘link currently points to’.
Lines starting with ‘/’ and with ‘ - priority ‘ in them record an alternative path and its priority.
Lines starting with ‘slave program: path’ are recorded against the alternative path.
Lines starting with “Current ‘best’ version is” indicate the default choice of an ‘auto’ status alternative.
The output of
alternatives --display *program*
can only ever list one program, so as long as one ‘status is’ line is found (as described above), the content of the object displays that program.- program
The name of the program found in the ‘status is’ line. This attribute is set to
None
if a status line is not found.- Type:
str
- status
The status of the program, or
None
if not found.- Type:
str
- link
The link to this program, or
None
if the ‘link currently points to`` line is not found.- Type:
str
- best
The ‘best choice’ path that
alternatives
would use, orNone
if the ‘best choice’ line is not found.- Type:
str
- paths
The alternative paths for this program. Each path is a dictionary containing the following keys:
path
: the actual path of this alternative for the programpriority
: the priority, as an integer (e.g. 1700111)slave
: a dictionary of programs dependent on this alternative - the key is the program name (e.g. ‘ControlPanel’) and the value is the path to that program for this alternative path.
- Type:
dict
Examples
>>> java_alt.program 'java' >>> java_alt.link '/usr/lib/jvm/jre-1.6.0-ibm.x86_64/bin/java' >>> len(java_alt.paths) 2 >>> java_alt.paths[0]['path'] '/usr/lib/jvm/jre-1.6.0-ibm.x86_64/bin/java' >>> java_alt.paths[0]['priority'] 16091 >>> java_alt.paths[0]['slave']['ControlPanel'] '/usr/lib/jvm/jre-1.6.0-ibm.x86_64/bin/ControlPanel'
- class insights.parsers.alternatives.JavaAlternatives(context, extra_bad_lines=None)[source]
Bases:
AlternativesOutput
Class to read the
/usr/sbin/alternatives --display java
output.Uses the
AlternativesOutput
base class to get information about the alternatives forjava
available and which one is currently in use.Examples
>>> java_alt.program 'java' >>> java_alt.link '/usr/lib/jvm/jre-1.6.0-ibm.x86_64/bin/java' >>> len(java_alt.paths) 2 >>> java_alt.paths[0]['path'] '/usr/lib/jvm/jre-1.6.0-ibm.x86_64/bin/java' >>> java_alt.paths[0]['priority'] 16091 >>> java_alt.paths[0]['slave']['ControlPanel'] '/usr/lib/jvm/jre-1.6.0-ibm.x86_64/bin/ControlPanel'
- class insights.parsers.alternatives.PythonAlternatives(context, extra_bad_lines=None)[source]
Bases:
AlternativesOutput
Class to read the
/usr/sbin/alternatives --display python
output.Uses the
AlternativesOutput
base class to get information about the alternatives forbest
available and which one is currently in use.Examples
>>> python_alt.program 'python' >>> python_alt.link '/usr/bin/python3' >>> len(python_alt.paths) 2 >>> python_alt.paths[0]['path'] '/usr/libexec/no-python' >>> python_alt.paths[0]['priority'] 404