This page was last modified 09:34, 23 August 2008.
A Python program to show available drive space
From Forum Nokia Wiki
drivespace.py
Python Sample code for S60 mobile devices to show available drive space
To use this utility first download and install python for S60 1.4.1 to your mobile device:
[[1]]
Program output:
Available Drive Space:
User C: 114.1 MB Free
System D: 78.9 MB Free
User E: 990.4 MB Free
Install:
1. Create a Python directory on your mobile device E:Python.
2. Save the code below with a text editor.
3. Using a USB cable connect to PC Suite Phone Browser and open the Python directory.
4. Drag and Drop drivespace.py into the mobile Python directory "Nokia Phone Browser\Nokia N95\Memory Card\Python"
# Example using sysinfo to show available # drive space in MB on a S60 mobile device # For Python 1.4.1 import sysinfo # #drives is a Dictionary datatype drives = sysinfo.free_drivespace() # # print drives # {u'C:': 119627776,u'D:': 79310848,u'Z:': 0,u'E:': 2087256064} # drives = {‘key1’: ‘value1’, ‘key2’: ‘value2’, ‘key3’: ‘value3’, ‘key4’: ‘value4’} # # Do some formatting for pretty output print '' print 'Available Drive Space:' print '' print 'User %8s %8.1f MB Free' % ('C: ', ((drives['C:'])/(1024*1024.0)) ) print 'System %4s %8.1f MB Free' % ('D: ', ((drives['D:'])/(1024*1024.0)) ) print 'User %8s %8.1f MB Free' % ('E: ', ((drives['E:'])/(1024*1024.0)) ) print ''
Notes:
Using the Python Dictionary datatype:
drives = {‘key1’: ‘value1’, ‘key2’: ‘value2’, ‘key3’: ‘value3’, ‘key4’: ‘value4’}
print sysinfo.free_drivespace()
{u'C:': 119627776,u'D:': 79310848,u'Z:': 0,u'E:': 2087256064}
The u before the drive u’C:’ identifies this as a unicode string.
In this example ‘C:’ is the read write user storage on the device. ‘D:’ is the system RAM and ‘E:’ is the memory card. There is also a ‘Z:’ drive for ROM memory but an unsigned python application cannot access the information for this drive so it returns 0.
To access the drive information as a python dictionary type we assign “drives” to the
sysinfo result:
drives = sysinfo.free_drivespace()
Modify and format the result in MB:
print "User C: %0.1f MB Available" % (drives['C:'])/(1024*1024.0))
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problems with N93i and Python | federico2929 | Python | 2 | 2007-05-18 07:41 |
| Memory seems very full (Nokia 6600) ? | tpr007 | General Discussion | 1 | 2004-11-09 12:35 |
| mifdef on non-SDK drive | kanima | Carbide.c++ and CodeWarrior Tools | 3 | 2007-03-12 20:58 |
| users file access webDav | werty1st | Mobile Web Server | 9 | 2007-03-19 07:34 |
| File paths in Symbian C++? | maniac_2k | General Symbian C++ | 5 | 2004-08-05 18:44 |
