Skip to main content

Compile platform information from 'sys' and 'platform' modules into a single PLATFORM class.

Project description

Red-Sys

Access platform details from a single object.

Description

This module has a number of class objects, with properties derived from the platform and sys modules (part of Python's stdlib).

The cross-platform, main object of red-sys is the PlatformInfo class (defined in domain.platform.schemas). This class has properties like machine, which prints the machine's architecture (i.e. x86_x84), system (i.e. Linux), and more.

PlatformInfo also has details about the Python interpreter running a script where PlatformInfo is called. PlatformInfo.python has details like the interpreter's version, implementation, path, and more. You can view the class at domain.platform.schemas.PlatformPython.

Usage

Import the PlatformInfo object. 2 methods:

  • An initialized CONSTANT
    • Import with: from red_sys import PLATFORM
    • The PLATFORM instance will be initialized from the environment.
      • Equivalent to PLATFORM = PlatformInfo()
  • Use the .get_platform() function
    • Import the function with from red_sysinfo.utils import platform_utils
    • Define a variable, i.e. PLATFORM = platform_utils.get_platform()
      • Variable will contain an initialized instance of PlatformInfo
  • Initialize an instance of the PlatformInfo class
    • from red_sys import PlatformInfo
      
      p: PlatformInfo = PlatformInfo()
      
      print(p.system())
      

To print a pre-formatted platform report, import the print_platform() function from red_sysinfo.domain.platform.utils and pass a PlatformInfo object.

Example:

from red_sysinfo import PLATFORM, print_platform()

print_platform(p=PLATFORM)

Optionally, call print_platform(print_large_values=True) to print values with a large output, like PLATFORM.python.modules.

The PlatformInfoBase class defines a number of functions and properties that children classes (classes inheriting from PlatformInfoBase, i.e. "PlatformInfo(PlatformInfoBase):") can access.

  • .is_<platform>() functions, which return a bool if platform is detected
    • .is_linux()
    • .is_unix()
    • .is_win()
    • .is_mac()
    • .is_java()
  • .is_<arch> functions, which return a bool if CPU architecture is detected
    • .is_32bit()
    • .is_64bit()
  • .as_dict() function
    • Returns representation of class as a Python dict
    • Usage: PLATFORM.is_dict()

Enums

red-sys also has a number of enumerators for constants. These are defined in domain.enums.platform, and are separated by platform.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

red_sysinfo-0.1.2.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

red_sysinfo-0.1.2-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file red_sysinfo-0.1.2.tar.gz.

File metadata

  • Download URL: red_sysinfo-0.1.2.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.10.0 CPython/3.11.5

File hashes

Hashes for red_sysinfo-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f0e6c98886debbe5a33e79135b66038585c159a95cf2c390fa5ade1b1bb6a7d3
MD5 fc6eb91c97ba79892d22a159d3af620d
BLAKE2b-256 0b6b2054df061a2c6db0dbcfc34456a97d05aa957392c95c935378b6b3104d07

See more details on using hashes here.

File details

Details for the file red_sysinfo-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: red_sysinfo-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.10.0 CPython/3.11.5

File hashes

Hashes for red_sysinfo-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fb639c76475264d07ea1b8d95bae5f48e24f00650858360837731043e9158b58
MD5 3931377d2c37490ccdb30becb3915e5c
BLAKE2b-256 b1fed33ca4243ee83fc21771991ef73829db0fba2a85e6b0cd36b97387cdde4b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page