~free.ekanayaka/landscape-client/jaunty-updates-1.4.4-0ubuntu0.9.04

« back to all changes in this revision

Viewing changes to landscape/deployment.py

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-03-18 20:42:05 UTC
  • Revision ID: james.westby@ubuntu.com-20090318204205-v17ejhu5urdsrm7j
Tags: 1.0.28-0ubuntu1
New upstream release. (LP: #343954)

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
    def reload(self):
127
127
        self.load(self._command_line_args)
128
128
 
129
 
    def load(self, args, accept_unexistent_config=False):
 
129
    def load(self, args, accept_nonexistent_config=False):
130
130
        """
131
131
        Load configuration data from command line arguments and a config file.
132
132
 
138
138
        if self.config:
139
139
            if os.path.isfile(self.config):
140
140
                self.load_configuration_file(self.config)
141
 
            elif not accept_unexistent_config:
 
141
            elif not accept_nonexistent_config:
142
142
                sys.exit("error: file not found: %s" % self.config)
143
143
        else:
144
144
            for potential_config_file in self.default_config_filenames:
146
146
                    self.load_configuration_file(potential_config_file)
147
147
                    break
148
148
 
 
149
        self._load_external_options()
 
150
 
149
151
        # Check that all needed options were given.
150
152
        for option in self.required_options:
151
153
            if not getattr(self, option):
156
158
        if self.bus not in ("session", "system"):
157
159
            sys.exit("error: bus must be one of 'session' or 'system'")
158
160
 
 
161
    def _load_external_options(self):
 
162
        """Hook for loading options from elsewhere (e.g. for --import)."""
 
163
 
159
164
    def load_command_line(self, args):
160
165
        """Load configuration data from the given command line."""
161
166
        self._command_line_args = args
195
200
        3. The first filename in self.default_config_filenames
196
201
        """
197
202
        # The filename we'll write to
198
 
        filename = (self.config or self._config_filename or
199
 
                    self.default_config_filenames[0])
 
203
        filename = self.get_config_filename()
200
204
 
201
205
        config_parser = ConfigParser()
202
206
        # Make sure we read the old values from the config file so that we
233
237
        return parser
234
238
 
235
239
    def get_config_filename(self):
236
 
        return self._config_filename
 
240
        if self.config:
 
241
            return self.config
 
242
        if self._config_filename:
 
243
            return self._config_filename
 
244
        if self.default_config_filenames:
 
245
            for potential_config_file in self.default_config_filenames:
 
246
                if os.access(potential_config_file, os.R_OK):
 
247
                    return potential_config_file
 
248
            return self.default_config_filenames[0]
 
249
        return None
237
250
 
238
251
    def get_command_line_options(self):
239
252
        return self._command_line_options