on which SAT is running
'''
-import os, sys, platform
+import os, sys
+from platform import system,python_version,release
+
+# linux_distribution is removed from platform module in python 3.8+
+# we have to use distro module, which is not standard.
+# write an error message if distro is not installed
+try:
+ from platform import linux_distribution
+except:
+ try:
+ from distro import linux_distribution
+ except:
+ print ("\nError :\n"
+ " linux_distribution was removed from platform module in Python 3.8+\n"
+ " For python 3.8+ sat requires distro module to get information on linux distribution.\n"
+ " Please install distro module with : pip install distro")
+ sys.exit(-1)
+
def is_windows():
'''method that checks windows OS
:rtype: boolean
'''
- return platform.system() == 'Windows'
+ return system() == 'Windows'
def get_user():
'''method that gets the username that launched sat
return "W"
# else get linux distribution description from platform, and encode it with code
- lin_distrib = platform.dist()[0].lower()
+ lin_distrib = linux_distribution()[0].lower()
distrib="not found"
for dist in codes:
if dist in lin_distrib:
"""
Return major and minor version of the distribution
from a CentOS example, returns '7.6'
- extracted from platform.dist()
+ extracted from platform.linux_distribution()
"""
- dist_version=platform.dist()[1].split('.')
+ dist_version=linux_distribution()[1].split('.')
if len(dist_version)==1:
version = dist_version[0]
else:
'''
if is_windows():
- return platform.release()
+ return release()
# get version from platform
- dist_version=platform.dist()[1].split('.')
+ dist_version=linux_distribution()[1].split('.')
# encode it (conform to src/internal_config/distrib.pyconf VERSIONS dist
if distrib == "CO":
'''
# The platform python module gives the answer
- return platform.python_version()
+ return python_version()
def get_nb_proc():
'''Gets the number of processors of the machine
import multiprocessing
nb_proc=multiprocessing.cpu_count()
except :
- nb_proc=int(os.sysconf('SC_NPROCESSORS_ONLN'))
+ if is_windows():
+ if os.environ.has_key("NUMBER_OF_PROCESSORS"):
+ nb_proc = int(os.environ["NUMBER_OF_PROCESSORS"])
+ else:
+ nb_proc = 1
+ else:
+ nb_proc=int(os.sysconf('SC_NPROCESSORS_ONLN'))
return nb_proc