This repository was archived by the owner on Aug 17, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpy_platform.py
More file actions
executable file
·83 lines (69 loc) · 3.86 KB
/
py_platform.py
File metadata and controls
executable file
·83 lines (69 loc) · 3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python3
import platform, argparse, os, time, logging
# This allows for the user to pass arguments to the script, allowing for certain information to be shown:
parser = argparse.ArgumentParser('py_platform', description='Python-based system information giver using platform module', epilog='thanks! ; main Branch ; by Nacroni')
parser.add_argument('-a', '--all', help='prints all information (short for fnwdio)', action='store_true')
parser.add_argument('-f', '--freedesktop', help='prints the freedesktop.org OS release information', action='store_true')
parser.add_argument('-n', '--android', help='prints Android information', action='store_true')
parser.add_argument('-w', '--win32', help='prints Win32 information', action='store_true')
parser.add_argument('-d', '--darwin', help='prints Darwin information', action='store_true')
parser.add_argument('-i', '--ios', help='prints iOS information', action='store_true')
args = parser.parse_args()
logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.DEBUG)
# This allows the script to see whether or not a certain argument is enabled.
freedesktop_enable = args.freedesktop
android_enable = args.android
win32_enable = args.win32
darwin_enable = args.darwin
ios_enable = args.ios
if args.all:
freedesktop_enable=True
android_enable=True
win32_enable=True
darwin_enable=True
ios_enable=True
if not os.path.exists('/etc/os-release') or not os.path.exists('/usr/lib/os-release'):
logging.warning('freedesktop.org information not available. turning off argument.')
freedesktop_enable = False
print('System Information')
# (f' name: {var}' )
print(f' System: {platform.system()}' )
print(f' User: {os.getlogin()}' )
print(f' Hostname: {platform.node()}' )
print(f' Monotonic Clock: {time.monotonic()}' )
print(f' Release: {platform.release()}' )
print(f' Version: {platform.version()}' )
print(f' Machine: {platform.machine()}' )
print(f' Processor: {platform.processor()}' )
print(f' Architecture: {platform.architecture()}')
print(f' CPU Count: {os.cpu_count()}' )
if freedesktop_enable: # If the 'freedesktop' argument is used...
print('\nfreedesktop.org Information')
# (f' name: {var}' )
print(f' OS Release: {platform.freedesktop_os_release()}')
if android_enable: # If the Android argument is used...
print('\nAndroid Information')
# (f' name: {var}' )
print(f' Version: {platform.android_ver()}')
if 'Windows' in platform.system() or win32_enable: # If the user is running Windows or the Win32 argument is used...
print('\nWindows (Win32) Information')
# (f' name: {var}' )
print(f' Version: {platform.win32_ver()}' )
print(f' Edition: {platform.win32_edition()}')
print(f' Is IoT: {platform.win32_is_iot()}' )
if 'Darwin' in platform.system() or darwin_enable: # If the user is running Darwin or the Mac argument is used...
print('\nDarwin Information')
# (f' name: {var}' )
print(f' Mac Version: {platform.mac_ver()}')
if ios_enable: # If the iOS argument is used...
print('\niOS Information')
# (f' name: {var}' )
print(f' iOS Version: {platform.ios_ver()}')
print('\nPython Information')
# (f' name: {var}' )
print(f' Version: {platform.python_version()}' )
print(f' Branch: {platform.python_branch()}' )
print(f' Build: {platform.python_build()}' )
print(f' Compiler: {platform.python_compiler()}' )
print(f' Implementation: {platform.python_implementation()}')
print(f' Revision: {platform.python_revision()}' )