class Os:
Represents information about an operating system (OS), such as the family of the OS (Windows, Linux, ...), its architecture and version.
Due to the nature of recovering information from replay data, depending on the trace some information could be missing on an OS. This translates to OS having all of its properties able to return None.
Method | __eq__ |
Compares the instance for equality with an object. |
Method | __init__ |
Instantiates a new Os from its components. |
Method | __repr__ |
Returns the "official" string representation of this instance. |
Method | __str__ |
Returns the nicely printable string representation of this instance. |
Method | expect |
Raises OsError if this OS instance does not match any of the expected OS arguments. |
Method | matches |
Compare the components of this instance with the non-None components of the other. |
Property | architecture |
The CPU architecture of the OS. |
Property | family |
The OS family (Windows, Linux). |
Property | kernel |
The version of the kernel of the OS. |
Property | windows |
The Windows version. |
Static Method | _unpack |
Undocumented |
Instance Variable | _architecture |
Undocumented |
Instance Variable | _family |
Undocumented |
Instance Variable | _kernel |
Undocumented |
Instance Variable | _windows |
Undocumented |
Compares the instance for equality with an object.
- if the object is not an
Os
, will return False.
Parameters | |
other:object | Undocumented |
Returns | |
bool | Undocumented |
Instantiates a new Os from its components.
Parameters | |
architecture:_Optional[ | Undocumented |
family:_Optional[ | Undocumented |
kernel_Optional[ | Undocumented |
windows_Optional[ | Undocumented |
Returns the "official" string representation of this instance.
Returns | |
str | Undocumented |
Returns the nicely printable string representation of this instance.
Returns | |
str | Undocumented |
Raises OsError
if this OS instance does not match any of the expected OS arguments.
Example
Expecting Windows of any architecture or a x64 Linux
>>> server.ossi.os().expect(Os(family=OsFamily.Windows), ... Os(architecture=Architecture.X64, family=OsFamily.Linux))
Expecting Linux 4.x or Linux 5.x
>>> server.ossi.os().expect(Os(family=OsFamily.Linux, kernel_version=KernelVersion(4)), ... Os(family=OsFamily.Linux, kernel_version=KernelVersion(5)))
Notes
Parameters | |
*expected:Os | Undocumented |
Compare the components of this instance with the non-None components of the other.
This method behaves like the equality comparison, expects that it still considers this instance to match with the other if they only differ on components (family, architecture, kernel_version, version) that are None for the other.
This allows to compare for OS that are unconstrained on some dimensions, and this is used in expect
.
Examples
>>> Os(family=OsFamily.Windows, architecture=Architecture.X64).matches(Os(family=OsFamily.Windows)) True >>> Os(family=OsFamily.Windows, architecture=Architecture.X64).matches(Os(family=OsFamily.Linux)) False >>> Os(family=OsFamily.Linux, kernel_version=KernelVersion(4, 9, 0, "4.9.0-16-amd64")).matches( ... Os(family=OsFamily.Linux, kernel_version=KernelVersion(4))) True
Notes
- The matches relationship is not symmetric: a.matches(b) does not imply b.matches(a)
- Equal instances always match.
- Kernel versions are also compared with
KernelVersion.matches
rather than equality.
Parameters | |
other:Os | Undocumented |
Returns | |
bool | Undocumented |
The version of the kernel of the OS.
Note that it does not necessarily match with the "brand version" of the OS, e.g. Windows 7 has kernel version 6.1
def _unpack(maybe_os):
Undocumented
Parameters | |
maybereven_api.OptionalOs | Undocumented |
Returns | |
Os | Undocumented |