File: list_devices.py

package info (click to toggle)
pyparted 3.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 952 kB
  • sloc: ansic: 7,453; python: 4,579; makefile: 91; sh: 4
file content (16 lines) | stat: -rw-r--r-- 469 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/python3
# 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;