OS detection is a critical capability of many ROS tools in the ROS build toolchain. The rospkg.os_detect module provides and extendable library for detecting various operating systems. It is focused on detecting operating systems used with ROS.
Currently supported OSes:
Exception to indicate failure to detect operating system.
Detects the current operating system. This class will iterate over registered classes to lookup the active OS and version. The list of detectors can be overridden in the constructor; otherwise it will default to OsDetector classes provided by this library.
- default_os_list¶
List of currently registered detectors. Must not be modified directly.
- static register_default(os_name, os_detector)[source]¶
Register detector to be used with all future instances of OsDetect. The new detector will have precedence over any previously registered detectors associated with os_name.
- detect_os() → tuple[source]¶
Returns: (os_name, os_version, os_codename), (str, str, str) Raises : OsNotDetected if OS could not be detected
- get_detector([name]) → OsDetector[source]¶
Get detector used for specified OS name, or the detector for this OS if name is None.
Raises : KeyError
- add_detector(name, detector)[source]¶
Add detector to list of detectors used by this instance. detector will override any previous detectors associated with name.
Parameters:
- name – OS name that detector matches
- detector – OsDetector instance
- get_os() → OsDetector¶
Get OsDetector for this operating system.
Raises : OsNotDetected if OS could not be detected
- get_name() → str[source]¶
Returns: Name of current operating system. See OS_* definitions in this module for possible values. Raises : OsNotDetected if OS could not be detected
- get_version() → str[source]¶
Returns: Version of current operating system Raises : OsNotDetected if OS could not be detected
- get_codename() → str[source]¶
Returns: Codename of current operating system if available, or empty string if OS does not provide codename. Raises : OsNotDetected if OS could not be detected
Generic API for detecting a specific OS.
Returns: | codename for this OS. (ala Ubuntu Hardy Heron = “hardy”). If codenames are not available for this OS, return empty string. |
---|---|
Raises : | OsNotDetected if called on incorrect OS. |
Returns: | standardized version for this OS. (ala Ubuntu Hardy Heron = “8.04”) |
---|---|
Raises : | OsNotDetected if called on incorrect OS. |
Name used for Arch Linux OS.
Name used for Cygwin OS.
Name used for Debian OS.
Name used for FreeBSD OS.
Name used for Gentoo.
Name used for Mint OS.
Name used for OpenSUSE OS.
Name used for OS X.
Name used for Red Hat Enterprise Linux.
Name used for Ubuntu OS.
Linux: wrapper around lsb_release to get the current OS
Linux: wrapper around lsb_release to get the current OS codename