From 2f9089d985b24243b64d06b56afaf390e923a4e6 Mon Sep 17 00:00:00 2001 From: Qin Bo Date: Sat, 7 Dec 2013 18:18:49 +0800 Subject: [PATCH] add process patition table is empty modified: partition_data.py Signed-off-by: Qin Bo --- new_partition/partition_data.py | 48 +++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/new_partition/partition_data.py b/new_partition/partition_data.py index 8cabcaf..5cb8151 100755 --- a/new_partition/partition_data.py +++ b/new_partition/partition_data.py @@ -122,16 +122,8 @@ class Partition: ''' each disk ''' for d in Partition.get_disks(): _device = _ped.device_get(d) - try: - _disk = _ped.Disk(_device) - except: - continue - _part = _disk.next_partition() - ''' free partition number ''' - fn = 0 - ''' partition sequence number ''' - sn = 0 - ''' each partition ''' + + dev = _device.path ''' algorithm from parted.c do_print() ''' disk_start = _device.unit_format (0) @@ -141,8 +133,42 @@ class Partition: disk_size = disk_end + try: + _disk = _ped.Disk(_device) + except Exception, message: + m_p = re.compile('.*: unrecognised disk label') + dev = _device.path + + ''' process partition table is empty ''' + if m_p.match(str(message)): + Partition(dev, # device name + disk_size, # disk size + ' ', # partition_table + 'yes', # disk from os + ' ', # partition sequence number + ' ', # partition + ' ', # num + ' ', # start + ' ', # end + ' ', # size + ' ', # type + ' ', # file system + ' ', # flags + 'yes', # partition from os + ' ', # whether format + ' ' # mount point + ) + + continue + + ''' free partition number ''' + fn = 0 + ''' partition sequence number ''' + sn = 0 + partition_table = _disk.type.name - dev = _device.path + ''' each partition ''' + _part = _disk.next_partition() if DEBUG: print dev