Fix the bug when getting flags of partitions, and
hide 'Raid' and 'Boot' button temporarily. modified: new_partition/interface_partition.py modified: new_partition/partition_data.py
This commit is contained in:
@@ -128,8 +128,10 @@ def conform_unit(num_unit, unit = base_unit):
|
||||
def showPartitionWindow():
|
||||
global clb
|
||||
global bb
|
||||
bb = ButtonBar (screen, (("New", "new"),("Delete", "delete"),("Boot", "boot"),\
|
||||
("Raid", "raid"),("OK", "ok", "F12"),("Cancel", "cancel","F11"),('Quit','quit','ESC')))
|
||||
#bb = ButtonBar (screen, (("New", "new"),("Delete", "delete"),("Boot", "boot"),\
|
||||
# ("Raid", "raid"),("OK", "ok", "F12"),("Cancel", "cancel","F11"),('Quit','quit','ESC')))
|
||||
bb = ButtonBar (screen, (("New", "new"),("Delete", "delete"),\
|
||||
("OK", "ok", "F12"),("Cancel", "cancel","F11"),('Quit','quit','ESC')))
|
||||
|
||||
clb = CListbox(height=10, cols=6,
|
||||
col_widths=[19,11,11,11,10,12],
|
||||
@@ -192,7 +194,7 @@ def showPartitionWindow():
|
||||
partition_pretty = partition
|
||||
|
||||
clb.append([" %s" %(partition_pretty),"%s" %(start_pretty),"%s" %(end_pretty),"%s" %(size_pretty),"%s" %(ptype),"%s" %(flags)],\
|
||||
"partition:%s:%s:%s:%s:%s:%s:%s:%s" %(partition, dev, size, start, end, partition_table, size_pretty, pre_partition_name),\
|
||||
"partition:%s:%s:%s:%s:%s:%s:%s:%s:%s" %(partition, dev, size, start, end, partition_table, size_pretty, pre_partition_name, flags),\
|
||||
[LEFT, RIGHT, RIGHT, RIGHT, LEFT, LEFT])
|
||||
|
||||
sg = Grid(2, 3)
|
||||
@@ -1348,6 +1350,41 @@ def main():
|
||||
if bb.buttonPressed(res) == "quit":
|
||||
screen.finish()
|
||||
sys.exit(-1)
|
||||
|
||||
# if bb.buttonPressed(res) == "raid" and re.search('dev:', clb.current()) == None \
|
||||
# and re.search('extended',clb.current()) == None and \
|
||||
# re.search('Free Space',clb.current()) == None:
|
||||
# partition = clb.current().split(":")[1]
|
||||
# dev = clb.current().split(":")[2]
|
||||
# flags = clb.current().split(":")[9]
|
||||
# if re.search('raid',flags):
|
||||
# flags = '' if flags == 'raid' else flags.split(',')[0]
|
||||
# else:
|
||||
# flags = 'raid' if flags == '' else flags + ',raid'
|
||||
#
|
||||
# p_d.Partition.dict[dev]['partition'][partition]['flags'] = flags
|
||||
#
|
||||
# if bb.buttonPressed(res) == "boot" and re.search('dev:', clb.current()) == None \
|
||||
# and re.search('extended',clb.current()) == None and \
|
||||
# re.search('Free Space',clb.current()) == None:
|
||||
# partition = clb.current().split(":")[1]
|
||||
# dev = clb.current().split(":")[2]
|
||||
# label = clb.current().split(":")[6]
|
||||
# flags = clb.current().split(":")[9]
|
||||
# if re.search('boot',flags):
|
||||
# flags = '' if flags == 'boot' else flags.split(',')[1]
|
||||
# else:
|
||||
# flags = 'boot' if flags == '' else 'boot,' + flags
|
||||
# p_d.Partition.dict[dev]['partition'][partition]['flags'] = flags
|
||||
# if label == 'msdos' and re.search('boot', p_d.Partition.dict[dev]['partition'][partition]['flags']):
|
||||
# for p in p_d.sort_partitions(p_d.Partition.dict,dev,'partition'):
|
||||
# if p != partition and re.search('boot', p_d.Partition.dict[dev]['partition'][p]['flags']):
|
||||
# if p_d.Partition.dict[dev]['partition'][p]['flags'] == 'boot':
|
||||
# p_d.Partition.dict[dev]['partition'][p]['flags'] = ''
|
||||
# else:
|
||||
# p_d.Partition.dict[dev]['partition'][p]['flags'] = \
|
||||
# p_d.Partition.dict[dev]['partition'][p]['flags'].split(',')[1].strip()
|
||||
|
||||
# assign label(msdos or gpt) of dev
|
||||
if re.search("dev:", clb.current()) and bb.buttonPressed(res) == "new":
|
||||
dev = clb.current().split(":")[1]
|
||||
|
||||
@@ -54,19 +54,18 @@ def get_flags (part):
|
||||
string=""
|
||||
if not part.is_active ():
|
||||
return string
|
||||
first=1
|
||||
flag = _ped.partition_flag_next (0)
|
||||
first = 1
|
||||
while flag:
|
||||
if part.get_flag (flag):
|
||||
string = string + _ped.partition_flag_get_name (flag)
|
||||
if first:
|
||||
first = 0
|
||||
string = string + _ped.partition_flag_get_name(flag)
|
||||
else:
|
||||
string = string + ", "
|
||||
string = string + ","+ _ped.partition_flag_get_name(flag)
|
||||
flag = _ped.partition_flag_next (flag)
|
||||
return string
|
||||
|
||||
|
||||
'''make nested dict'''
|
||||
def makehash():
|
||||
return defaultdict(makehash)
|
||||
@@ -475,7 +474,8 @@ def init_from_xml():
|
||||
|
||||
if __name__ == "__main__":
|
||||
Partition.init_from_os(unit='s')
|
||||
print Partition.get_disk_from_partition('/dev/sdc7')
|
||||
#print Partition.get_disk_from_partition('/dev/sdc7')
|
||||
get_flags('/dev/sdc1')
|
||||
#for d in Partition.get_raid_devices():
|
||||
# print d
|
||||
#print Partition.dict.keys()
|
||||
|
||||
Reference in New Issue
Block a user