File: list_devices.py

package info (click to toggle)
pyparted 3.11.7-0.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 936 kB
  • sloc: ansic: 7,184; python: 3,697; makefile: 93; sh: 4
file content (16 lines) | stat: -rw-r--r-- 468 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/python
# simple example on how to list available devices on system
import parted

devices = parted.getAllDevices();

for device in devices:
    geom = device.hardwareGeometry;
    ssize = device.sectorSize;
    size = (geom[0] * geom[1] * geom[2] * ssize) / 1000 / 1000 / 1000;

    print "Model: %s" %   device.model
    print "Size: %s GB" %  size 
    print "Heads: %s" %  geom[0]
    print "Sectors: %s" %  geom[2]
    print "Sector Size: %s" % ssize;