def start(self, auto_process=False): self.status = None if not self.db: assert self.frontend is not None self.frontend.start_debconf() self.db = self.frontend.db self.ui_loop_level = 0 prep = self.prepare() if prep is None: self.run(None, None) return self.command = ['log-output', '-t', PACKAGE, '--pass-stdout'] if isinstance(prep[0], types.StringTypes): self.command.append(prep[0]) else: self.command.extend(prep[0]) question_patterns = prep[1] if len(prep) > 2: env = prep[2] else: env = {} self.debug("Starting up '%s' for %s.%s", self.command, self.__class__.__module__, self.__class__.__name__) self.debug("Watching for question patterns %s", ', '.join(question_patterns)) widgets = {} for pattern in question_patterns: widgets[pattern] = self self.dbfilter = DebconfFilter(self.db, widgets) # TODO: Set as unseen all questions that we're going to ask. if auto_process: self.dbfilter.start(self.command, blocking=False, extra_env=env) # Clearly, this isn't enough for full non-blocking operation. # However, debconf itself is generally quick, and the confmodule # will generally be listening for a reply when we try to send # one; the slow bit is waiting for the confmodule to decide to # send a command. Therefore, this is the only file descriptor we # bother to watch, which greatly simplifies our life. self.frontend.watch_debconf_fd(self.dbfilter.subout_fd, self.process_input) else: self.dbfilter.start(self.command, blocking=True, extra_env=env)