本文整理汇总了Python中nt._getdiskusage方法的典型用法代码示例。如果您正苦于以下问题:Python nt._getdiskusage方法的具体用法?Python nt._getdiskusage怎么用?Python nt._getdiskusage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nt
的用法示例。
在下文中一共展示了nt._getdiskusage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: disk_usage
# 需要导入模块: import nt [as 别名]
# 或者: from nt import _getdiskusage [as 别名]
def disk_usage(path):
"""Return disk usage statistics about the given path.
Returned values is a named tuple with attributes 'total', 'used' and
'free', which are the amount of total, used and free space, in bytes.
"""
total, free = nt._getdiskusage(path)
used = total - free
return _ntuple_diskusage(total, used, free)
示例2: test_nt_helpers
# 需要导入模块: import nt [as 别名]
# 或者: from nt import _getdiskusage [as 别名]
def test_nt_helpers(self):
# Trivial validation that the helpers do not break, and support both
# unicode and bytes (UTF-8) paths
drive, path = ntpath.splitdrive(sys.executable)
drive = drive.rstrip(ntpath.sep) + ntpath.sep
self.assertEqual(drive, nt._getvolumepathname(sys.executable))
self.assertEqual(drive.encode(),
nt._getvolumepathname(sys.executable.encode()))
cap, free = nt._getdiskusage(sys.exec_prefix)
self.assertGreater(cap, 0)
self.assertGreater(free, 0)
b_cap, b_free = nt._getdiskusage(sys.exec_prefix.encode())
# Free space may change, so only test the capacity is equal
self.assertEqual(b_cap, cap)
self.assertGreater(b_free, 0)
for path in [sys.prefix, sys.executable]:
final_path = nt._getfinalpathname(path)
self.assertIsInstance(final_path, str)
self.assertGreater(len(final_path), 0)
b_final_path = nt._getfinalpathname(path.encode())
self.assertIsInstance(b_final_path, bytes)
self.assertGreater(len(b_final_path), 0)