/[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 718 - (show annotations) (download) (as text)
Tue Jun 28 04:49:19 2005 UTC (9 years, 8 months ago) by codeman
File MIME type: text/x-python
File size: 7408 byte(s)
finished almost all internationalization of GenDialog.

1 #!/usr/bin/python
2
3 import sys
4 sys.path.append("../..")
5
6 import dialog
7 import GLIException, GLIInstallProfile, GLIClientConfiguration, GLIClientController, GLIUtility, GLIStorageDevice
8 from GLIGenDialog import GLIGenCF,GLIGenIP
9 import string, copy, time, re, glob, os, platform
10 import gettext
11 _ = gettext.gettext
12
13 class Setup_CConfig(GLIGenCF):
14 def __init__(self, client_profile, local_install, advanced_mode):
15 GLIGenCF.__init__(self, client_profile, local_install, advanced_mode)
16 self.set_arch_template()
17 self.set_logfile()
18 self.set_root_mount_point()
19 self.set_client_networking()
20 self.set_enable_ssh()
21 self.set_livecd_password()
22 self.set_client_kernel_modules()
23 self.client_config_xml_file = None
24 if advanced_mode:
25 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:
26 self.client_config_xml_file = self.save_client_profile()
27
28 class Setup_InstallProfile(GLIGenIP):
29 def __init__(self, client_profile, install_profile, local_install, advanced_mode):
30 GLIGenIP.__init__(self, client_profile, install_profile, local_install, advanced_mode)
31 self.install_profile_xml_file = None
32 if d.yesno(_(u"Do you want to save the InstallProfile XML file?")) == DLG_YES:
33 self.install_profile_xml_file = self._save_install_profile()
34
35 # ------------------------------------------------------------------
36 if __name__ == '__main__':
37
38 d = dialog.Dialog()
39 client_profile = GLIClientConfiguration.ClientConfiguration()
40 install_profile = GLIInstallProfile.InstallProfile()
41 cc = GLIClientController.GLIClientController(pretend=False)
42 exception_waiting = None
43 client_config_xml_file = None
44 install_profile_xml_file = None
45 next_step_waiting = False
46 install_done = False
47 local_install = True
48 advanced_mode = False
49
50 DLG_OK = 0
51 DLG_YES = 0
52 DLG_CANCEL = 1
53 DLG_NO = 1
54 DLG_ESC = 2
55 DLG_ERROR = 3
56 DLG_EXTRA = 4
57 DLG_HELP = 5
58
59 d.setBackgroundTitle("Gentoo Linux Installer")
60 welcome_string = _(u"""Welcome to the Gentoo Linux Installer! This program will help install Gentoo on your computer.
61 Before proceeding please thoroughly read the Gentoo Installation Handbook available at
62 http://www.gentoo.org/doc/en/handbook/index.xml \n
63 This installer works by first asking a series of questions to generate an \"installation profile\",
64 which contains all the information needed to install Gentoo.\n
65 NO Changes will be made to your system until you select the "Install!" button.
66 You can save your profile at any time by exiting the installer.
67 You can also load a previously made profile at any time.\n
68 If choosing expert mode, you will make a second profile with configuration settings for the livecd environment and the installer.\n
69 Press OK to continue""")
70 d.msgbox(welcome_string, height=25, width=78, title="Welcome")
71
72 #Change the Yes/No buttons to new labels for this question.
73 d.add_persistent_args(["--yes-label", _(u"Simulate")])
74 d.add_persistent_args(["--no-label", _(u"Real Install")])
75 #This is a temporary question during the development process. In a beta release a real install will be implied.
76 if d.yesno(_(u"Are we performing an actual install or just simulating?"), width=45) == DLG_NO:
77 cc._pretend = False
78 else:
79 cc._pretend = True
80
81 #Set the Yes/No labels.
82 d.add_persistent_args(["--yes-label", "Standard"])
83 d.add_persistent_args(["--no-label","Advanced"])
84 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.
85 """)
86 if d.yesno(advanced_string, width=55, height=15) == DLG_NO:
87 advanced_mode = True
88 local_install = True
89
90 #Reset the Yes/No labels.
91 d.add_persistent_args(["--yes-label", "Yes"])
92 d.add_persistent_args(["--no-label","No"])
93 if advanced_mode:
94 #Local install affects the pre-selection of partitions on the local hard drives, amongst other things.
95 if d.yesno(_(u"Are the profiles being generated to be used for an install on the current computer?")) == DLG_NO:
96 local_install = False
97
98 #Ask
99 while 1:
100 string = _(u"""
101 The first profile needed for an advnaced install includes all the
102 necessary information for getting the livecd environment set up.
103 This includes the livecd networking configuration, where the
104 logfile and new root mount point are to be located, etc.
105 We call this the ClientConfiguration profile.
106 Do you have a previously generated XML file for the ClientConfiguration?
107 """)
108 if d.yesno(string, width=70, height=15, defaultno=1) == DLG_YES:
109 code, client_config_xml_file = d.inputbox(_(u"Enter the filename of the XML file"))
110 if code != DLG_OK:
111 break
112 if GLIUtility.is_file(client_config_xml_file):
113 break
114 d.msgbox(_(u"Cannot open file ") + client_config_xml_file, height=7, width=50)
115 client_config_xml_file = None
116 continue
117 else:
118 break
119
120 if client_config_xml_file != None:
121 client_profile.parse(client_config_xml_file)
122 # code to actually run the client_controller functions
123 else:
124 #This line does all the work.
125 gen_client_conf = Setup_CConfig(client_profile, local_install, advanced_mode)
126 client_profile = gen_client_conf.client_profile()
127
128 client_profile.set_interactive(None, True, None)
129 cc.set_configuration(client_profile)
130
131 cc.start_pre_install()
132
133 while 1:
134 if d.yesno(_(u"Do you have a previously generated InstallProfile XML file?")) == DLG_YES:
135 code, install_profile_xml_file = d.inputbox(_(u"Enter the filename of the XML file"))
136 if code != DLG_OK:
137 break
138 if GLIUtility.is_file(install_profile_xml_file):
139 break
140 d.msgbox(_(u"Cannot open file ") + install_profile_xml_file, height=7, width=50)
141 install_profile_xml_file = None
142 else:
143 break
144
145 if install_profile_xml_file != None:
146 install_profile.parse(install_profile_xml_file)
147 else:
148 gen_install_profile = Setup_InstallProfile(client_profile, install_profile, local_install, advanced_mode)
149 install_profile = gen_install_profile.install_profile()
150
151
152 # INSTALLATION TIME
153 current_item = 0
154 while 1:
155 cc.set_install_profile(install_profile)
156 cc.start_install()
157 d.gauge_start("Installation Started!", title="Installation progress")
158 num_steps_completed = 1
159 while 1:
160 notification = cc.getNotification()
161 if notification == None:
162 time.sleep(1)
163 continue
164 type_r = notification.get_type()
165 data = notification.get_data()
166 if type_r == "exception":
167 print "Exception received:"
168 print data
169 elif type_r == "int":
170 if data == GLIClientController.NEXT_STEP_READY:
171 next_step_waiting = False
172 next_step = cc.get_next_step_info()
173 num_steps = cc.get_num_steps()
174 i = (num_steps_completed*100)/num_steps
175 d.gauge_update(i, "On step %d of %d. Current step: %s" % (num_steps_completed, num_steps, next_step), update_text=1)
176 num_steps_completed += 1
177 #print "Next step: " + next_step
178 if cc.has_more_steps():
179 cc.next_step()
180 continue
181 if data == GLIClientController.INSTALL_DONE:
182 d.gauge_update(100, "Install completed!", update_text=1)
183 d.gauge_stop()
184 print "Install done!"
185 sys.exit(0)

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20