diff options
-rwxr-xr-x | seivot | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -47,11 +47,25 @@ def runcmd(argv, **kwargs): data = os.read(fd, 1024**2) os.close(fd) if p.returncode != 0: - raise Exception('command failed: %s\n%s' % (argv, err)) + raise cliapp.AppException('command failed: %s\n%s' % (argv, err)) return Measurement(data), out +def drop_caches(): + def sudo_tee(status): + p = subprocess.Popen(['sudo', '-p', 'Password (for clearing cache): ', + 'tee', '/proc/sys/vm/drop_caches'], + stdin=subprocess.PIPE, stdout=subprocess.PIPE) + out, err = p.communicate('%s\n' % status) + if p.returncode != 0: + raise cliapp.AppException('failed to clear cache') + + logging.debug('clearing Linux kernel cache') + sudo_tee(3) + sudo_tee(0) + + class BackupProgram(object): name = None |