aboutsummaryrefslogtreecommitdiff
path: root/src/facter.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/facter.py')
-rw-r--r--src/facter.py35
1 files changed, 28 insertions, 7 deletions
diff --git a/src/facter.py b/src/facter.py
index 8dea288..8e01142 100644
--- a/src/facter.py
+++ b/src/facter.py
@@ -1,3 +1,22 @@
+# Copyright 2018-2019 Florian Fischer <florian.fl.fischer@fau.de>
+#
+# This file is part of allocbench.
+#
+# allocbench is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# allocbench is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with allocbench. If not, see <http://www.gnu.org/licenses/>.
+
+"""Collect facts about the benchmark environment"""
+
import ctypes
import datetime
import multiprocessing
@@ -9,6 +28,7 @@ import src.globalvars as gv
def collect_facts():
+ """Collect facts ad store them in src.globalvars.facts"""
# Populate src.globalvars.facts on import
_uname = platform.uname()
gv.facts["hostname"] = _uname.node
@@ -34,7 +54,7 @@ def collect_facts():
# Copied from pip.
# https://github.com/pypa/pip/blob/master/src/pip/_internal/utils/glibc.py
# Licensed under MIT.
-def glibc_version_string(bin=None):
+def glibc_version_string(executable=None):
"Returns glibc version string, or None if not using glibc."
# ctypes.CDLL(None) internally calls dlopen(NULL), and as the dlopen
@@ -42,7 +62,7 @@ def glibc_version_string(bin=None):
# main program". This way we can let the linker do the work to figure out
# which libc our process is actually using.
try:
- process_namespace = ctypes.CDLL(bin)
+ process_namespace = ctypes.CDLL(executable)
except OSError:
return None
@@ -80,10 +100,11 @@ def glibc_version_string(bin=None):
# versions that was generated by pip 8.1.2 and earlier is useless and
# misleading. Solution: instead of using platform, use our code that actually
# works.
-def libc_ver(bin=None):
- glibc_version = glibc_version_string(bin)
+def libc_ver(executable=None):
+ """Return glibc version or platform.libc_ver as fallback"""
+ glibc_version = glibc_version_string(executable)
if glibc_version is None:
# For non-glibc platforms, fall back on platform.libc_ver
- return platform.libc_ver()
- else:
- return ("glibc", glibc_version)
+ return platform.libc_ver(executable)
+
+ return ("glibc", glibc_version)