summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xseivot16
1 files changed, 15 insertions, 1 deletions
diff --git a/seivot b/seivot
index 4709c1d..66c696c 100755
--- a/seivot
+++ b/seivot
@@ -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