forked from E3V3A/pip-date
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyOSinfo.py
executable file
·86 lines (76 loc) · 3.83 KB
/
pyOSinfo.py
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
84
85
86
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# pyOSinfo - Show what Python thinks about your system environment
#----------------------------------------------------------------------
# File Name : pyOSinfo
# Author : E:V:A
# Date : 2018-02-08
# Last Modified : 2022-01-24
# Version : 1.0.5
# License : GPLv3
# URL : https://github.com/E3V3A/pip-date/
# Description : Show some system, os and platform information as seen by python3
#----------------------------------------------------------------------
# NOTE:
# On Cygwin, yuo have to pay attention to the parts of the PATH
# that is cpoied fromt he Windows (System PATH). This will interfere
# with the resulsts of 'os.name' [nt vs posix], depeding on which
# python*.exe was used. Try to test with:
# ls -al `which python.exe`
#----------------------------------------------------------------------
import os, sys, platform, site
from os.path import join
__version__ = '1.0.5'
TRUECOLOR = "\x1b[38;2;255;100;0mTRUECOLOR\x1b[0m"
def hasUname():
try:
os.uname()[0]
return True
except:
return False
print("\nCurrent OS variables as seen by Python3 (%s)\n" % platform.python_version() )
print('os.getenv(\"TERM\"): %s' % os.getenv("TERM")) # [xterm, xterm-color, xterm-256color]
print('os.name: %s' % os.name ) # [posix, nt, java]
print('os.sys.platform: %s' % os.sys.platform ) # [linux, win32, cygwin, darwin]
print('sys.platform: %s' % sys.platform ) # [linux, win32, cygwin, darwin]
print('TRUECOLOR (orange): %s' % TRUECOLOR ) # TRUECOLOR written in nice orange
# Apparently some Windows Pythons doesn't provide os.uname attribute.
# Like: Winpython64-3.6.7.0Zero
print('\nos.uname:') # sysname, nodename, release, version, machine
if hasUname():
print('\tnodename: %s' % os.uname()[1] ) #
print('\tmachine: %s' % os.uname()[4] ) #
print('\tsysname: %s' % os.uname()[0] ) #
print('\trelease: %s' % os.uname()[2] ) #
print('\tversion: %s' % os.uname()[3] ) #
else:
print('\tN/A' )
print('\nplatform:')
print('\tnode : %s' % platform.node() )
print('\tmachine : %s' % platform.machine() )
print('\tprocessor : %s' % platform.processor() )
print('\tsystem : %s' % platform.system() )
print('\trelease : %s' % platform.release() )
print('\tversion : %s' % platform.version() )
print('\tplatform : %s' % platform.platform() )
print('\tuname (6) : {}'.format(platform.uname()) ) # (system, node, release, version, machine) # not processor
print('\tarchitecture (2): (%s,%s)' % platform.architecture() ) # (bits, linkage)
#print('\twin32_ver (4): (%s,%s,%s,%s)' % platform.win32_ver() ) # (release, version, csd, ptype)
# python -c "import os, sys; print(sys.implementation);"
# (_multiarch='x86_64-cygwin', cache_tag='cpython-38', hexversion=50856116, name='cpython', version=sys.version_info(major=3, minor=8, micro=0, releaselevel='beta', serial=4))
# (name='cpython', cache_tag='cpython-310', version=sys.version_info(major=3, minor=10, micro=0, releaselevel='final', serial=0), hexversion=50987248)
print('\nsys:')
#print('\timplementation (7) : {}'.format(sys.implementation()) ) #
print('\timplementation (7) : WIP') #
print("\nsite:")
print("\tgetusersitepackages: %s" % site.getusersitepackages())
i=0
for ploc in site.getsitepackages(): # Returns a []
print("\tgetsitepackages[%i]: %s" % (i, ploc)) # site.getsitepackages()[0])
i+=1
print()
print("\tPREFIXES (2) : %s" % site.PREFIXES)
print("\tUSER_SITE : %s" % site.USER_SITE)
print("\tUSER_BASE : %s" % site.USER_BASE)
print('\nsys.path:\n\t%s\n' % ('\n\t'.join(sys.path)) )
sys.exit(0)