#!/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 anaconda_log 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