diskspace

Find free disk space in python on OS/X

五迷三道 提交于 2019-11-27 00:54:47
问题 I'm looking for the number of free bytes on my HD, but have trouble doing so on python. I've tried the following: import os stat = os.statvfs(path) print stat.f_bsize * stat.f_bavail But, on OS/X it gives me a 17529020874752 bytes, which is about about 1.6 TB, which would be very nice, but unfortunately not really true. What's the best way to get to this figure? 回答1: Try using f_frsize instead of f_bsize . >>> s = os.statvfs('/') >>> (s.f_bavail * s.f_frsize) / 1024 23836592L >>> os.system(

What is the current full install size of Cygwin?

徘徊边缘 提交于 2019-11-26 23:53:46
问题 Every source I found online says a full installation of Cygwin takes over 1 GB, but mine is only 100 MB. I was pretty sure I downloaded everything from the mirror servers, but the install took less than 5 minutes to complete instead of hours, as I'd expect if it were installing gigabytes of software. Did Cygwin get a huge clean-up during 2012~2013, or did I do something wrong in the installation? 回答1: A full Cygwin installation can range from 23 to 112 GiB, depending on how you define "full."

iPhone - Free space left on device reported incorrectly (+- 200 Mb difference)

爱⌒轻易说出口 提交于 2019-11-26 23:23:09
问题 I use this method to get the free space on the disk, extracted from a code found after some researches. float freeSpace = -1.0f; NSError* error = nil; NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSDictionary* dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error]; if (dictionary) { NSNumber* fileSystemSizeInBytes = [dictionary objectForKey:NSFileSystemFreeSize]; freeSpace =

How to check if IOException is Not-Enough-Disk-Space-Exception type?

独自空忆成欢 提交于 2019-11-26 22:07:35
How can I check if IOException is a "Not enough disk space" exception type? At the moment I check to see if the message matches something like "Not enough disk space", but I know that this won't work if the OS language is not English. Justin You need to check the HResult and test against ERROR_DISK_FULL (0x70) and ERROR_HANDLE_DISK_FULL (0x27) , which can be converted to HResults by OR 'ing with 0x80070000 . For .Net Framework 4.5 and above, you can use the Exception.HResult property: static bool IsDiskFull(Exception ex) { const int HR_ERROR_HANDLE_DISK_FULL = unchecked((int)0x80070027); const

Auto compact the deleted space in mongodb?

左心房为你撑大大i 提交于 2019-11-26 18:26:10
The mongodb document says that To compact this space, run db.repairDatabase() from the mongo shell (note this operation will block and is slow). in http://www.mongodb.org/display/DOCS/Excessive+Disk+Space I wonder how to make the mongodb free deleted disk space automatically ? p.s. We stored many downloading task in mongodb, up to 20GB, and finished these in half an hour. In general if you don't need to shrink your datafiles you shouldn't shrink them at all. This is because "growing" your datafiles on disk is a fairly expensive operation and the more space that MongoDB can allocate in

Cross-platform space remaining on volume using python

江枫思渺然 提交于 2019-11-26 15:53:37
I need a way to determine the space remaining on a disk volume using python on linux, Windows and OS X. I'm currently parsing the output of the various system calls (df, dir) to accomplish this - is there a better way? Frankovskyi Bogdan import ctypes import os import platform import sys def get_free_space_mb(dirname): """Return folder/drive free space (in megabytes).""" if platform.system() == 'Windows': free_bytes = ctypes.c_ulonglong(0) ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(dirname), None, None, ctypes.pointer(free_bytes)) return free_bytes.value / 1024 / 1024 else: st

Get free space on internal memory

人走茶凉 提交于 2019-11-26 15:14:26
Is it possible to get the amount of free memory on an Android device (not on the SD CARD) via the Android SDK? If so, how? mad this post might fit well to your question. also check this thread . there is so much info here on SO. googled a bit and here is the solution (found at android git ) File path = Environment.getDataDirectory(); StatFs stat = new StatFs(path.getPath()); long blockSize = stat.getBlockSize(); long availableBlocks = stat.getAvailableBlocks(); return Formatter.formatFileSize(this, availableBlocks * blockSize); /*****************************************************************

Find size and free space of the filesystem containing a given file

一笑奈何 提交于 2019-11-26 15:11:31
I'm using Python 2.6 on Linux. What is the fastest way: to determine which partition contains a given directory or file? For example, suppose that /dev/sda2 is mounted on /home , and /dev/mapper/foo is mounted on /home/foo . From the string "/home/foo/bar/baz" I would like to recover the pair ("/dev/mapper/foo", "home/foo") . and then, to get usage statistics of the given partition? For example, given /dev/mapper/foo I would like to obtain the size of the partition and the free space available (either in bytes or approximately in megabytes). If you just need the free space on a device, see the

Any way to keep curl's cookies in memory and not on disk

早过忘川 提交于 2019-11-26 13:49:06
问题 I'm doing some cURL work in php 5.3.0. I'm wondering if there is any way to tell the curl handle/object to keep the cookies in memory (assuming I'm reusing the same handle for multiple requests), or to somehow return them and let me pass them back when making a new handle. Theres this long accepted method for getting them in/out of the request: curl_setopt($ch, CURLOPT_COOKIEJAR, $filename); curl_setopt($ch, CURLOPT_COOKIEFILE, $filename); But I'm hitting some scenarios where I need to be

Data size in memory vs. on disk

萝らか妹 提交于 2019-11-26 11:22:19
问题 How does the RAM required to store data in memory compare to the disk space required to store the same data in a file? Or is there no generalized correlation? For example, say I simply have a billion floating point values. Stored in binary form, that\'d be 4 billion bytes or 3.7GB on disk (not including headers and such). Then say I read those values into a list in Python... how much RAM should I expect that to require? 回答1: Python Object Data Size If the data is stored in some python object,