From dfbd89b928653f6616d0262d79b4362c7caec249 Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Sat, 15 Jan 2022 17:57:28 +0100 Subject: [PATCH] file ownerships --- tools/CacheAnalyzer/cacheGraph.py | 4 +++- tools/CacheAnalyzer/permPolicy.py | 1 + tools/CacheAnalyzer/replPolicy.py | 2 ++ tools/CacheAnalyzer/setDueling.py | 2 ++ tools/CacheAnalyzer/strideGraph.py | 2 ++ tools/cpuBench/cpuBench.py | 9 +++++++-- 6 files changed, 17 insertions(+), 3 deletions(-) diff --git a/tools/CacheAnalyzer/cacheGraph.py b/tools/CacheAnalyzer/cacheGraph.py index c931bbe..2d1b393 100755 --- a/tools/CacheAnalyzer/cacheGraph.py +++ b/tools/CacheAnalyzer/cacheGraph.py @@ -4,6 +4,7 @@ from itertools import count from collections import namedtuple, OrderedDict import argparse +import os import sys from cacheLib import * @@ -84,7 +85,8 @@ def main(): with open(args.output ,'w') as f: f.write('\n'.join(html)) print('Graph written to ' + args.output) - + if not args.sim: + os.chown(args.output, int(os.environ['SUDO_UID']), int(os.environ['SUDO_GID'])) if __name__ == "__main__": main() diff --git a/tools/CacheAnalyzer/permPolicy.py b/tools/CacheAnalyzer/permPolicy.py index a495773..e0d7ca2 100755 --- a/tools/CacheAnalyzer/permPolicy.py +++ b/tools/CacheAnalyzer/permPolicy.py @@ -106,6 +106,7 @@ def main(): with open(args.output ,'w') as f: f.write('\n'.join(html)) + os.chown(args.output, int(os.environ['SUDO_UID']), int(os.environ['SUDO_GID'])) else: policyClass = cacheSim.AllPolicies[args.sim] cacheSim.getPermutations(policyClass, args.simAssoc) diff --git a/tools/CacheAnalyzer/replPolicy.py b/tools/CacheAnalyzer/replPolicy.py index 5e69e99..5678380 100755 --- a/tools/CacheAnalyzer/replPolicy.py +++ b/tools/CacheAnalyzer/replPolicy.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import argparse +import os import random import sys @@ -165,6 +166,7 @@ def main(): with open(args.output ,'w') as f: f.write('\n'.join(html)) + os.chown(args.output, int(os.environ['SUDO_UID']), int(os.environ['SUDO_GID'])) if not args.randPolicies and not args.best: print('Possible policies: ' + ', '.join(possiblePolicies)) diff --git a/tools/CacheAnalyzer/setDueling.py b/tools/CacheAnalyzer/setDueling.py index 8f73478..8257f89 100755 --- a/tools/CacheAnalyzer/setDueling.py +++ b/tools/CacheAnalyzer/setDueling.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import argparse +import os import random from plotly.offline import plot @@ -123,6 +124,7 @@ def main(): with open(args.output ,'w') as f: f.write('\n'.join(html)) print('Output written to ' + args.output) + os.chown(args.output, int(os.environ['SUDO_UID']), int(os.environ['SUDO_GID'])) if __name__ == "__main__": diff --git a/tools/CacheAnalyzer/strideGraph.py b/tools/CacheAnalyzer/strideGraph.py index ae80f86..ef516d0 100755 --- a/tools/CacheAnalyzer/strideGraph.py +++ b/tools/CacheAnalyzer/strideGraph.py @@ -2,6 +2,7 @@ import argparse import math +import os import plotly.graph_objects as go from plotly.offline import plot @@ -59,6 +60,7 @@ def main(): with open(args.output ,'w') as f: f.write('\n'.join(html)) print('Graph written to ' + args.output) + os.chown(args.output, int(os.environ['SUDO_UID']), int(os.environ['SUDO_GID'])) if __name__ == "__main__": main() diff --git a/tools/cpuBench/cpuBench.py b/tools/cpuBench/cpuBench.py index aac0923..49c44db 100755 --- a/tools/cpuBench/cpuBench.py +++ b/tools/cpuBench/cpuBench.py @@ -2793,7 +2793,8 @@ def writeHtmlFile(folder, instrNode, title, body): folder = '/tmp/cpu-html/' + folder if not os.path.exists(folder): os.makedirs(folder) - with open(os.path.join(folder, filename), "w") as f: + htmlFilename = os.path.join(folder, filename) + with open(htmlFilename, "w") as f: f.write('\n' '\n' '' + title + '\n' @@ -2802,6 +2803,7 @@ def writeHtmlFile(folder, instrNode, title, body): + body + '\n' '\n') + os.chown(htmlFilename, int(os.environ['SUDO_UID']), int(os.environ['SUDO_GID'])) # returns list of xml instruction nodes @@ -3492,9 +3494,12 @@ def main(): rough_string = ET.tostring(XMLRoot, 'utf-8') reparsed = minidom.parseString(rough_string) f.write('\n'.join([line for line in reparsed.toprettyxml(indent=' ').split('\n') if line.strip()])) + os.chown(args.output, int(os.environ['SUDO_UID']), int(os.environ['SUDO_GID'])) - with tarfile.open('genhtml-' + arch + (('-IACA' + iacaVersion) if useIACA else '-Measurements') + '.tar.gz', "w:gz") as tar: + tarFilename = 'genhtml-' + arch + (('-IACA' + iacaVersion) if useIACA else '-Measurements') + '.tar.gz' + with tarfile.open(tarFilename, "w:gz") as tar: tar.add('/tmp/cpu-html/', arcname=os.path.sep) + os.chown(tarFilename, int(os.environ['SUDO_UID']), int(os.environ['SUDO_GID'])) shutil.rmtree('/tmp/cpu-html/')