File: test.py

package info (click to toggle)
python-parted 0.10-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 924 kB
  • ctags: 342
  • sloc: ansic: 1,039; python: 512; makefile: 70; sh: 13
file content (48 lines) | stat: -rw-r--r-- 1,469 bytes parent folder | download
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
46
47
48
import parted
import sys

parted.init()
parted.device_probe_all()

device = parted.get_devices()[0]
disk = device.disk_open()
print disk.get_dev().get_path(), disk.get_type().get_name()

partlist = disk.get_part_list()
for part in partlist:
    print part.get_num(), part.get_bootable(), part.get_type(), \
          part.get_system()
    if part.get_fs_type() is not None:
        print "  " + part.get_fs_type().get_name()

disk.close()

################################################################################

print "Testing disk types..."

for dt in parted.get_disk_types():
    print dt.get_name()

print parted.disk_type_get("msdos").get_name()

################################################################################

for device in parted.get_devices():
    print (device.get_model(), device.get_type(), device.get_sector_size(),
           device.get_heads(), device.get_sectors(), device.get_cylinders(),
           device.get_geom_known(), device.get_host(), device.get_did(),
           device.get_length(), device.get_dirty())

################################################################################

device = parted.device_get("/dev/hda")

print (device.get_model(), device.get_type(), device.get_sector_size(),
       device.get_heads(), device.get_sectors(), device.get_cylinders(),
       device.get_geom_known(), device.get_host(), device.get_did(),
       device.get_length(), device.get_dirty())

parted.done()
sys.exit()