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.1.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: red_sysinfo-0.1.1.tar.gz
  • Upload date:
  • Size: 9.1 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.1.tar.gz
Algorithm Hash digest
SHA256 d3c2cba33415be30cd7c7b5e158624fbe5b693f20e5738b1792e3914456a2e53
MD5 578e41d86549242446f161814105644f
BLAKE2b-256 f561ed004bcbbea2cc3aa6919430ef0bcbe9fd528ec1c0ec0d7083a66a8352a6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: red_sysinfo-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a34863da2f56df725960e30f3ffbf6b7f683fbae7495aaa6d1c49858ad265401
MD5 de23ccd54556cbf0f4268890cd498ac3
BLAKE2b-256 ea64513c48e10a8619bdcd30c0b1a3263c8c890a24a064f7d398b3ff03fd7180

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