~xnox/ubiquity/move-keyboard-early

« back to all changes in this revision

Viewing changes to espresso/backend/config.py

  • Committer: Colin Watson
  • Date: 2006-02-23 13:14:42 UTC
  • mfrom: (779.1.15 timezone)
  • Revision ID: colin.watson@canonical.com-20060223131442-a85f76cd7488af9e
merge my timezone branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
# -*- coding: utf-8 -*-
3
3
 
4
4
from espresso import misc
5
 
from espresso.components import language_apply, usersetup_apply
 
5
from espresso.components import language_apply, timezone_apply, usersetup_apply
6
6
from espresso.settings import *
7
7
 
8
8
import os
42
42
        else:
43
43
            misc.post_log('error', 'Configuring distro')
44
44
            return False
45
 
        #queue.put('94 Configure time zone')
46
 
        #misc.post_log('info', 'Configuring distro')
47
 
        #if self.configure_timezone():
48
 
        #    misc.post_log('info', 'Configured distro')
49
 
        #else:
50
 
        #    misc.post_log('error', 'Configuring distro')
51
 
        #    return False
 
45
        queue.put('94 Configure time zone')
 
46
        misc.post_log('info', 'Configuring distro')
 
47
        if self.configure_timezone():
 
48
            misc.post_log('info', 'Configured distro')
 
49
        else:
 
50
            misc.post_log('error', 'Configuring distro')
 
51
            return False
52
52
        queue.put('95 Creating user')
53
53
        misc.post_log('info', 'Configuring distro')
54
54
        if self.configure_user():
110
110
 
111
111
 
112
112
    def get_locales(self):
113
 
        """set timezone and keymap attributes from debconf. It uses the same values
 
113
        """set keymap attributes from debconf. It uses the same values
114
114
        the user have selected on live system.
115
115
 
116
 
        get_locales() -> timezone, keymap, locales"""
 
116
        get_locales() -> keymap, locales"""
117
117
 
118
118
        db = DebconfCommunicator('espresso')
119
119
 
120
120
        try:
121
 
            self.timezone = db.get('time/zone')
122
 
            if self.timezone == '':
123
 
                    self.timezone = db.get('tzconfig/choose_country_zone_multiple')
124
 
        except debconf.DebconfError:
125
 
            if os.path.islink('/etc/localtime'):
126
 
                self.timezone = os.readlink('/etc/localtime')
127
 
                if self.timezone.startswith('/usr/share/zoneinfo/'):
128
 
                    self.timezone = self.timezone[len('/usr/share/zoneinfo/'):]
129
 
            elif os.path.exists('/etc/timezone'):
130
 
                self.timezone = open('/etc/timezone').readline().strip()
131
 
            else:
132
 
                self.timezone = None
133
 
 
134
 
        try:
135
121
            self.keymap = db.get('debian-installer/keymap')
136
122
        except debconf.DebconfError:
137
123
            self.keymap = None
143
129
 
144
130
 
145
131
    def configure_timezone(self):
146
 
        """set timezone on installed system (which was obtained from
147
 
        get_locales)."""
148
 
 
149
 
        if self.timezone is not None:
150
 
            # tzsetup ignores us if these exist
151
 
            for tzfile in ('etc/timezone', 'etc/localtime'):
152
 
                    path = os.path.join(self.target, tzfile)
153
 
                    if os.path.exists(path):
154
 
                            os.unlink(path)
155
 
 
156
 
            self.set_debconf('d-i', 'time/zone', self.timezone)
157
 
            self.chrex('tzsetup')
158
 
 
159
 
        return True
 
132
        """Set timezone on installed system."""
 
133
 
 
134
        dbfilter = timezone_apply.TimezoneApply(self.frontend)
 
135
        return (dbfilter.run_command(auto_process=True) == 0)
160
136
 
161
137
 
162
138
    def configure_keymap(self):