~xubuntu-dev/ubiquity/lp1437180_feh

« back to all changes in this revision

Viewing changes to ubiquity/frontend/base.py

  • Committer: Michael Terry
  • Date: 2009-07-14 13:14:35 UTC
  • mfrom: (3285.2.37 ubiquity.reorg)
  • Revision ID: michael.terry@canonical.com-20090714131435-m8wkg4pnp4cfwr38
merge from lp:~mterry/ubiquity/oem-config-merge : oem-config and ubiquity now share the same code base\!

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
import debconf
28
28
from ubiquity.debconfcommunicator import DebconfCommunicator
29
29
from ubiquity.misc import drop_privileges
30
 
 
 
30
from ubiquity.components import console_setup, language, timezone, usersetup, \
 
31
                                partman, partman_commit, \
 
32
                                summary, install, migrationassistant
31
33
from ubiquity import i18n
32
34
 
 
35
# Pages that may be loaded. Interpretation is up to the frontend, but it is
 
36
# strongly recommended to keep the page identifiers the same.
 
37
PAGE_COMPONENTS = {
 
38
    'LanguageOnly' : language.Language,
 
39
    'Language' : language.Language,
 
40
    'Location' : timezone.Timezone,
 
41
    'KeyboardConf' : console_setup.ConsoleSetup,
 
42
    'PartAuto' : partman.Partman,
 
43
    'PartAdvanced' : partman.Partman,
 
44
    'UserInfo' : usersetup.UserSetup,
 
45
    'Network' : None,
 
46
    'Tasks' : None,
 
47
    'MigrationAssistant' : migrationassistant.MigrationAssistant,
 
48
    'Ready' : summary.Summary,
 
49
}
 
50
 
33
51
class BaseFrontend:
34
52
    """Abstract ubiquity frontend.
35
53
 
76
94
                    del os.environ['UBIQUITY_MIGRATION_ASSISTANT']
77
95
        except debconf.DebconfError:
78
96
            pass
 
97
 
 
98
        self.oem_user_config = False
 
99
        if 'UBIQUITY_OEM_USER_CONFIG' in os.environ:
 
100
          self.oem_user_config = True
79
101
        
80
102
        try:
81
103
            self.oem_id = db.get('oem-config/id')
109
131
        except debconf.DebconfError:
110
132
            pass
111
133
 
 
134
        if self.oem_user_config:
 
135
            step_list_name = 'ubiquity/oem-config-steps'
 
136
        else:
 
137
            step_list_name = 'ubiquity/steps'
 
138
        valid_step_list = db.metaget(step_list_name, 'choices-c')
 
139
        valid_steps = valid_step_list.replace(',', ' ').split()
 
140
        step_list = db.get(step_list_name)
 
141
        steps = step_list.replace(',', ' ').split()
 
142
        self.pagenames = []
 
143
        self.pages = []
 
144
        for valid_page in valid_steps:
 
145
            if valid_page in steps:
 
146
                if valid_page == 'MigrationAssistant' and \
 
147
                   'UBIQUITY_MIGRATION_ASSISTANT' not in os.environ:
 
148
                    continue
 
149
                step_name = "step%s" % valid_page
 
150
                # Handle special frontend overrides
 
151
                if hasattr(self, 'pages_override_remove') and \
 
152
                   step_name in self.pages_override_remove:
 
153
                    continue
 
154
                self.pagenames.append(step_name)
 
155
                page_class = PAGE_COMPONENTS[valid_page]
 
156
                if page_class is not None and page_class not in self.pages:
 
157
                    self.pages.append(page_class)
 
158
        for step in steps:
 
159
            if step not in valid_steps:
 
160
                syslog.syslog(syslog.LOG_WARNING,
 
161
                              "Unknown step name in %s: %s" %
 
162
                              (step_list_name, step))
 
163
 
 
164
        # Handle special frontend extra pages
 
165
        if hasattr(self, 'pages_override_append'):
 
166
            for page in self.pages_override_append:
 
167
                self.pagenames.append(page[0])
 
168
                if page[1]:
 
169
                    self.pages.append(page[1])
 
170
 
 
171
        if not self.pagenames:
 
172
            raise ValueError, "No valid steps in %s" % step_list_name
 
173
 
112
174
        if 'SUDO_USER' in os.environ:
113
175
            os.environ['SCIM_USER'] = os.environ['SUDO_USER']
114
176
            os.environ['SCIM_HOME'] = os.path.expanduser(