473,382 Members | 1,447 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Space left on device

Is there any function to see how much space is left on a device (such
as a usb key)? I'm trying to fill in an mp3 reader in a little script,
and this information could be very useful! Thanks!

Jan 16 '06 #1
1 2139
rbt
sir_alex wrote:
Is there any function to see how much space is left on a device (such
as a usb key)? I'm trying to fill in an mp3 reader in a little script,
and this information could be very useful! Thanks!


On windows with the win32 extensions, you might try this:

# Get hard drive info from Windows.
drive = win32api.GetDiskFreeSpace('c:')
print drive[0], "sectors per cluster."
print drive[1], "bytes per sector."
print drive[2], "free clusters."
print drive[3], "total clusters."

You could use wmi to discover where the device has been mounted:
for item in c.Win32_DiskDrive():
print item

instance of Win32_DiskDrive
{
BytesPerSector = 512;
Capabilities = {3, 4, 7};
Caption = "M-SysT5 Dell Memory Key USB Device";
ConfigManagerErrorCode = 0;
ConfigManagerUserConfig = FALSE;
CreationClassName = "Win32_DiskDrive";
Description = "Disk drive";
DeviceID = "\\\\.\\PHYSICALDRIVE1";
Index = 1;
InterfaceType = "USB";
Manufacturer = "(Standard disk drives)";
MediaLoaded = TRUE;
MediaType = "Removable media other than\tfloppy";
Model = "M-SysT5 Dell Memory Key USB Device";
Name = "\\\\.\\PHYSICALDRIVE1";
Partitions = 1;
PNPDeviceID =
"USBSTOR\\DISK&VEN_M-SYST5&PROD_DELL_MEMORY_KEY&REV_5.00\\09809350C300C 9D7&0";
SectorsPerTrack = 63;
Signature = 2865277640;
Size = "254983680";
Status = "OK";
....
Jan 16 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: Aurangzeb M. Agha | last post by:
I'm running Postgres 7.1.3, and just started having a problem where my dynamic site is going down (read-only DB, with no writes happening to the DB) regularly (every other day). I have no idea...
0
by: sir_alex | last post by:
Is there any function to see how much space is left on a device (such as a usb key)? I'm trying to fill in an mp3 reader in a little script, and this information could be very useful! Thanks!
5
by: mostro713 | last post by:
Hello all, I would like to write a script in Python to email me when disk space gets below a certain value. My first question (I'm sure of many) is how do get this output into a dictionary or...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.