class documentation

class Os:

View In Hierarchy

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_version The version of the kernel of the OS.
Property windows_version The Windows version.
Static Method _unpack Undocumented
Instance Variable _architecture Undocumented
Instance Variable _family Undocumented
Instance Variable _kernel_version Undocumented
Instance Variable _windows_version Undocumented
def __eq__(self, other):

Compares the instance for equality with an object.

  • if the object is not an Os, will return False.
Parameters
other:objectUndocumented
Returns
boolUndocumented
def __init__(self, architecture=None, family=None, kernel_version=None, windows_version=None):

Instantiates a new Os from its components.

Parameters
architecture:_Optional[Architecture]Undocumented
family:_Optional[OsFamily]Undocumented
kernel_version:_Optional[KernelVersion]Undocumented
windows_version:_Optional[WindowsVersion]Undocumented
def __repr__(self):

Returns the "official" string representation of this instance.

Returns
strUndocumented
def __str__(self):

Returns the nicely printable string representation of this instance.

Returns
strUndocumented
def expect(self, *expected):

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

  • This function always checks with matches. If you need more complicated checks, you should raise OsErrors directly.
Parameters
*expected:OsUndocumented
def matches(self, other):

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:OsUndocumented
Returns
boolUndocumented
@property
architecture: _Optional[Architecture] =

The CPU architecture of the OS.

@property
family: _Optional[OsFamily] =

The OS family (Windows, Linux).

@property
kernel_version: _Optional[KernelVersion] =

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

@property
windows_version: _Optional[WindowsVersion] =

The Windows version.

Return None for other OSes, or if it cannot be detected.

@staticmethod
def _unpack(maybe_os):

Undocumented

Parameters
maybe_os:reven_api.OptionalOsUndocumented
Returns
OsUndocumented
_architecture =

Undocumented

_family =

Undocumented

_kernel_version =

Undocumented

_windows_version =

Undocumented