This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author carstenkoch
Recipients carstenkoch, davidsarah, effbot, gvanrossum, tim.peters
Date 2011-01-09.14:07:47
SpamBayes Score 0.020935247
Marked as misclassified No
Message-id <1294582073.74.0.0391870696767.issue410547@psf.upfronthosting.co.za>
In-reply-to
Content
Here is what I am doing now:

...
if sys.platform == "win32":
   import win32file
else:
   import statvfs
...


def get_free_space(path = '.'):
   """
      Determine the free space in bytes for the given path.
   """
   if sys.platform == "win32":
      sizes = win32file.GetDiskFreeSpace(path)
      return sizes[0] * sizes[1] * sizes[2]
   else:
      status = os.statvfs(path)
      return status[statvfs.F_BAVAIL] * status[statvfs.F_FRSIZE]



def get_partition_size(path = '.'):
   """
      Determine the total space in bytes for the given path.
   """
   if sys.platform == "win32":
      sizes = win32file.GetDiskFreeSpace(path)
      return sizes[0] * sizes[1] * sizes[3]
   else:
      status = os.statvfs(path)
      return status[statvfs.F_BLOCKS] * status[statvfs.F_FRSIZE]
History
Date User Action Args
2011-01-09 14:07:53carstenkochsetrecipients: + carstenkoch, gvanrossum, tim.peters, effbot, davidsarah
2011-01-09 14:07:53carstenkochsetmessageid: <1294582073.74.0.0391870696767.issue410547@psf.upfronthosting.co.za>
2011-01-09 14:07:47carstenkochlinkissue410547 messages
2011-01-09 14:07:47carstenkochcreate