diff options
author | drebs <drebs@leap.se> | 2017-04-19 10:18:27 +0200 |
---|---|---|
committer | drebs <drebs@leap.se> | 2017-04-19 11:49:42 +0200 |
commit | 40f2cb8b1f07b1346e01ff69b57e14c492f1cd0b (patch) | |
tree | 9cab2f54014ffb7a56e1d75fd5ef0a70369afd63 /scripts/docker/files/bin/util.py | |
parent | a4558ea4874e0de3561f228b41ef0a94a2e4c326 (diff) |
[test] remove docker scripts from this repo
Docker scripts are only used for CI and do not need to be in this
repository. Beause of that, we decided to moved the docker scripts to a
private repository where dockerfiles for other parts of leap also live.
Diffstat (limited to 'scripts/docker/files/bin/util.py')
-rw-r--r-- | scripts/docker/files/bin/util.py | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/scripts/docker/files/bin/util.py b/scripts/docker/files/bin/util.py deleted file mode 100644 index e7e2ef9a..00000000 --- a/scripts/docker/files/bin/util.py +++ /dev/null @@ -1,75 +0,0 @@ -import re -import psutil -import time -import threading -import argparse -import pytz -import datetime - - -class ValidateUserHandle(argparse.Action): - def __call__(self, parser, namespace, values, option_string=None): - m = re.compile('^([^@]+)@([^@]+\.[^@]+)$') - res = m.match(values) - if res == None: - parser.error('User handle should have the form user@provider.') - setattr(namespace, 'username', res.groups()[0]) - setattr(namespace, 'provider', res.groups()[1]) - - -class StatsLogger(threading.Thread): - - def __init__(self, name, fname, procs=[], interval=0.01): - threading.Thread.__init__(self) - self._stopped = True - self._name = name - self._fname = fname - self._procs = self._find_procs(procs) - self._interval = interval - - def _find_procs(self, procs): - return filter(lambda p: p.name in procs, psutil.process_iter()) - - def run(self): - self._stopped = False - with open(self._fname, 'w') as f: - self._start = time.time() - f.write(self._make_header()) - while self._stopped is False: - f.write('%s %s\n' % - (self._make_general_stats(), self._make_proc_stats())) - time.sleep(self._interval) - f.write(self._make_footer()) - - def _make_general_stats(self): - now = time.time() - stats = [] - stats.append("%f" % (now - self._start)) # elapsed time - stats.append("%f" % psutil.cpu_percent()) # total cpu - stats.append("%f" % psutil.virtual_memory().percent) # total memory - return ' '.join(stats) - - def _make_proc_stats(self): - stats = [] - for p in self._procs: - stats.append('%f' % p.get_cpu_percent()) # proc cpu - stats.append('%f' % p.get_memory_percent()) # proc memory - return ' '.join(stats) - - def _make_header(self): - header = [] - header.append('# test_name: %s' % self._name) - header.append('# start_time: %s' % datetime.datetime.now(pytz.utc)) - header.append( - '# elapsed_time total_cpu total_memory proc_cpu proc_memory ') - return '\n'.join(header) + '\n' - - def _make_footer(self): - footer = [] - footer.append('# end_time: %s' % datetime.datetime.now(pytz.utc)) - return '\n'.join(footer) - - def stop(self): - self._stopped = True - - |