| OLD | NEW |
| 1 # Copyright 2015 The LUCI Authors. All rights reserved. | 1 # Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """POSIX specific utility functions.""" | 5 """POSIX specific utility functions.""" |
| 6 | 6 |
| 7 import os | 7 import os |
| 8 import subprocess | 8 import subprocess |
| 9 import sys | 9 import sys |
| 10 | 10 |
| 11 | 11 |
| 12 def _run_df(): | 12 def _run_df(): |
| 13 """Runs df and returns the output.""" | 13 """Runs df and returns the output.""" |
| 14 proc = subprocess.Popen( | 14 proc = subprocess.Popen( |
| 15 ['/bin/df', '-k', '-P'], env={'LANG': 'C'}, | 15 ['/bin/df', '-k', '-P', '-l'], env={'LANG': 'C'}, |
| 16 stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 16 stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 17 for l in proc.communicate()[0].splitlines(): | 17 for l in proc.communicate()[0].splitlines(): |
| 18 l = l.decode('utf-8') | 18 l = l.decode('utf-8') |
| 19 if l.startswith(u'/dev/'): | 19 if l.startswith(u'/dev/'): |
| 20 items = l.split() | 20 items = l.split() |
| 21 if (sys.platform == 'darwin' and | 21 if (sys.platform == 'darwin' and |
| 22 items[5].startswith(u'/Volumes/firmwaresyncd.')): | 22 items[5].startswith(u'/Volumes/firmwaresyncd.')): |
| 23 # There's an issue on OSX where sometimes a small volume is mounted | 23 # There's an issue on OSX where sometimes a small volume is mounted |
| 24 # during boot time and may be caught here by accident. Just ignore it as | 24 # during boot time and may be caught here by accident. Just ignore it as |
| 25 # it could trigger the low free disk space check and cause an unexpected | 25 # it could trigger the low free disk space check and cause an unexpected |
| (...skipping 18 matching lines...) Expand all Loading... |
| 44 # Do not use the value reported by 'df' since it includes all the free | 44 # Do not use the value reported by 'df' since it includes all the free |
| 45 # space, including the free space reserved by root. Since the Swarming bot | 45 # space, including the free space reserved by root. Since the Swarming bot |
| 46 # is likely not running as root, it present an inflated value of what is | 46 # is likely not running as root, it present an inflated value of what is |
| 47 # usable. | 47 # usable. |
| 48 #u'free_mb': round(float(items[3]) / 1024., 1), | 48 #u'free_mb': round(float(items[3]) / 1024., 1), |
| 49 u'free_mb': get_free_space_mb(items[5]), | 49 u'free_mb': get_free_space_mb(items[5]), |
| 50 u'size_mb': round(float(items[1]) / 1024., 1), | 50 u'size_mb': round(float(items[1]) / 1024., 1), |
| 51 } | 51 } |
| 52 for items in _run_df() | 52 for items in _run_df() |
| 53 } | 53 } |
| OLD | NEW |