Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Unified Diff: client/common_lib/hosts/base_classes.py

Issue 6551020: Merge remote branch 'autotest-upstream/master' into try-box1 (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/bin/local_host.py ('k') | client/common_lib/hosts/base_classes_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/common_lib/hosts/base_classes.py
diff --git a/client/common_lib/hosts/base_classes.py b/client/common_lib/hosts/base_classes.py
index e0c240f24b6bd1fdec6274c09dae26bcc8831a99..b267e79f06abe6b812bc43f2c60cd2fdd96a22a4 100644
--- a/client/common_lib/hosts/base_classes.py
+++ b/client/common_lib/hosts/base_classes.py
@@ -228,11 +228,22 @@ class Host(object):
def check_diskspace(self, path, gb):
- # Note: 1 GB = 10**9 bytes (SI unit).
+ """Raises an error if path does not have at least gb GB free.
+
+ @param path The path to check for free disk space.
+ @param gb A floating point number to compare with a granularity
+ of 1 MB.
+
+ 1000 based SI units are used.
+
+ @raises AutoservDiskFullHostError if path has less than gb GB free.
+ """
+ one_mb = 10**6 # Bytes (SI unit).
+ mb_per_gb = 1000.0
logging.info('Checking for >= %s GB of space under %s on machine %s',
gb, path, self.hostname)
- df = self.run('df -PB %d %s | tail -1' % (10**9, path)).stdout.split()
- free_space_gb = int(df[3])
+ df = self.run('df -PB %d %s | tail -1' % (one_mb, path)).stdout.split()
+ free_space_gb = int(df[3])/mb_per_gb
if free_space_gb < gb:
raise error.AutoservDiskFullHostError(path, gb, free_space_gb)
else:
« no previous file with comments | « client/bin/local_host.py ('k') | client/common_lib/hosts/base_classes_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698