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

Contents of /trunk/src/fe/dialog/gli-dialog.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1122 - (show annotations) (download) (as text)
Fri Dec 2 02:50:50 2005 UTC (12 years, 8 months ago) by codeman
File MIME type: text/x-python
File size: 12045 byte(s)
  added debug mode question to gli-dialog
  added CC proxies to CC networking for gli-dialog

1 #!/usr/bin/python
2 # Copyright 1999-2005 Gentoo Foundation
3 # This source code is distributed under the terms of version 2 of the GNU
4 # General Public License as published by the Free Software Foundation, a copy
5 # of which can be found in the main directory of this project.
6
7 import sys
8 sys.path.append("../..")
9
10 import dialog
11 import GLIException, GLIInstallProfile, GLIClientConfiguration, GLIClientController, GLIUtility, GLIStorageDevice
12 from GLIGenDialog import GLIGenCF,GLIGenIP
13 import string, copy, time, re, glob, os, platform
14 import gettext
15 _ = gettext.gettext
16
17 class Setup_CConfig(GLIGenCF):
18 def __init__(self, client_profile, local_install, advanced_mode):
19 GLIGenCF.__init__(self, client_profile, local_install, advanced_mode)
20 self.set_arch_template()
21 self.set_verbose()
22 self.set_logfile()
23 self.set_root_mount_point()
24 self.set_client_networking()
25 self.set_enable_ssh()
26 self.set_livecd_password()
27 self.set_client_kernel_modules()
28 self.client_config_xml_file = None
29 if advanced_mode:
30 if d.yesno(_(u"Do you want to save the ClientConfiguration XML file before continuing? (it will be automatically saved before the install begins)")) == DLG_YES:
31 self.client_config_xml_file = self.save_client_profile()
32
33 class Setup_InstallProfile(GLIGenIP):
34 def __init__(self, client_profile, install_profile, local_install, advanced_mode):
35 GLIGenIP.__init__(self, client_profile, install_profile, local_install, advanced_mode)
36 show_review_menu = True
37 #Change the Yes/No buttons to new labels for this question.
38 d.add_persistent_args(["--yes-label", _(u"Wizard Mode")])
39 d.add_persistent_args(["--no-label", _(u"Skip to Menu")])
40 if d.yesno(_(u"The Gentoo Linux Installer can either take you step by step through the installation settings (recommended), or you can instead go straight to the Revisions menu to set your settings before the installation begins."), width=66) == DLG_YES:
41 self.set_partitions()
42 self.set_network_mounts()
43 self.set_install_stage()
44 self.set_portage_tree()
45 self.set_make_conf()
46 if advanced_mode:
47 self.set_distcc()
48 self.set_kernel()
49 self.set_boot_loader()
50 self.set_timezone()
51 self.set_networking()
52 if advanced_mode:
53 self.set_cron_daemon()
54 self.set_logger()
55 self.set_extra_packages()
56 if advanced_mode:
57 self.set_services()
58 self.set_rc_conf()
59 self.set_root_password()
60 self.set_additional_users()
61 self.show_settings()
62 #Reset the Yes/No labels.
63 d.add_persistent_args(["--yes-label", "Yes"])
64 d.add_persistent_args(["--no-label","No"])
65 if d.yesno(_(u"Do you want to change any of your settings before starting the actual installation?")) == DLG_NO:
66 show_review_menu = False
67 if show_review_menu:
68 self._fn = (
69 { 'text': "Partitioning", 'fn': self.set_partitions },
70 { 'text': "Network mounts", 'fn': self.set_network_mounts },
71 { 'text': "Install Stage", 'fn': self.set_install_stage },
72 { 'text': "Portage Tree", 'fn': self.set_portage_tree },
73 { 'text': "make.conf", 'fn': self.set_make_conf },
74 { 'text': "distcc", 'fn': self.set_distcc },
75 { 'text': "etc/portage/*", 'fn': self.set_etc_portage },
76 { 'text': "Kernel", 'fn': self.set_kernel },
77 { 'text': "Bootloader", 'fn': self.set_boot_loader },
78 { 'text': "Timezone", 'fn': self.set_timezone },
79 { 'text': "Networking", 'fn': self.set_networking },
80 { 'text': "Cron daemon", 'fn': self.set_cron_daemon },
81 { 'text': "Logging daemon", 'fn': self.set_logger },
82 { 'text': "Extra packages", 'fn': self.set_extra_packages },
83 { 'text': "Services", 'fn': self.set_services },
84 { 'text': "Configuration Settings", 'fn': self.set_rc_conf },
85 { 'text': "Root password", 'fn': self.set_root_password },
86 { 'text': "Additional Users", 'fn': self.set_additional_users })
87 self._menu_list = []
88 for item in self._fn:
89 self._menu_list.append(item['text'])
90 current_item = 0
91 while 1:
92 code, menuitem = self._d.menu("Choose an option", choices=self._dmenu_list_to_choices(self._menu_list), default_item=str(current_item), height=23, menu_height=17, cancel="Done")
93 if code != DLG_OK:
94 break
95 current_item = int(menuitem)
96 menuitem = self._menu_list[int(menuitem)-1]
97 for item in self._fn:
98 if menuitem == item['text']:
99 item['fn']()
100 current_item += 1
101 self.install_profile_xml_file = None
102 #Reset the Yes/No labels.
103 d.add_persistent_args(["--yes-label", "Yes"])
104 d.add_persistent_args(["--no-label","No"])
105 if d.yesno(_(u"Do you want to save the InstallProfile XML file?")) == DLG_YES:
106 self.install_profile_xml_file = self.save_install_profile()
107
108 # ------------------------------------------------------------------
109 if __name__ == '__main__':
110
111 d = dialog.Dialog()
112 client_profile = GLIClientConfiguration.ClientConfiguration()
113 install_profile = GLIInstallProfile.InstallProfile()
114 cc = GLIClientController.GLIClientController(pretend=False)
115 exception_waiting = None
116 client_config_xml_file = None
117 install_profile_xml_file = None
118 next_step_waiting = False
119 install_done = False
120 local_install = True
121 advanced_mode = False
122
123 DLG_OK = 0
124 DLG_YES = 0
125 DLG_CANCEL = 1
126 DLG_NO = 1
127 DLG_ESC = 2
128 DLG_ERROR = 3
129 DLG_EXTRA = 4
130 DLG_HELP = 5
131
132 d.setBackgroundTitle("Gentoo Linux Installer")
133 welcome_string = _(u"""Welcome to the Gentoo Linux Installer! This program will help install Gentoo on your computer.
134 Before proceeding please thoroughly read the Gentoo Installation Handbook available at
135 http://www.gentoo.org/doc/en/handbook/index.xml \n
136 This installer works by first asking a series of questions to generate an \"installation profile\",
137 which contains all the information needed to install Gentoo.\n
138 NO Changes will be made to your system until you select the "Install!" button.
139 You can save your profile at any time by exiting the installer.
140 You can also load a previously made profile at any time.\n
141 If choosing expert mode, you will make a second profile with configuration settings for the livecd environment and the installer.\n
142 Press OK to continue""")
143 d.msgbox(welcome_string, height=25, width=78, title="Welcome")
144
145 #Change the Yes/No buttons to new labels for this question.
146 d.add_persistent_args(["--yes-label", _(u"Simulate")])
147 d.add_persistent_args(["--no-label", _(u"Real Install")])
148 #This is a temporary question during the development process. In a beta release a real install will be implied.
149 if d.yesno(_(u"Are we performing an actual install or just simulating?"), width=45) == DLG_NO:
150 cc._pretend = False
151 else:
152 cc._pretend = True
153
154 #Set the Yes/No labels.
155 d.add_persistent_args(["--yes-label", "Standard"])
156 d.add_persistent_args(["--no-label","Advanced"])
157 advanced_string = _(u"""This installer has two modes, an advanced mode for those knowledgable with the inner details of their computer and a standard mode where many of the defaults will be chosen for the user for simplicity and to speed up the install process. The advanced mode offers full customizability and is required for generating profiles to be used other computers. \nThe advanced mode is recommended by the developers.
158 """)
159 if d.yesno(advanced_string, width=55, height=15) == DLG_NO:
160 advanced_mode = True
161 local_install = True
162
163 #Reset the Yes/No labels.
164 d.add_persistent_args(["--yes-label", "Yes"])
165 d.add_persistent_args(["--no-label","No"])
166 if advanced_mode:
167 #Local install affects the pre-selection of partitions on the local hard drives, amongst other things.
168 if d.yesno(_(u"Are the profiles being generated to be used for an install on the current computer?")) == DLG_NO:
169 local_install = False
170
171 #Ask
172 while 1:
173 string = _(u"""
174 The first profile needed for an advanced install includes all the
175 necessary information for getting the livecd environment set up.
176 This includes the livecd networking configuration, where the
177 logfile and new root mount point are to be located, etc.
178 We call this the ClientConfiguration profile.
179 Do you have a previously generated XML file for the ClientConfiguration?
180 """)
181 if d.yesno(string, width=70, height=15, defaultno=1) == DLG_YES:
182 code, client_config_xml_file = d.inputbox(_(u"Enter the filename of the XML file"))
183 if code != DLG_OK:
184 break
185 if GLIUtility.is_file(client_config_xml_file):
186 break
187 d.msgbox(_(u"Cannot open file ") + client_config_xml_file, height=7, width=50)
188 client_config_xml_file = None
189 continue
190 else:
191 break
192
193 if client_config_xml_file != None:
194 client_profile.parse(client_config_xml_file)
195 # code to actually run the client_controller functions
196 else:
197 #This line does all the work.
198 gen_client_conf = Setup_CConfig(client_profile, local_install, advanced_mode)
199 client_profile = gen_client_conf.client_profile()
200
201 client_profile.set_interactive(None, True, None)
202 cc.set_configuration(client_profile)
203
204 #This will execute all of the CC functions, and set up networking if there is networking to set up.
205 cc.start_pre_install()
206
207 #Reset the Yes/No labels.
208 d.add_persistent_args(["--yes-label", "Yes"])
209 d.add_persistent_args(["--no-label","No"])
210 while 1:
211 if d.yesno(_(u"All of the installation settings are stored in an XML file, which we call the InstallProfile. If you have previously saved a profile and would like to load it for this install, say Yes. Otherwise say No. Do you have a previously generated InstallProfile XML file?"), width=55, defaultno=1) == DLG_YES:
212 code, install_profile_xml_file = d.inputbox(_(u"Enter the filename of the XML file"))
213 if code != DLG_OK:
214 break
215 if GLIUtility.is_file(install_profile_xml_file):
216 break
217 d.msgbox(_(u"Cannot open file ") + install_profile_xml_file, height=7, width=50)
218 install_profile_xml_file = None
219 else:
220 break
221
222 if install_profile_xml_file != None:
223 install_profile.parse(install_profile_xml_file)
224 else:
225 gen_install_profile = Setup_InstallProfile(client_profile, install_profile, local_install, advanced_mode)
226 install_profile = gen_install_profile.install_profile()
227
228
229 # INSTALLATION TIME
230 current_item = 0
231 while 1:
232 cc.set_install_profile(install_profile)
233 cc.start_install()
234 d.gauge_start(_(u"Installation Started!"), title=_(u"Installation progress"))
235 num_steps_completed = 1
236 next_step = 0
237 num_steps = 0
238 i = 0
239 while 1:
240 notification = cc.getNotification()
241 if notification == None:
242 time.sleep(1)
243 continue
244 type_r = notification.get_type()
245 data = notification.get_data()
246 if type_r == "exception":
247 #Reset the Yes/No labels.
248 d.add_persistent_args(["--yes-label", "Yes"])
249 d.add_persistent_args(["--no-label","No"])
250 if d.yesno(_(u"There was an Exception received during the install that is outside of the normal install errors. This is a bad thing. The error was:")+ str(data) + _(u"\nPlease submit a bug report (after searching to make sure it's not a known issue and verifying you didn't do something stupid) with the contents of /var/log/install.log and /tmp/installprofile.xml and the version of the installer you used\nDo you want to cleanup your system to attempt another install?"), width=70) == DLG_YES:
251 cc.start_failure_cleanup()
252 elif type_r == "progress":
253 #SECONDARY UPDATIN' GOIN ON IN HERE
254 diff = (data[0]*100)/num_steps
255 d.gauge_update(i+diff, "On step %d of %d. Current step: %s\n%s" % (num_steps_completed, num_steps, next_step, data[1]), update_text=1)
256 elif type_r == "int":
257 if data == GLIClientController.NEXT_STEP_READY:
258 next_step_waiting = False
259 next_step = cc.get_next_step_info()
260 num_steps = cc.get_num_steps()
261 i = (num_steps_completed*100)/num_steps
262 d.gauge_update(i, "On step %d of %d. Current step: %s" % (num_steps_completed, num_steps, next_step), update_text=1)
263 num_steps_completed += 1
264 #print "Next step: " + next_step
265 if cc.has_more_steps():
266 cc.next_step()
267 continue
268 if data == GLIClientController.INSTALL_DONE:
269 d.gauge_update(100, _(u"Install completed!"), update_text=1)
270 d.gauge_stop()
271 print _(u"Install done!")
272 sys.exit(0)

Properties

Name Value
svn:eol-style native
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20