Add docstring to reserve_disk_space.

This commit is contained in:
voussoir 2021-12-23 17:45:46 -08:00
parent b59fb409d9
commit 110551f1bf
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -31,10 +31,21 @@ class NotEnoughSpace(Exception):
self.drive = drive self.drive = drive
def reserve_disk_space(reserve, drive): def reserve_disk_space(reserve, drive):
'''
Returns a dotdict containing these values:
{
'free': integer number of free bytes,
'reserve': integer number of requested bytes,
'drive': path string representing the drive we checked
}
Raises NotEnoughSpace if the amount of free disk space on `drive` is less
than `free`.
'''
drive = os.path.abspath(drive) drive = os.path.abspath(drive)
drive = os.path.splitdrive(drive)[0] drive = os.path.splitdrive(drive)[0]
log.debug('Checking drive %s', drive) log.debug('Checking drive %s.', drive)
free = shutil.disk_usage(drive).free free = shutil.disk_usage(drive).free
if free < reserve: if free < reserve: