aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/__init__.py1
-rw-r--r--src/benchmarks/__init__.py1
-rw-r--r--src/facter.py11
-rw-r--r--src/util.py26
4 files changed, 24 insertions, 15 deletions
diff --git a/src/__init__.py b/src/__init__.py
index 0334b3a..d989a60 100644
--- a/src/__init__.py
+++ b/src/__init__.py
@@ -14,7 +14,6 @@
#
# You should have received a copy of the GNU General Public License
# along with allocbench. If not, see <http://www.gnu.org/licenses/>.
-
"""A framework linking allocators to applications"""
__author__ = "Florian Fischer"
diff --git a/src/benchmarks/__init__.py b/src/benchmarks/__init__.py
index f7cc8d7..68b5e56 100644
--- a/src/benchmarks/__init__.py
+++ b/src/benchmarks/__init__.py
@@ -14,5 +14,4 @@
#
# You should have received a copy of the GNU General Public License
# along with allocbench. If not, see <http://www.gnu.org/licenses/>.
-
"""allocbench benchmark definitions"""
diff --git a/src/facter.py b/src/facter.py
index c3c95cd..fe0b316 100644
--- a/src/facter.py
+++ b/src/facter.py
@@ -14,7 +14,6 @@
#
# 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
@@ -53,6 +52,7 @@ def collect_facts():
starttime = starttime[:starttime.rfind(':')]
gv.facts["starttime"] = starttime
+
def store_facts(path=None):
"""Store facts to file"""
if not path:
@@ -66,6 +66,7 @@ def store_facts(path=None):
with open(filename, "w") as f:
json.dump(gv.facts, f)
+
def load_facts(path=None):
"""Load facts from file"""
if not path:
@@ -86,10 +87,12 @@ def load_facts(path=None):
with open(filename, "rb") as f:
gv.facts = pickle.load(f)
else:
- raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), filename)
+ raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT),
+ filename)
print_info(f"Loading facts from: {filename}")
+
# Copied from pip.
# https://github.com/pypa/pip/blob/master/src/pip/_internal/utils/glibc.py
# Licensed under MIT.
@@ -148,10 +151,12 @@ def libc_ver(executable=None):
return ("glibc", glibc_version)
+
def exe_version(executable, version_flag="--version"):
"""Return version of executable"""
proc = subprocess.run([executable, version_flag],
- universal_newlines=True, stdout=subprocess.PIPE)
+ universal_newlines=True,
+ stdout=subprocess.PIPE)
if proc.returncode != 0:
print_warning(f"failed to get version of {executable}")
diff --git a/src/util.py b/src/util.py
index c5fa162..7992084 100644
--- a/src/util.py
+++ b/src/util.py
@@ -14,7 +14,6 @@
#
# You should have received a copy of the GNU General Public License
# along with allocbench. If not, see <http://www.gnu.org/licenses/>.
-
"""Helper functions for allocbench"""
import hashlib
@@ -24,6 +23,7 @@ import sys
import src.globalvars
+
def is_exe(fpath):
"""Check if the given path is an exexutable file"""
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
@@ -75,9 +75,11 @@ def allocbench_msg(color, *objects, sep=' ', end='\n', file=sys.stdout):
if src.globalvars.verbosity < 0:
return
- color = {"YELLOW": "\x1b[33m",
- "GREEN": "\x1b[32m",
- "RED": "\x1b[31m"}[color]
+ color = {
+ "YELLOW": "\x1b[33m",
+ "GREEN": "\x1b[32m",
+ "RED": "\x1b[31m"
+ }[color]
is_atty = sys.stdout.isatty()
if is_atty:
@@ -137,14 +139,16 @@ def print_error(*objects, sep=' ', end='\n', file=sys.stderr):
def print_license_and_exit():
"""Print GPL info and Copyright before exit"""
print("Copyright (C) 2018-2019 Florian Fischer")
- print("License GPLv3: GNU GPL version 3 <http://gnu.org/licenses/gpl.html>")
+ print(
+ "License GPLv3: GNU GPL version 3 <http://gnu.org/licenses/gpl.html>")
exit(0)
def print_version_and_exit():
"""Print current commit info before exit"""
proc = subprocess.run(["git", "rev-parse", "HEAD"],
- universal_newlines=True, stdout=subprocess.PIPE)
+ universal_newlines=True,
+ stdout=subprocess.PIPE)
if proc.returncode != 0:
print_error("git rev-parse failed")
@@ -152,7 +156,8 @@ def print_version_and_exit():
commit = proc.stdout[:-1]
proc = subprocess.run(["git", "status", "--porcelain"],
- universal_newlines=True, stdout=subprocess.PIPE)
+ universal_newlines=True,
+ stdout=subprocess.PIPE)
if proc.returncode != 0:
print_error("git status --porcelain failed")
@@ -163,12 +168,13 @@ def print_version_and_exit():
print(f"{commit}{dirty}")
exit(0)
+
def sha1sum(filename):
"""Return sha1sum of a file"""
- sha1 = hashlib.sha1()
- barray = bytearray(64*1024)
+ sha1 = hashlib.sha1()
+ barray = bytearray(64 * 1024)
view = memoryview(barray)
with open(filename, 'rb', buffering=0) as f:
- for n in iter(lambda : f.readinto(view), 0):
+ for n in iter(lambda: f.readinto(view), 0):
sha1.update(view[:n])
return sha1.hexdigest()