/[gli]/trunk/src/fe/dialog/dialogfe.py
Gentoo

Diff of /trunk/src/fe/dialog/dialogfe.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 602 Revision 603
58 output_string = output_string[index:] 58 output_string = output_string[index:]
59 59
60 return output_list 60 return output_list
61 61
62def set_partitions(): 62def set_partitions():
63 if not d.yesno("This will reset any changes you have made. Continue?") == DLG_YES: return
64# devices = copy.deepcopy(install_profile.get_partition_tables()) 63 devices = install_profile.get_partition_tables()
65 devices = {} 64 drives = devices.keys()
66 drives = GLIStorageDevice.detect_devices()
67 drives.sort() 65 drives.sort()
68# use_existing = False
69# if not devices: 66 if not devices:
70 use_existing = local_install #(d.yesno("Do you want to use the existing disk partitions?") == DLG_YES) 67 tmp_drives = GLIStorageDevice.detect_devices()
68 tmp_drives.sort()
71 for drive in drives: 69 for drive in tmp_drives:
72 devices[drive] = GLIStorageDevice.Device(drive) 70 devices[drive] = GLIStorageDevice.Device(drive)
71 if local_install:
73 if use_existing: devices[drive].set_partitions_from_disk() 72 devices[drive].set_partitions_from_disk()
73 drives.append(drive)
74 while 1: 74 while 1:
75 code, drive_to_partition = d.menu("Which drive would you like to partition?", choices=dmenu_list_to_choices(drives), cancel="Done") 75 code, drive_to_partition = d.menu("Which drive would you like to partition?", choices=dmenu_list_to_choices(drives), cancel="Done")
76 if code != DLG_OK: break 76 if code != DLG_OK: break
77 drive_to_partition = drives[int(drive_to_partition)-1] 77 drive_to_partition = drives[int(drive_to_partition)-1]
78 while 1: 78 while 1:
79 partitions = devices[drive_to_partition].get_partitions() 79 partitions = devices[drive_to_partition].get_partitions()
80 partsmenu = devices[drive_to_partition].get_ordered_partition_list() 80 partlist = devices[drive_to_partition].get_ordered_partition_list()
81 tmpparts = devices[drive_to_partition].get_partitions()
82 partsmenu = []
83 for part in partlist:
84 tmppart = tmpparts[part]
85 entry = ""
86 if tmppart.get_type() == "free":
87 entry = "Unallocated space ("
88 if tmppart.is_logical():
89 entry += "logical, "
90 entry += str(tmppart.get_mb()) + "MB)"
91 elif tmppart.get_type() == "extended":
92 entry = str(int(tmppart.get_minor())) + " - Extended (" + str(tmppart.get_mb()) + "MB)"
93 else:
94 entry = str(int(tmppart.get_minor())) + " - "
95 # Type: " + tmppart.get_type() + ", Mountpoint: " + tmppart.get_mountpoint() + ", Mountopts: " + tmppart.get_mountopts() + "("
96 if tmppart.is_logical():
97 entry += "Logical ("
98 else:
99 entry += "Primary ("
100 entry += tmppart.get_type() + ", "
101 entry += (tmppart.get_mountpoint() or "none") + ", "
102 entry += (tmppart.get_mountopts() or "none") + ", "
103 entry += str(tmppart.get_mb()) + "MB)"
104 partsmenu.append(entry)
81 code, part_to_edit = d.menu("Which partition would you like to edit?", width=70, choices=dmenu_list_to_choices(partsmenu), cancel="Back") 105 code, part_to_edit = d.menu("Select a partition or unallocated space to edit", width=70, choices=dmenu_list_to_choices(partsmenu), cancel="Back")
82 if code != DLG_OK: break 106 if code != DLG_OK: break
83 part_to_edit = partsmenu[int(part_to_edit)-1] 107 part_to_edit = partlist[int(part_to_edit)-1]
84 if re.compile("^Free Space").match(part_to_edit) != None: 108 tmppart = tmpparts[part_to_edit]
85 new_start, new_end = re.compile("^Free Space \((\d+)\s*-\s*(\d+)\)").match(part_to_edit).groups() 109 if tmppart.get_type() == "free":
86 code, new_start2 = d.inputbox("New partition start (minimum " + new_start + ")?", init=new_start) 110 free_mb = tmppart.get_mb()
111 code, new_mb = d.inputbox("Size of new partition in MB (max " + str(free_mb) + "MB):", init=str(free_mb))
87 if code != DLG_OK: continue 112 if code != DLG_OK: continue
88 code, new_end2 = d.inputbox("New partition end (maximum " + new_end + ")?", init=new_end) 113 if int(new_mb) > free_mb:
89 if code != DLG_OK: continue 114 d.msgbox("The size you entered (" + new_mb + "MB) is larger than the maximum of " + str(free_mb) + "MB")
90 minor = devices[drive_to_partition].get_partition_at(int(new_start) - 1) + 1 115 continue
91 part_types = ["ext2", "ext3", "linux-swap", "fat32", "ntfs", "extended", "other"] 116 part_types = ["ext2", "ext3", "linux-swap", "fat32", "ntfs", "extended", "other"]
92 code, type = d.menu("Type for new partition (reiserfs not yet supported!)", choices=dmenu_list_to_choices(part_types)) 117 code, type = d.menu("Type for new partition (reiserfs not yet supported!)", choices=dmenu_list_to_choices(part_types))
93 if code != DLG_OK: continue 118 if code != DLG_OK: continue
94 type = part_types[int(type)-1] 119 type = part_types[int(type)-1]
95 if type == "other": 120 if type == "other":
96 code, type = d.inputbox("New partition's type?") 121 code, type = d.inputbox("New partition's type:")
97 if code != DLG_OK: continue 122 if code != DLG_OK: continue
98 if (int(new_start2) < int(new_start)) or (int(new_end2) > int(new_end)): 123 devices[drive_to_partition].add_partition(part_to_edit, int(new_mb), 0, 0, type)
99 d.msgbox("Cannot create new partition because it is not within the bounds of the selected free space.")
100 continue
101 devices[drive_to_partition].add_partition(devices[drive_to_partition].get_free_minor_at(int(new_start2), int(new_end2)), int(new_start2), int(new_end2), type)
102 else: 124 else:
103 while 1: 125 while 1:
104 tmpdevice, tmpminor = re.compile("^(/dev/[a-zA-Z]+)(\d+):").search(part_to_edit).groups() 126 tmppart = tmpparts[part_to_edit]
105 tmppart = partitions[int(tmpminor)] 127 tmptitle = drive_to_partition + str(part_to_edit) + " - "
106 tmptitle = tmpdevice + tmpminor + ": " + str(tmppart.get_start()) + "-" + str(tmppart.get_end()) 128 if tmppart.is_logical():
129 tmptitle += "Logical ("
130 else:
131 tmptitle += "Primary ("
132 tmptitle += tmppart.get_type() + ", "
133 tmptitle += (tmppart.get_mountpoint() or "none") + ", "
134 tmptitle += (tmppart.get_mountopts() or "none") + ", "
135 tmptitle += str(tmppart.get_mb()) + "MB)"
107 menulist = ["Delete", "Mount Point", "Mount Options", "Type", "Format"] 136 menulist = ["Delete", "Mount Point", "Mount Options", "Format"]
108 code, part_action = d.menu(tmptitle, choices=dmenu_list_to_choices(menulist), cancel="Back") 137 code, part_action = d.menu(tmptitle, choices=dmenu_list_to_choices(menulist), cancel="Back")
109 if code != DLG_OK: break 138 if code != DLG_OK: break
110 part_action = menulist[int(part_action)-1] 139 part_action = menulist[int(part_action)-1]
111 if part_action == "Delete": 140 if part_action == "Delete":
112 answer = (d.yesno("Are you sure you want to delete the partition " + tmpdevice + tmpminor + "?") == DLG_YES) 141 answer = (d.yesno("Are you sure you want to delete the partition " + drive_to_partition + str(part_to_edit) + "?") == DLG_YES)
113 if answer == True: 142 if answer == True:
114 tmpdev = tmppart.get_device() 143 tmpdev = tmppart.get_device()
115 tmpdev.remove_partition(int(tmpminor)) 144 tmpdev.remove_partition(part_to_edit)
116 break 145 break
117 elif part_action == "Mount Point": 146 elif part_action == "Mount Point":
118 code, answer = d.inputbox("Enter a mountpoint for partition" + str(tmpminor), init=tmppart.get_mountopts()) 147 code, answer = d.inputbox("Enter a mountpoint for partition " + str(part_to_edit), init=tmppart.get_mountpoint())
119 if code == DLG_OK: tmppart.set_mountpoint(answer) 148 if code == DLG_OK: tmppart.set_mountpoint(answer)
120 elif part_action == "Mount Options": 149 elif part_action == "Mount Options":
121 code, answer = d.inputbox("Enter your options for partition" + str(tmpminor), init=tmppart.get_mountopts()) 150 code, answer = d.inputbox("Enter your mount options for partition " + str(part_to_edit), init=(tmppart.get_mountopts() or "defaults"))
122 if code == DLG_OK: tmppart.set_mountopts(answer) 151 if code == DLG_OK: tmppart.set_mountopts(answer)
123 elif part_action == "Type":
124 part_types = ["ext2", "ext3", "linux-swap", "fat32", "ntfs", "extended", "other"]
125 code, type = d.menu("Type for partition (reiserfs not supported!)", choices=dmenu_list_to_choices(part_types))
126 if code != DLG_OK: continue
127 type = part_types[int(type)-1]
128 if type == "other":
129 code, type = d.inputbox("Partition's type?")
130 tmppart.set_type(type)
131 elif part_action == "Format": 152 elif part_action == "Format":
132 answer = d.yesno("Do you want to format this partition?") 153 code = d.yesno("Do you want to format this partition?")
133 if code == DLG_YES: 154 if code == DLG_YES:
134 tmppart.set_format(True) 155 tmppart.set_format(True)
135 else: 156 else:
136 tmppart.set_format(False) 157 tmppart.set_format(False)
137 158
138 if d.yesno("Would you like to save changes?") == DLG_YES:
139 parts_tmp = {}
140 for part in devices.keys():
141 parts_tmp[part] = devices[part].get_install_profile_structure()
142 install_profile.set_partition_tables(parts_tmp) 159 install_profile.set_partition_tables(devices)
143 160
144def set_network_mounts(): 161def set_network_mounts():
145# This is where any NFS mounts will be specified 162# This is where any NFS mounts will be specified
146 network_mounts = copy.deepcopy(install_profile.get_network_mounts()) 163 network_mounts = copy.deepcopy(install_profile.get_network_mounts())
147 while 1: 164 while 1:

Legend:
Removed from v.602  
changed lines
  Added in v.603

  ViewVC Help
Powered by ViewVC 1.1.20