blob: 7897967a14a9cb7c6cd95f030875a7d127d4308a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#!/usr/bin/python
#
# scan system for harddrives and output device name/size
#
import os
import sys
# for testing
if (os.path.exists('isys')):
sys.path.append('isys')
sys.path.append('/usr/lib/anaconda')
import parted
import partedUtils
import isys
drives = isys.hardDriveDict()
driveList = drives.keys()
driveList.sort()
for drive in driveList:
if isys.driveIsRemovable(drive):
continue
# try to open and get size
skip = 0
deviceFile = "/tmp/%s" % (drive,)
isys.makeDevInode(drive, deviceFile)
try:
dev = parted.PedDevice.get(deviceFile)
except:
skip = 1
os.remove(deviceFile)
if skip:
continue
sizeMB = (float(dev.heads * dev.cylinders * dev.sectors) / (1024 * 1024)
* dev.sector_size)
print drive, sizeMB
|