rosclean: #2816 merged patch for FreeBSD support, discarded other bits in patch
This commit is contained in:
parent
271a2189a8
commit
d93f1113a6
|
@ -73,8 +73,8 @@ def get_human_readable_disk_usage(d):
|
||||||
@return: human-readable disk usage (du -h)
|
@return: human-readable disk usage (du -h)
|
||||||
@rtype: str
|
@rtype: str
|
||||||
"""
|
"""
|
||||||
# only implemented on Linux for now. Should work on OS X but need to verify first (du is not identical)
|
# only implemented on Linux and FreeBSD for now. Should work on OS X but need to verify first (du is not identical)
|
||||||
if platform.system() == 'Linux':
|
if platform.system() in ['Linux', 'FreeBSD']:
|
||||||
try:
|
try:
|
||||||
return subprocess.Popen(['du', '-sh', d], stdout=subprocess.PIPE).communicate()[0].split()[0]
|
return subprocess.Popen(['du', '-sh', d], stdout=subprocess.PIPE).communicate()[0].split()[0]
|
||||||
except:
|
except:
|
||||||
|
@ -87,16 +87,21 @@ def get_disk_usage(d):
|
||||||
Get disk usage in bytes for directory
|
Get disk usage in bytes for directory
|
||||||
@param d: directory path
|
@param d: directory path
|
||||||
@type d: str
|
@type d: str
|
||||||
@return: disk usage in bytes (du -b)
|
@return: disk usage in bytes (du -b) or (du -A) * 1024
|
||||||
@rtype: int
|
@rtype: int
|
||||||
@raise ROSCleanException: if get_disk_usage() cannot be used on this platform
|
@raise ROSCleanException: if get_disk_usage() cannot be used on this platform
|
||||||
"""
|
"""
|
||||||
# only implemented on Linux for now. Should work on OS X but need to verify first (du is not identical)
|
# only implemented on Linux and FreeBSD for now. Should work on OS X but need to verify first (du is not identical)
|
||||||
if platform.system() == 'Linux':
|
if platform.system() == 'Linux':
|
||||||
try:
|
try:
|
||||||
return int(subprocess.Popen(['du', '-sb', d], stdout=subprocess.PIPE).communicate()[0].split()[0])
|
return int(subprocess.Popen(['du', '-sb', d], stdout=subprocess.PIPE).communicate()[0].split()[0])
|
||||||
except:
|
except:
|
||||||
raise ROSCleanException("rosclean is not supported on this platform")
|
raise ROSCleanException("rosclean is not supported on this platform")
|
||||||
|
elif platform.system() == 'FreeBSD':
|
||||||
|
try:
|
||||||
|
return int(subprocess.Popen(['du', '-sA', d], stdout=subprocess.PIPE).communicate()[0].split()[0]) * 1024
|
||||||
|
except:
|
||||||
|
raise ROSCleanException("rosclean is not supported on this platform")
|
||||||
else:
|
else:
|
||||||
raise ROSCleanException("rosclean is not supported on this platform")
|
raise ROSCleanException("rosclean is not supported on this platform")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue