#!/usr/bin/env python import parted import parted.device import parted.disk import sys try: if len(sys.argv) > 2: if sys.argv[2] == 'system': part_order=1 elif sys.argv[2] == 'boot': part_order=0 else: sys.exit(1) else: part_order=0 device = parted.device.Device(sys.argv[1]) disk = parted.Disk(device) print disk.partitions[part_order].path except: pass