コード例 #1
0
 def run(self,priority,question):
     if question.startswith('lirc/remote'):
         device=self.frontend.get_lirc("remote")
         if question.startswith('lirc/remote_modules'):
             self.preseed('lirc/remote_modules',device["modules"])
         elif question.startswith('lirc/remote_lircd_conf'):
             self.preseed('lirc/remote_lircd_conf',device["lircd_conf"])
         elif question.startswith('lirc/remote_driver'):
             self.preseed('lirc/remote_driver',device["driver"])
         elif question.startswith('lirc/remote_device'):
             self.preseed('lirc/remote_device',device["device"])
         elif question.startswith('lirc/remote'):
             self.preseed('lirc/remote',device["remote"])
     elif question.startswith('lirc/transmitter'):
         device=self.frontend.get_lirc("transmitter")
         if question.startswith('lirc/transmitter_modules'):
             self.preseed('lirc/transmitter_modules',device["modules"])
         elif question.startswith('lirc/transmitter_lircd_conf'):
             self.preseed('lirc/transmitter_lircd_conf',device["lircd_conf"])
         elif question.startswith('lirc/transmitter_driver'):
             self.preseed('lirc/transmitter_driver',device["driver"])
         elif question.startswith('lirc/transmitter_device'):
             self.preseed('lirc/transmitter_device',device["device"])
         elif question.startswith('lirc/transmitter'):
             self.preseed('lirc/transmitter',device["transmitter"])
     return FilteredCommand.run(self, priority, question)
コード例 #2
0
    def run(self, priority, question):
        if self.done:
            return self.succeeded

        if question == 'console-setup/layout':
            # Reset this in case we just backed up from the variant
            # question.
            self.succeeded = True
            # TODO cjwatson 2006-09-07: no console-setup support for layout
            # choice translation yet
            self.frontend.set_keyboard_choices(
                self.choices_untranslated(question))
            self.frontend.set_keyboard(self.db.get(question))
            return True
        elif question == 'console-setup/variant':
            # TODO cjwatson 2006-10-02: no console-setup support for variant
            # choice translation yet
            self.frontend.set_keyboard_variant_choices(
                self.choices_untranslated(question))
            self.frontend.set_keyboard_variant(self.db.get(question))
            # console-setup preseeding is special, and needs to be checked
            # by hand. The seen flag on console-setup/layout is used
            # internally by console-setup, so we can't just force it to
            # true.
            if ('UBIQUITY_AUTOMATIC' in os.environ and
                self.db.fget('console-setup/layoutcode', 'seen') == 'true'):
                return True
            else:
                return FilteredCommand.run(self, priority, question)
        else:
            return True
コード例 #3
0
ファイル: install.py プロジェクト: Jolicloud/ubiquity
    def run(self, priority, question):
        if question.endswith('/apt-install-failed'):
            return self.error(priority, question)

        elif question == 'migration-assistant/failed-unmount':
            response = self.frontend.question_dialog(
                self.description(question),
                self.extended_description(question),
                ('ubiquity/text/go_back', 'ubiquity/text/continue'))
            if response is None or response == 'ubiquity/text/continue':
                self.preseed(question, 'true')
            else:
                self.preseed(question, 'false')
            return True
        elif question == 'ubiquity/install/copying_error/md5':
            response = self.frontend.question_dialog(
                self.description(question),
                # TODO evand 2008-02-14: i18n.
                self.extended_description(question),
                ('Abort', 'Retry', 'Skip'),
                use_templates=False)
            if response is None or response == 'Abort':
                self.preseed(question, 'abort')
            elif response == 'Retry':
                self.preseed(question, 'retry')
            elif response == 'Skip':
                self.preseed(question, 'skip')
            return True
        elif question == 'ubiquity/install/new-bootdev':
            current_device = self.db.get(question)
            response = self.frontend.bootloader_dialog(current_device)
            self.preseed(question, response)
            return True

        return FilteredCommand.run(self, priority, question)
コード例 #4
0
    def run(self, priority, question):
        if question.endswith('/summary'):
            text = ''
            wrapper = textwrap.TextWrapper(width=76)
            for line in self.extended_description(question).split("\n"):
                text += wrapper.fill(line) + "\n"

            self.frontend.set_summary_text(text)

            if os.access('/usr/share/grub-installer/grub-installer', os.X_OK):
                # TODO cjwatson 2006-09-04: a bit inelegant, and possibly
                # Ubuntu-specific?
                self.frontend.set_summary_device('(hd0)')
            else:
                self.frontend.set_summary_device(None)

            self.frontend.set_grub_combo(grub_options())

            if will_be_installed('popularity-contest'):
                try:
                    participate = self.db.get('popularity-contest/participate')
                    self.frontend.set_popcon(participate == 'true')
                except debconf.DebconfError:
                    self.frontend.set_popcon(None)
            else:
                self.frontend.set_popcon(None)

            # This component exists only to gather some information and then
            # get out of the way.
            #return True
        return FilteredCommand.run(self, priority, question)
コード例 #5
0
    def run(self, priority, question):
        if question == 'grub-installer/bootdev':
            # Force to the default in the case of an unsupported OS.
            if self.db.get(question) == '':
                self.preseed(question, misc.grub_default())

        return FilteredCommand.run(self, priority, question)
コード例 #6
0
    def run(self, priority, question):
        if question == 'grub-installer/bootdev':
            # Force to the default in the case of an unsupported OS.
            if self.db.get(question) == '':
                self.preseed(question, misc.grub_default())

        return FilteredCommand.run(self, priority, question)
コード例 #7
0
ファイル: grubinstaller.py プロジェクト: jamieboo/ubiquity
    def run(self, priority, question):
        if question == 'grub-installer/bootdev':
            # Force to (hd0) in the case of an unsupported OS.
            if self.db.get(question) == '':
                self.preseed(question, '(hd0)')

        return FilteredCommand.run(self, priority, question)
コード例 #8
0
ファイル: install.py プロジェクト: jamieboo/ubiquity
    def run(self, priority, question):
        if question.endswith('/apt-install-failed'):
            return self.error(priority, question)

        elif question == 'migration-assistant/failed-unmount':
            response = self.frontend.question_dialog(
                self.description(question),
                self.extended_description(question),
                ('ubiquity/text/go_back', 'ubiquity/text/continue'))
            if response is None or response == 'ubiquity/text/continue':
                self.preseed(question, 'true')
            else:
                self.preseed(question, 'false')
            return True
        elif question == 'ubiquity/install/copying_error/md5':
            response = self.frontend.question_dialog(
                self.description(question),
                # TODO evand 2008-02-14: i18n.
                self.extended_description(question),
                ('Abort', 'Retry', 'Skip'),
                use_templates=False)
            if response is None or response == 'Abort':
                self.preseed(question, 'abort')
            elif response == 'Retry':
                self.preseed(question, 'retry')
            elif response == 'Skip':
                self.preseed(question, 'skip')
            return True

        return FilteredCommand.run(self, priority, question)
コード例 #9
0
    def run(self, priority, question):
        syslog.syslog("-------> run guadaPrePartition")
        if question.startswith('guada-ubiquity/prepartition'):
            #advanced = self.frontend.get_advanced()
            #self.preseed_bool('mythbuntu/advanced_install', advanced)
            print "question"

        return FilteredCommand.run(self, priority, question)
コード例 #10
0
    def run(self, priority, question):
        syslog.syslog("-------> run guadaPrePartition")
        if question.startswith('guada-ubiquity/prepartition'):
            #advanced = self.frontend.get_advanced()
            #self.preseed_bool('mythbuntu/advanced_install', advanced)
            print "question"

        return FilteredCommand.run(self, priority, question)
コード例 #11
0
ファイル: partman_commit.py プロジェクト: jamieboo/ubiquity
    def run(self, priority, question):
        if self.done:
            return self.succeeded

        if question.startswith('partman/confirm'):
            if question == 'partman/confirm':
                self.db.set('ubiquity/partman-made-changes', 'true')
            else:
                self.db.set('ubiquity/partman-made-changes', 'false')
            self.preseed(question, 'true')
            return True

        elif question == 'partman/exception_handler':
            if priority == 'critical' or priority == 'high':
                response = self.frontend.question_dialog(
                    self.description(question),
                    self.extended_description(question),
                    self.choices(question), use_templates=False)
                self.preseed(question, response, seen=False)
            else:
                self.preseed(question, 'unhandled', seen=False)
            return True

        elif question == 'partman/exception_handler_note':
            if priority == 'critical' or priority == 'high':
                self.frontend.error_dialog(self.description(question),
                                           self.extended_description(question))
                return FilteredCommand.error(self, priority, question)
            else:
                return True

        elif self.question_type(question) == 'boolean':
            response = self.frontend.question_dialog(
                self.description(question),
                self.extended_description(question),
                ('ubiquity/text/go_back', 'ubiquity/text/continue'))

            answer_reversed = False
            if (question == 'partman-jfs/jfs_boot' or
                question == 'partman-jfs/jfs_root'):
                answer_reversed = True
            if response is None or response == 'ubiquity/text/continue':
                answer = answer_reversed
            else:
                answer = not answer_reversed
                self.succeeded = False
                self.done = True
                self.frontend.return_to_partitioning()
            if answer:
                self.preseed(question, 'true')
            else:
                self.preseed(question, 'false')
            return True

        else:
            return FilteredCommand.run(self, priority, question)
コード例 #12
0
    def run(self, priority, question):
        if question.endswith('/apt-install-failed'):
            return self.error(priority, question)

        elif question == 'ubiquity/install/new-bootdev':
            current_device = self.db.get(question)
            response = self.frontend.bootloader_dialog(current_device)
            self.preseed(question, response)
            return True

        return FilteredCommand.run(self, priority, question)
コード例 #13
0
ファイル: plugininstall.py プロジェクト: 27Paolo/ubiquity
    def run(self, priority, question):
        if question.endswith('/apt-install-failed'):
            return self.error(priority, question)

        elif question == 'ubiquity/install/new-bootdev':
            current_device = self.db.get(question)
            response = self.frontend.bootloader_dialog(current_device)
            self.preseed(question, response)
            return True

        return FilteredCommand.run(self, priority, question)
コード例 #14
0
    def run(self, priority, question):
        if self.done:
            return self.succeeded

        if question.startswith('partman/confirm'):
            self.db.set('ubiquity/partman-confirm', question[8:])
            self.preseed(question, 'true')
            return True

        elif question == 'partman/exception_handler':
            if priority == 'critical' or priority == 'high':
                response = self.frontend.question_dialog(
                    self.description(question),
                    self.extended_description(question),
                    self.choices(question),
                    use_templates=False)
                self.preseed(question, response, seen=False)
            else:
                self.preseed(question, 'unhandled', seen=False)
            return True

        elif question == 'partman/exception_handler_note':
            if priority == 'critical' or priority == 'high':
                self.frontend.error_dialog(self.description(question),
                                           self.extended_description(question))
                return FilteredCommand.error(self, priority, question)
            else:
                return True

        elif self.question_type(question) == 'boolean':
            response = self.frontend.question_dialog(
                self.description(question),
                self.extended_description(question),
                ('ubiquity/text/go_back', 'ubiquity/text/continue'))

            answer_reversed = False
            if (question == 'partman-jfs/jfs_boot'
                    or question == 'partman-jfs/jfs_root'):
                answer_reversed = True
            if response is None or response == 'ubiquity/text/continue':
                answer = answer_reversed
            else:
                answer = not answer_reversed
                self.succeeded = False
                self.done = True
                self.frontend.return_to_partitioning()
            if answer:
                self.preseed(question, 'true')
            else:
                self.preseed(question, 'false')
            return True

        else:
            return FilteredCommand.run(self, priority, question)
コード例 #15
0
ファイル: summary.py プロジェクト: jokalee/salamander
    def run(self, priority, question):
        if question.endswith('/summary'):
            text = ''
            wrapper = textwrap.TextWrapper(width=76)
            for line in self.extended_description(question).split("\n"):
                text += wrapper.fill(line) + "\n"

            self.frontend.set_summary_text(text)

            useRaid = self.db.get('ubiquity/use_raid')
            if useRaid != "true":
                self.frontend.set_summary_text(text)
                try:
                    install_bootloader = self.db.get(
                        'ubiquity/install_bootloader')
                    self.frontend.set_grub(install_bootloader == 'true')
                except debconf.DebconfError:
                    self.frontend.set_grub(None)

                if os.access('/usr/share/grub-installer/grub-installer',
                             os.X_OK):
                    # TODO cjwatson 2006-09-04: a bit inelegant, and possibly
                    # Ubuntu-specific?
                    if installing_from_disk():
                        self.frontend.set_summary_device(find_grub_target())
                    else:
                        self.frontend.set_summary_device('(hd0)')
                else:
                    self.frontend.set_summary_device(None)

                self.frontend.set_grub_combo(grub_options())

                if will_be_installed('popularity-contest'):
                    try:
                        participate = self.db.get(
                            'popularity-contest/participate')
                        self.frontend.set_popcon(participate == 'true')
                    except debconf.DebconfError:
                        self.frontend.set_popcon(None)
                else:
                    self.frontend.set_popcon(None)
            else:
                raidDiskStrs = re.split("\\\\[\t ]+",
                                        self.db.get('ubiquity/raid_disks'))
                text = text + "\n"
                text = text + "These disks will be formatted into a RAID array:\n" + '\n'.join(
                    raidDiskStrs) + "\n\n"
                self.frontend.set_summary_text(text)

            # This component exists only to gather some information and then
            # get out of the way.
            #return True
        return FilteredCommand.run(self, priority, question)
コード例 #16
0
ファイル: summary.py プロジェクト: ericpaulbishop/salamander
    def run(self, priority, question):
        if question.endswith("/summary"):
            text = ""
            wrapper = textwrap.TextWrapper(width=76)
            for line in self.extended_description(question).split("\n"):
                text += wrapper.fill(line) + "\n"

            self.frontend.set_summary_text(text)

            useRaid = self.db.get("ubiquity/use_raid")
            if useRaid != "true":
                self.frontend.set_summary_text(text)
                try:
                    install_bootloader = self.db.get("ubiquity/install_bootloader")
                    self.frontend.set_grub(install_bootloader == "true")
                except debconf.DebconfError:
                    self.frontend.set_grub(None)

                if os.access("/usr/share/grub-installer/grub-installer", os.X_OK):
                    # TODO cjwatson 2006-09-04: a bit inelegant, and possibly
                    # Ubuntu-specific?
                    if installing_from_disk():
                        self.frontend.set_summary_device(find_grub_target())
                    else:
                        self.frontend.set_summary_device("(hd0)")
                else:
                    self.frontend.set_summary_device(None)

                self.frontend.set_grub_combo(grub_options())

                if will_be_installed("popularity-contest"):
                    try:
                        participate = self.db.get("popularity-contest/participate")
                        self.frontend.set_popcon(participate == "true")
                    except debconf.DebconfError:
                        self.frontend.set_popcon(None)
                else:
                    self.frontend.set_popcon(None)
            else:
                raidDiskStrs = re.split("\\\\[\t ]+", self.db.get("ubiquity/raid_disks"))
                text = text + "\n"
                text = text + "These disks will be formatted into a RAID array:\n" + "\n".join(raidDiskStrs) + "\n\n"
                self.frontend.set_summary_text(text)

            # This component exists only to gather some information and then
            # get out of the way.
            # return True
        return FilteredCommand.run(self, priority, question)
コード例 #17
0
ファイル: install.py プロジェクト: pombreda/OnionScraper
    def run(self, priority, question):
        if question == 'ubiquity/install/copying_error/md5':
            response = self.frontend.question_dialog(
                self.description(question),
                # TODO evand 2008-02-14: i18n.
                self.extended_description(question),
                ('Abort', 'Retry', 'Skip'),
                use_templates=False)
            if response is None or response == 'Abort':
                self.preseed(question, 'abort')
            elif response == 'Retry':
                self.preseed(question, 'retry')
            elif response == 'Skip':
                self.preseed(question, 'skip')
            return True

        return FilteredCommand.run(self, priority, question)
コード例 #18
0
    def run(self,priority,question):
        if question.startswith('mythbuntu/officialthemes'):
            official = self.frontend.get_officialthemes()
            official_string=""
            for theme in official:
                if not official[theme].get_active():
                    official_string+=theme + " "
            self.preseed('mythbuntu/officialthemes', official_string)
        elif question.startswith('mythbuntu/communitythemes'):
            community = self.frontend.get_communitythemes()
            community_string=""
            for theme in community:
                if not community[theme].get_active():
                    community_string+=theme + " "
            self.preseed('mythbuntu/communitythemes', community_string)

        return FilteredCommand.run(self, priority, question)
コード例 #19
0
ファイル: install.py プロジェクト: pkt/ubiquity.squibby
    def run(self, priority, question):
        if question == 'ubiquity/install/copying_error/md5':
            response = self.frontend.question_dialog(
                self.description(question),
                # TODO evand 2008-02-14: i18n.
                self.extended_description(question),
                ('Abort', 'Retry', 'Skip'),
                use_templates=False)
            if response is None or response == 'Abort':
                self.preseed(question, 'abort')
            elif response == 'Retry':
                self.preseed(question, 'retry')
            elif response == 'Skip':
                self.preseed(question, 'skip')
            return True

        return FilteredCommand.run(self, priority, question)
コード例 #20
0
    def run(self, priority, question):
        if question == 'time/zone':
            zone = self.db.get(question)
            # Some countries don't have a default zone, so just pick the
            # first choice in the list.
            if not zone:
                choices_c = self.choices_untranslated(question)
                if choices_c:
                    zone = choices_c[0]
            # special cases where default is not in zone.tab
            if zone == 'Canada/Eastern':
                zone = 'America/Toronto'
            elif zone == 'US/Eastern':
                zone = 'America/New_York'
            self.frontend.set_timezone(zone)

        return FilteredCommand.run(self, priority, question)
コード例 #21
0
    def run(self, priority, question):
        if (question != 'ubiquity/run-ma-again') and \
            (question != 'migration-assistant/partitions'):
            self.got_a_question = True
        if question == 'migration-assistant/failed-unmount':
            response = self.frontend.question_dialog(
                self.description(question),
                self.extended_description(question),
                ('ubiquity/text/go_back', 'ubiquity/text/continue'))
            if response is None or response == 'ubiquity/text/continue':
                self.preseed(question, 'true')
            else:
                self.preseed(question, 'false')
            return True

        # We cannot currently import from partitions that are scheduled for
        # deletion, so we filter them out of the list.
        if question == 'migration-assistant/partitions':
            self.filter_parts()

        elif question == 'ubiquity/run-ma-again':
            self.db.set('ubiquity/run-ma-again', 'false')
            self.set_choices()
            # If we didn't ask any questions, they're all preseeded and we don't
            # need to show the page, so we'll continue along.  If we got at
            # least one question, show the page.
            if not self.got_a_question:
                return self.succeeded
            else:
                return FilteredCommand.run(self, priority, question)

        elif question.endswith('user'):
            username = self.db.get('passwd/username')
            self.preseed(question, username)
        elif question.endswith('password'):
            # Just in case for now.  It should never get here as there's a check
            # in ma-ask that skips asking the user details if the username is
            # already preseeded in passwd.
            password = self.db.get('passwd/user-password')
            self.preseed(question, password)
            self.preseed(question + '-again', password)
        else:
            self.preseed(question, ", ".join(self.choices(question)))

        return True
コード例 #22
0
 def run(self,priority,question):
     if question.startswith('mythbuntu/mytharchive'):
         mytharchive = self.frontend.get_mytharchive()
         self.preseed_bool('mythbuntu/mytharchive', mytharchive)
     elif question.startswith('mythbuntu/mythbrowser'):
         mythbrowser = self.frontend.get_mythbrowser()
         self.preseed_bool('mythbuntu/mythbrowser', mythbrowser)
     elif question.startswith('mythbuntu/mythcontrols'):
         mythcontrols = self.frontend.get_mythcontrols()
         self.preseed_bool('mythbuntu/mythcontrols', mythcontrols)
     elif question.startswith('mythbuntu/mythflix'):
         mythflix = self.frontend.get_mythflix()
         self.preseed_bool('mythbuntu/mythflix', mythflix)
     elif question.startswith('mythbuntu/mythgallery'):
         mythgallery = self.frontend.get_mythgallery()
         self.preseed_bool('mythbuntu/mythgallery', mythgallery)
     elif question.startswith('mythbuntu/mythgame'):
         mythgame = self.frontend.get_mythgame()
         self.preseed_bool('mythbuntu/mythgame', mythgame)
     elif question.startswith('mythbuntu/mythmovies'):
         mythmovies = self.frontend.get_mythmovies()
         self.preseed_bool('mythbuntu/mythmovies', mythmovies)
     elif question.startswith('mythbuntu/mythmusic'):
         mythmusic = self.frontend.get_mythmusic()
         self.preseed_bool('mythbuntu/mythmusic', mythmusic)
     elif question.startswith('mythbuntu/mythnews'):
         mythnews = self.frontend.get_mythnews()
         self.preseed_bool('mythbuntu/mythnews', mythnews)
     elif question.startswith('mythbuntu/mythphone'):
         mythphone = self.frontend.get_mythphone()
         self.preseed_bool('mythbuntu/mythphone', mythphone)
     elif question.startswith('mythbuntu/mythphone'):
         mythstream = self.frontend.get_mythstream()
         self.preseed_bool('mythbuntu/mythstream', mythstream)
     elif question.startswith('mythbuntu/mythvideo'):
         mythvideo = self.frontend.get_mythvideo()
         self.preseed_bool('mythbuntu/mythvideo', mythvideo)
     elif question.startswith('mythbuntu/mythweather'):
         mythweather = self.frontend.get_mythweather()
         self.preseed_bool('mythbuntu/mythweather', mythweather)
     elif question.startswith('mythbuntu/mythweb'):
         mythweb = self.frontend.get_mythweb()
         self.preseed_bool('mythbuntu/mythweb', mythweb)
     return FilteredCommand.run(self, priority, question)
コード例 #23
0
 def run(self,priority,question):
     if question.startswith('mythbuntu/video_driver'):
         video_driver = self.frontend.get_video()
         self.preseed('mythbuntu/video_driver', video_driver)
     elif question.startswith('mythbuntu/tvout'):
         tvout = self.frontend.get_tvout()
         self.preseed('mythbuntu/tvout', tvout)
     elif question.startswith('mythbuntu/tvstandard'):
         tvstandard = self.frontend.get_tvstandard()
         self.preseed('mythbuntu/tvstandard', tvstandard)
     elif question.startswith('mythbuntu/hdhomerun'):
         hdhomerun = self.frontend.get_hdhomerun()
         self.preseed_bool('mythbuntu/hdhomerun',hdhomerun)
     elif question.startswith('mythbuntu/xmltv'):
         xmltv = self.frontend.get_xmltv()
         self.preseed_bool('mythbuntu/xmltv',xmltv)
     elif question.startswith('mythbuntu/dvbutils'):
         dvbutils = self.frontend.get_dvbutils()
         self.preseed_bool('mythbuntu/dvbutils',dvbutils)
     return FilteredCommand.run(self, priority, question)
コード例 #24
0
 def run(self,priority,question):
     if question.startswith('mythtv/mysql_admin_password'):
         if self.frontend.get_secure_mysql():
             mysql_root = self.frontend.get_mysql_root_password()
         else:
             mysql_root = ""
         self.preseed('mythtv/mysql_admin_password',mysql_root)
     elif question.startswith('mythtv/mysql_mythtv_user'):
         if not self.frontend.get_uselivemysqlinfo():
             mysqluser = self.frontend.get_mysqluser()
         else:
             mysqluser = self.db.get('mythtv/mysql_mythtv_user')
         self.preseed('mythtv/mysql_mythtv_user', mysqluser)
     elif question.startswith('mythtv/mysql_mythtv_password'):
         if not self.frontend.get_uselivemysqlinfo():
             mysqlpass = self.frontend.get_mysqlpass()
         else:
             mysqlpass = self.db.get('mythtv/mysql_mythtv_password')
         self.preseed('mythtv/mysql_mythtv_password', mysqlpass)
     elif question.startswith('mythtv/mysql_mythtv_dbname'):
         if not self.frontend.get_uselivemysqlinfo():
             mysqldatabase = self.frontend.get_mysqldatabase()
         else:
             mysqldatabase = self.db.get('mythtv/mysql_mythtv_dbname')
         self.preseed('mythtv/mysql_mythtv_dbname', mysqldatabase)
     elif question.startswith('mythtv/mysql_host'):
         if not self.frontend.get_uselivemysqlinfo():
             mysqlserver = self.frontend.get_mysqlserver()
         else:
             mysqlserver = self.db.get('mythtv/mysql_host')
         self.preseed('mythtv/mysql_host', mysqlserver)
     elif question.startswith('mythweb/enable'):
         auth = self.frontend.get_secure_mythweb()
         self.preseed_bool('mythweb/enable', auth)
     elif question.startswith('mythweb/username'):
         user = self.frontend.get_mythweb_username()
         self.preseed('mythweb/username', user)
     elif question.startswith('mythweb/password'):
         passw = self.frontend.get_mythweb_password()
         self.preseed('mythweb/password', passw)
     return FilteredCommand.run(self, priority, question)
コード例 #25
0
ファイル: usersetup.py プロジェクト: jamieboo/ubiquity
    def run(self, priority, question):
        if question.startswith('user-setup/password-weak'):
            # A dialog is a bit clunky, but workable for now. Perhaps it
            # would be better to display some text in the style of
            # password_error, and then let the user carry on anyway by
            # clicking next again?
            response = self.frontend.question_dialog(
                self.description(question),
                self.extended_description(question),
                ('ubiquity/text/choose_another_password',
                 'ubiquity/text/continue'))
            if response is None or response == 'ubiquity/text/continue':
                self.preseed(question, 'true')
            else:
                self.preseed(question, 'false')
                self.succeeded = False
                self.done = False
                self.frontend.select_password()
            return True

        return FilteredCommand.run(self, priority, question)
コード例 #26
0
    def run(self, priority, question):
        if self.done:
            return self.succeeded

        if question == "console-setup/layout":
            # Reset this in case we just backed up from the variant
            # question.
            self.succeeded = True
            # TODO cjwatson 2006-09-07: no console-setup support for layout
            # choice translation yet
            self.frontend.set_keyboard_choices(self.choices_untranslated(question))
            self.frontend.set_keyboard(self.db.get(question))
            return True
        elif question == "console-setup/variant":
            # TODO cjwatson 2006-10-02: no console-setup support for variant
            # choice translation yet
            self.frontend.set_keyboard_variant_choices(self.choices_untranslated(question))
            self.frontend.set_keyboard_variant(self.db.get(question))
            return FilteredCommand.run(self, priority, question)
        else:
            return True
コード例 #27
0
    def run(self, priority, question):
        if question.endswith('/apt-install-failed'):
            return self.error(priority, question)

        elif question == 'migration-assistant/failed-unmount':
            response = self.frontend.question_dialog(
                self.description(question),
                self.extended_description(question),
                ('ubiquity/text/go_back', 'ubiquity/text/continue'))
            if response is None or response == 'ubiquity/text/continue':
                self.preseed(question, 'true')
            else:
                self.preseed(question, 'false')
            return True

        elif question == 'ubiquity/install/new-bootdev':
            current_device = self.db.get(question)
            response = self.frontend.bootloader_dialog(current_device)
            self.preseed(question, response)
            return True

        return FilteredCommand.run(self, priority, question)
コード例 #28
0
ファイル: timezone.py プロジェクト: jamieboo/ubiquity
    def run(self, priority, question):
        if question == 'time/zone':
            if self.multiple:
                # Work around a debconf bug: REGISTER does not appear to
                # give a newly-registered question the same default as the
                # question associated with its template, unless we also
                # RESET it.
                self.db.reset(question)
            zone = self.db.get(question)
            # Some countries don't have a default zone, so just pick the
            # first choice in the list.
            if not zone:
                choices_c = self.choices_untranslated(question)
                if choices_c:
                    zone = choices_c[0]
            # special cases where default is not in zone.tab
            if zone == 'Canada/Eastern':
                zone = 'America/Toronto'
            elif zone == 'US/Eastern':
                zone = 'America/New_York'
            self.frontend.set_timezone(zone)

        return FilteredCommand.run(self, priority, question)
コード例 #29
0
ファイル: language.py プロジェクト: jamieboo/ubiquity
    def run(self, priority, question):
        if question == 'localechooser/languagelist':
            self.language_question = question
            current_language_index = self.value_index(question)
            current_language = "English"

            import gzip
            languagelist = gzip.open('/usr/lib/ubiquity/localechooser/languagelist.data.gz')
            language_display_map = {}
            i = 0
            for line in languagelist:
                line = unicode(line, 'utf-8')
                if line == '' or line == '\n':
                    continue
                code, name, trans = line.strip(u'\n').split(u':')[1:]
                if code in ('dz', 'km'):
                    i += 1
                    continue
                language_display_map[trans] = (name, code)
                if i == current_language_index:
                    current_language = trans
                i += 1
            languagelist.close()

            def compare_choice(x, y):
                result = cmp(language_display_map[x][1],
                             language_display_map[y][1])
                if result != 0:
                    return result
                return cmp(x, y)

            sorted_choices = sorted(language_display_map, compare_choice)
            self.frontend.set_language_choices(sorted_choices,
                                               language_display_map)
            self.frontend.set_language(current_language)

        return FilteredCommand.run(self, priority, question)
コード例 #30
0
ファイル: install.py プロジェクト: JoliOS/ubiquity
    def run(self, priority, question):
        if question.endswith("/apt-install-failed"):
            return self.error(priority, question)

        elif question == "migration-assistant/failed-unmount":
            response = self.frontend.question_dialog(
                self.description(question),
                self.extended_description(question),
                ("ubiquity/text/go_back", "ubiquity/text/continue"),
            )
            if response is None or response == "ubiquity/text/continue":
                self.preseed(question, "true")
            else:
                self.preseed(question, "false")
            return True
        elif question == "ubiquity/install/copying_error/md5":
            response = self.frontend.question_dialog(
                self.description(question),
                # TODO evand 2008-02-14: i18n.
                self.extended_description(question),
                ("Abort", "Retry", "Skip"),
                use_templates=False,
            )
            if response is None or response == "Abort":
                self.preseed(question, "abort")
            elif response == "Retry":
                self.preseed(question, "retry")
            elif response == "Skip":
                self.preseed(question, "skip")
            return True
        elif question == "ubiquity/install/new-bootdev":
            current_device = self.db.get(question)
            response = self.frontend.bootloader_dialog(current_device)
            self.preseed(question, response)
            return True

        return FilteredCommand.run(self, priority, question)
コード例 #31
0
    def run(self,priority,question):
        if question.startswith('mythbuntu/vncservice'):
            vnc = self.frontend.get_vnc()
            self.preseed_bool('mythbuntu/vncservice', vnc)
        elif question.startswith('mythbuntu/vnc_password'):
            if not self.frontend.get_vnc():
                vnc_pass = "******"
            else:
                vnc_pass = self.frontend.get_vnc_password()
            self.preseed('mythbuntu/vnc_password', vnc_pass)
        elif question.startswith('mythbuntu/sshservice'):
            ssh = self.frontend.get_ssh()
            self.preseed_bool('mythbuntu/sshservice', ssh)
        elif question.startswith('mythbuntu/sambaservice'):
            samba = self.frontend.get_samba()
            self.preseed_bool('mythbuntu/sambaservice', samba)
        elif question.startswith('mythbuntu/nfsservice'):
            nfs = self.frontend.get_nfs()
            self.preseed_bool('mythbuntu/nfsservice', nfs)
        elif question.startswith('mythbuntu/mysqlservice'):
            mysql_secure = self.frontend.get_mysql_port()
            self.preseed_bool('mythbuntu/mysqlservice', mysql_secure)

        return FilteredCommand.run(self, priority, question)
コード例 #32
0
    def run(self, priority, question):
        if question.startswith('languagechooser/language-name'):
            self.language_question = question

            # Get index of untranslated value; we'll map this to the
            # translated value later.
            current_language_index = self.value_index(question)
            current_language = "English"

            language_choices = self.split_choices(
                unicode(self.db.metaget(question, 'choices-en.utf-8'),
                        'utf-8', 'replace'))
            language_choices_c = self.choices_untranslated(question)

            language_codes = {}
            languagelist = open('/usr/lib/ubiquity/localechooser/languagelist')
            for line in languagelist:
                if line.startswith('#'):
                    continue
                bits = line.split(';')
                if len(bits) >= 3:
                    if bits[2] in ('dz', 'km'):
                        # Exclude these languages for now, as we don't ship
                        # fonts for them and we don't have sufficient
                        # translations anyway.
                        continue
                    elif bits[2] in ('pt', 'zh'):
                        # Special handling for subdivided languages.
                        code = '%s_%s' % (bits[2], bits[3])
                    else:
                        code = bits[2]
                    language_codes[bits[0]] = code
            languagelist.close()

            language_display_map = {}
            for i in range(len(language_choices)):
                choice = re.sub(r'.*? *- (.*)', r'\1', language_choices[i])
                choice_c = language_choices_c[i]
                if choice_c not in language_codes:
                    continue
                language_display_map[choice] = (choice_c,
                                                language_codes[choice_c])
                if i == current_language_index:
                    current_language = choice

            def compare_choice(x, y):
                result = cmp(language_display_map[x][1],
                             language_display_map[y][1])
                if result != 0:
                    return result
                return cmp(x, y)

            sorted_choices = sorted(language_display_map, compare_choice)
            self.frontend.set_language_choices(sorted_choices,
                                               language_display_map)
            self.frontend.set_language(current_language)

        elif question.startswith('countrychooser/'):
            if 'DEBCONF_USE_CDEBCONF' not in os.environ:
                # Normally this default is handled by Default-$LL, but since
                # we can't change debconf's language on the fly (unlike
                # cdebconf), we have to fake it.
                country = self.db.get('debian-installer/country')
                if question.endswith('shortlist'):
                    self.db.set(question, country)
                elif question.endswith('country-name') and country:
                    fp = open('/usr/share/iso-codes/iso_3166.tab')
                    try:
                        for line in fp:
                            if line.startswith(country):
                                line = line.rstrip('\n')
                                self.db.set(question, line.split('\t')[1])
                                break
                    finally:
                        fp.close()
            return True

        return FilteredCommand.run(self, priority, question)
コード例 #33
0
    def run(self, priority, question):
        if self.done:
            # user answered confirmation question or backed up
            return self.succeeded

        self.current_question = question
        options = self.snoop()
        menu_options = self.snoop_menu(options)
        self.debug('Partman: state = %s', self.__state)

        if question.endswith('automatically_partition'):
            self.autopartition_question = question
            choices = self.choices(question)

            if self.auto_state is None:
                self.some_device_desc = \
                    self.description('partman-auto/text/use_device')
                self.resize_desc = \
                    self.description('partman-auto/text/resize_use_free')
                self.manual_desc = \
                    self.description('partman-auto/text/custom_partitioning')
                self.extra_options = {}
                if choices:
                    self.auto_state = [0, None]
            else:
                self.auto_state[0] += 1
            while self.auto_state[0] < len(choices):
                self.auto_state[1] = choices[self.auto_state[0]]
                if (self.auto_state[1] == self.some_device_desc or
                    self.auto_state[1] == self.resize_desc):
                    break
                else:
                    self.auto_state[0] += 1
            if self.auto_state[0] < len(choices):
                # Don't preseed_as_c, because Perl debconf is buggy in that
                # it doesn't expand variables in the result of METAGET
                # choices-c. All locales have the same variables anyway so
                # it doesn't matter.
                self.preseed(question, self.auto_state[1])
                self.succeeded = True
                return True
            else:
                self.auto_state = None

            if self.resize_desc not in self.extra_options:
                try:
                    del choices[choices.index(self.resize_desc)]
                except ValueError:
                    pass
            self.frontend.set_autopartition_choices(
                choices, self.extra_options,
                self.resize_desc, self.manual_desc)

        elif question == 'partman-auto/select_disk':
            if self.auto_state is not None:
                self.extra_options[self.auto_state[1]] = self.choices(question)
                # Back up to autopartitioning question.
                self.succeeded = False
                return False
            else:
                assert self.extra_choice is not None
                self.preseed(question, self.extra_choice)
                self.succeeded = True
                return True

        elif question == 'partman/choose_partition':
            self.autopartition_question = None # not autopartitioning any more

            if not self.building_cache and self.update_partitions:
                # Rebuild our cache of just these partitions.
                self.__state = [['', None, None]]
                self.building_cache = True
                if 'ALL' in self.update_partitions:
                    self.update_partitions = None

            if self.building_cache:
                state = self.__state[-1]
                if state[0] == question:
                    # advance to next partition
                    self.frontend.debconf_progress_step(1)
                    self.frontend.refresh()
                    self.debug('Partman: update_partitions = %s',
                               self.update_partitions)
                    state[1] = None
                    while self.update_partitions:
                        state[1] = self.update_partitions[0]
                        del self.update_partitions[0]
                        if state[1] not in self.partition_cache:
                            self.debug('Partman: %s not found in cache',
                                       partition)
                            state[1] = None
                            self.frontend.debconf_progress_step(1)
                            self.frontend.refresh()
                        else:
                            break

                    if state[1] is not None:
                        # Move on to the next partition.
                        partition = self.partition_cache[state[1]]
                        self.debug('Partman: Building cache (%s)',
                                   partition['parted']['path'])
                        self.preseed(question, partition['display'])
                        return True
                    else:
                        # Finished building the cache.
                        self.debug('Partman: Finished building cache')
                        self.__state.pop()
                        self.update_partitions = None
                        self.building_cache = False
                        self.frontend.debconf_progress_stop()
                        self.frontend.refresh()
                        self.frontend.update_partman(
                            self.disk_cache, self.partition_cache,
                            self.cache_order)
                else:
                    self.debug('Partman: Building cache')
                    os.seteuid(0)
                    parted = parted_server.PartedServer()
                    matches = self.find_script(menu_options, 'partition_tree')

                    # If we're only updating our cache for certain
                    # partitions, then self.update_partitions will be a list
                    # of the partitions to update; otherwise, we build the
                    # cache from scratch.
                    rebuild_all = self.update_partitions is None

                    if rebuild_all:
                        self.disk_cache = {}
                        self.partition_cache = {}
                    self.cache_order = []

                    # Clear out the partitions we're updating to make sure
                    # stale keys are removed.
                    if self.update_partitions is not None:
                        for devpart in self.update_partitions:
                            if devpart in self.partition_cache:
                                del self.partition_cache[devpart]

                    # Initialise any items we haven't heard of yet.
                    for script, arg, option in matches:
                        dev, part_id = self.split_devpart(arg)
                        if not dev:
                            continue
                        parted.select_disk(dev)
                        self.cache_order.append(arg)
                        if part_id:
                            if rebuild_all or arg not in self.partition_cache:
                                self.partition_cache[arg] = {
                                    'dev': dev,
                                    'id': part_id
                                }
                        else:
                            if rebuild_all or arg not in self.disk_cache:
                                device = parted.readline_device_entry('device')
                                self.disk_cache[arg] = {
                                    'dev': dev,
                                    'device': device
                                }

                    if self.update_partitions is None:
                        self.update_partitions = self.partition_cache.keys()
                    else:
                        self.update_partitions = [devpart
                            for devpart in self.update_partitions
                            if devpart in self.partition_cache]

                    # Update the display names of all disks and partitions.
                    for script, arg, option in matches:
                        dev, part_id = self.split_devpart(arg)
                        if not dev:
                            continue
                        parted.select_disk(dev)
                        if part_id:
                            self.partition_cache[arg]['display'] = option
                        else:
                            self.disk_cache[arg]['display'] = option

                    # Get basic information from parted_server for each
                    # partition being updated.
                    for devpart in self.update_partitions:
                        dev, part_id = self.split_devpart(devpart)
                        if not dev:
                            continue
                        parted.select_disk(dev)
                        info = parted.partition_info(part_id)
                        self.partition_cache[devpart]['parted'] = {
                            'num': info[0],
                            'id': info[1],
                            'size': info[2],
                            'type': info[3],
                            'fs': info[4],
                            'path': info[5],
                            'name': info[6]
                        }

                    drop_privileges()
                    self.frontend.debconf_progress_start(
                        0, len(self.update_partitions),
                        self.description('partman/progress/init/parted'))
                    self.frontend.refresh()
                    self.debug('Partman: update_partitions = %s',
                               self.update_partitions)

                    # Selecting a disk will ask to create a new disklabel,
                    # so don't bother with that.

                    devpart = None
                    if self.partition_cache:
                        while self.update_partitions:
                            devpart = self.update_partitions[0]
                            del self.update_partitions[0]
                            if devpart not in self.partition_cache:
                                self.debug('Partman: %s not found in cache',
                                           partition)
                                devpart = None
                                self.frontend.debconf_progress_step(1)
                                self.frontend.refresh()
                            else:
                                break
                    if devpart is not None:
                        partition = self.partition_cache[devpart]
                        self.debug('Partman: Building cache (%s)',
                                   partition['parted']['path'])
                        self.__state.append([question, devpart, None])
                        self.preseed(question, partition['display'])
                        return True
                    else:
                        self.debug('Partman: Finished building cache '
                                   '(no partitions to update)')
                        self.update_partitions = None
                        self.building_cache = False
                        self.frontend.debconf_progress_stop()
                        self.frontend.refresh()
                        self.frontend.update_partman(
                            self.disk_cache, self.partition_cache,
                            self.cache_order)
            elif self.creating_partition:
                devpart = self.creating_partition['devpart']
                if devpart in self.partition_cache:
                    self.frontend.update_partman(
                        self.disk_cache, self.partition_cache,
                        self.cache_order)
            elif self.editing_partition:
                devpart = self.editing_partition['devpart']
                if devpart in self.partition_cache:
                    self.frontend.update_partman(
                        self.disk_cache, self.partition_cache,
                        self.cache_order)
            elif self.deleting_partition:
                raise AssertionError, "Deleting partition didn't rebuild cache?"

            if self.debug_enabled():
                import pprint
                self.debug('disk_cache:')
                printer = pprint.PrettyPrinter()
                for line in printer.pformat(self.disk_cache).split('\n'):
                    self.debug('%s', line)
                self.debug('disk_cache end')
                self.debug('partition_cache:')
                printer = pprint.PrettyPrinter()
                for line in printer.pformat(self.partition_cache).split('\n'):
                    self.debug('%s', line)
                self.debug('partition_cache end')

            self.__state = [['', None, None]]
            self.creating_label = None
            self.creating_partition = None
            self.editing_partition = None
            self.deleting_partition = None
            self.undoing = False
            self.finish_partitioning = False

            FilteredCommand.run(self, priority, question)

            if self.finish_partitioning or self.done:
                if self.succeeded:
                    self.preseed_script(question, menu_options, 'finish')
                return self.succeeded

            elif self.creating_label:
                devpart = self.creating_label['devpart']
                if devpart in self.disk_cache:
                    disk = self.disk_cache[devpart]
                    # No need to use self.__state to keep track of this.
                    self.preseed(question, disk['display'])
                return True

            elif self.creating_partition:
                devpart = self.creating_partition['devpart']
                if devpart in self.partition_cache:
                    partition = self.partition_cache[devpart]
                    self.__state.append([question, devpart, None])
                    self.preseed(question, partition['display'])
                return True

            elif self.editing_partition:
                devpart = self.editing_partition['devpart']
                if devpart in self.partition_cache:
                    partition = self.partition_cache[devpart]
                    self.__state.append([question, devpart, None])
                    self.preseed(question, partition['display'])
                return True

            elif self.deleting_partition:
                devpart = self.deleting_partition['devpart']
                if devpart in self.partition_cache:
                    partition = self.partition_cache[devpart]
                    # No need to use self.__state to keep track of this.
                    self.preseed(question, partition['display'])
                return True

            elif self.undoing:
                self.preseed_script(question, menu_options, 'undo')
                return True

            else:
                raise AssertionError, ("Returned to %s with nothing to do" %
                                       question)

        elif question == 'partman-partitioning/confirm_new_label':
            if self.creating_label:
                response = self.frontend.question_dialog(
                    self.description(question),
                    self.extended_description(question),
                    ('ubiquity/text/go_back', 'ubiquity/text/continue'))
                if response is None or response == 'ubiquity/text/continue':
                    self.preseed(question, 'true')
                else:
                    self.preseed(question, 'false')
                return True
            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question == 'partman/free_space':
            if self.building_cache:
                state = self.__state[-1]
                assert state[0] == 'partman/choose_partition'
                partition = self.partition_cache[state[1]]
                can_new = False
                if self.find_script(menu_options, 'new'):
                    can_new = True
                partition['can_new'] = can_new
                # Back up to the previous menu.
                return False
            elif self.creating_partition:
                self.preseed_script(question, menu_options, 'new')
                return True
            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question == 'partman-partitioning/new_partition_size':
            if self.creating_partition:
                if 'bad_size' in self.creating_partition:
                    return False
                size = self.creating_partition['size']
                if re.search(r'^[0-9.]+$', size):
                    # ensure megabytes just in case partman's semantics change
                    size += 'M'
                self.preseed(question, size)
                return True
            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question == 'partman-partitioning/new_partition_type':
            if self.creating_partition:
                if self.creating_partition['type'] == PARTITION_TYPE_PRIMARY:
                    self.preseed(question, 'Primary')
                else:
                    self.preseed(question, 'Logical')
                return True
            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question == 'partman-partitioning/new_partition_place':
            if self.creating_partition:
                if (self.creating_partition['place'] ==
                    PARTITION_PLACE_BEGINNING):
                    self.preseed(question, 'Beginning')
                else:
                    self.preseed(question, 'End')
                return True
            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question == 'partman/active_partition':
            if self.building_cache:
                state = self.__state[-1]
                partition = self.partition_cache[state[1]]

                if state[0] == question:
                    state[2] += 1
                    if state[2] < len(partition['active_partition_build']):
                        # Move on to the next item.
                        visit = partition['active_partition_build']
                        self.preseed(question, visit[state[2]][2])
                        return True
                    else:
                        # Finished building the cache for this submenu; go
                        # back to the previous one.
                        try:
                            del partition['active_partition_build']
                        except KeyError:
                            pass
                        self.__state.pop()
                        return False

                assert state[0] == 'partman/choose_partition'
                os.seteuid(0)
                parted = parted_server.PartedServer()

                parted.select_disk(partition['dev'])
                for entry in ('method',
                              'filesystem', 'detected_filesystem',
                              'acting_filesystem',
                              'existing', 'formatable',
                              'mountpoint'):
                    if parted.has_part_entry(partition['id'], entry):
                        partition[entry] = \
                            parted.readline_part_entry(partition['id'], entry)

                drop_privileges()
                visit = []
                for (script, arg, option) in menu_options:
                    if arg in ('method', 'mountpoint'):
                        visit.append((script, arg, option))
                    elif arg == 'format':
                        partition['can_activate_format'] = True
                    elif arg == 'resize':
                        visit.append((script, arg, option))
                        partition['can_resize'] = True
                if visit:
                    partition['active_partition_build'] = visit
                    self.__state.append([question, state[1], 0])
                    self.preseed(question, visit[0][2])
                    return True
                else:
                    # Back up to the previous menu.
                    return False

            elif self.creating_partition or self.editing_partition:
                if self.creating_partition:
                    request = self.creating_partition
                else:
                    request = self.editing_partition

                state = self.__state[-1]
                partition = self.partition_cache[state[1]]

                if state[0] != question:
                    # Set up our intentions for this menu.
                    visit = []
                    for item in ('method', 'mountpoint', 'format'):
                        if item in request and request[item] is not None:
                            visit.append(item)
                    if (self.editing_partition and
                        'size' in request and request['size'] is not None):
                        visit.append('resize')
                    partition['active_partition_edit'] = visit
                    self.__state.append([question, state[1], -1])
                    state = self.__state[-1]

                state[2] += 1
                while state[2] < len(partition['active_partition_edit']):
                    # Move on to the next item.
                    visit = partition['active_partition_edit']
                    item = visit[state[2]]
                    scripts = self.find_script(menu_options, None, item)
                    if scripts:
                        self.preseed(question, scripts[0][2])
                        return True
                    state[2] += 1

                # If we didn't find anything to do, finish editing this
                # partition.
                try:
                    del partition['active_partition_edit']
                except KeyError:
                    pass
                self.__state.pop()
                self.preseed_script(question, menu_options, 'finish')
                return True

            elif self.deleting_partition:
                self.preseed_script(question, menu_options, 'delete')
                self.deleting_partition = None
                return True

            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question == 'partman-partitioning/confirm_resize':
            if self.autopartition_question is not None:
                if self.auto_state is not None:
                    # Proceed through confirmation question; we'll back up
                    # later.
                    self.preseed(question, 'true')
                    return True
                else:
                    response = self.frontend.question_dialog(
                        self.description(question),
                        self.extended_description(question),
                        ('ubiquity/text/go_back', 'ubiquity/text/continue'))
                    if (response is None or
                        response == 'ubiquity/text/continue'):
                        self.preseed(question, 'true')
                    else:
                        self.preseed(question, 'false')
                    return True
            elif self.building_cache:
                state = self.__state[-1]
                assert state[0] == 'partman/active_partition'
                # Proceed through to asking for the size; don't worry, we'll
                # back up from there.
                self.preseed(question, 'true')
                return True
            elif self.editing_partition:
                response = self.frontend.question_dialog(
                    self.description(question),
                    self.extended_description(question),
                    ('ubiquity/text/go_back', 'ubiquity/text/continue'))
                if response is None or response == 'ubiquity/text/continue':
                    self.preseed(question, 'true')
                else:
                    self.preseed(question, 'false')
                return True
            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question == 'partman-partitioning/new_size':
            if self.autopartition_question is not None:
                if self.auto_state is not None:
                    self.extra_options[self.auto_state[1]] = \
                        (self.resize_min_size, self.resize_max_size,
                            self.resize_orig_size, self.resize_path)
                    # Back up to autopartitioning question.
                    self.succeeded = False
                    return False
                else:
                    assert self.extra_choice is not None
                    if self.bad_auto_size:
                        self.bad_auto_size = False
                        return False
                    self.preseed(question, '%d%%' % self.extra_choice)
                    self.succeeded = True
                    return True
            elif self.building_cache:
                # subst() should have gathered the necessary information.
                # Back up.
                return False
            elif self.editing_partition:
                if 'bad_size' in self.editing_partition:
                    return False
                size = self.editing_partition['size']
                if re.search(r'^[0-9.]+$', size):
                    # ensure megabytes just in case partman's semantics change
                    size += 'M'
                self.preseed(question, size)
                return True
            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question == 'partman-target/choose_method':
            if self.building_cache:
                state = self.__state[-1]
                assert state[0] == 'partman/active_partition'
                partition = self.partition_cache[state[1]]
                partition['method_choices'] = []
                for (script, arg, option) in menu_options:
                    partition['method_choices'].append((script, arg, option))
                # Back up to the previous menu.
                return False
            elif self.creating_partition or self.editing_partition:
                if self.creating_partition:
                    request = self.creating_partition
                else:
                    request = self.editing_partition

                self.preseed_script(question, menu_options,
                                    None, request['method'])
                return True
            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question in ('partman-basicfilesystems/mountpoint',
                          'partman-basicfilesystems/fat_mountpoint'):
            if self.building_cache:
                state = self.__state[-1]
                assert state[0] == 'partman/active_partition'
                partition = self.partition_cache[state[1]]
                partition['mountpoint_choices'] = []
                choices_c = self.choices_untranslated(question)
                choices = self.choices(question)
                assert len(choices_c) == len(choices)
                for i in range(len(choices_c)):
                    if choices_c[i].startswith('/'):
                        partition['mountpoint_choices'].append((
                            choices_c[i].split(' ')[0],
                            choices_c[i], choices[i]))
                # Back up to the previous menu.
                return False
            elif self.creating_partition or self.editing_partition:
                if self.creating_partition:
                    request = self.creating_partition
                else:
                    request = self.editing_partition
                if 'bad_mountpoint' in request:
                    return False
                mountpoint = request['mountpoint']

                if mountpoint == '' or mountpoint is None:
                    self.preseed(question, 'Do not mount it')
                else:
                    self.preseed(question, 'Enter manually')
                return True
            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question == 'partman-basicfilesystems/mountpoint_manual':
            if self.creating_partition or self.editing_partition:
                if self.creating_partition:
                    request = self.creating_partition
                else:
                    request = self.editing_partition
                if 'bad_mountpoint' in request:
                    return False

                self.preseed(question, request['mountpoint'])
                return True
            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question.startswith('partman/confirm'):
            if question == 'partman/confirm':
                self.db.set('ubiquity/partman-made-changes', 'true')
            else:
                self.db.set('ubiquity/partman-made-changes', 'false')
            self.preseed(question, 'true')
            self.succeeded = True
            self.done = True
            return True

        elif question == 'partman/exception_handler':
            if priority == 'critical' or priority == 'high':
                response = self.frontend.question_dialog(
                    self.description(question),
                    self.extended_description(question),
                    self.choices(question), use_templates=False)
                self.preseed(question, response)
            else:
                self.preseed(question, 'unhandled')
            return True

        elif question == 'partman/exception_handler_note':
            if priority == 'critical' or priority == 'high':
                self.frontend.error_dialog(self.description(question),
                                           self.extended_description(question))
                return FilteredCommand.error(self, priority, question)
            else:
                return True

        elif self.question_type(question) == 'boolean':
            response = self.frontend.question_dialog(
                self.description(question),
                self.extended_description(question),
                ('ubiquity/text/go_back', 'ubiquity/text/continue'))

            answer_reversed = False
            if question in ('partman-jfs/jfs_boot', 'partman-jfs/jfs_root',
                            'grub-installer/install_to_xfs'):
                answer_reversed = True
            if response is None or response == 'ubiquity/text/continue':
                answer = answer_reversed
            else:
                answer = not answer_reversed
            if answer:
                self.preseed(question, 'true')
            else:
                self.preseed(question, 'false')
            return True

        return FilteredCommand.run(self, priority, question)
コード例 #34
0
 def run(self,priority,question):
     if question.startswith('mythbuntu/advanced_install'):
         advanced = self.frontend.get_advanced()
         self.preseed_bool('mythbuntu/advanced_install', advanced)
     return FilteredCommand.run(self, priority, question)
コード例 #35
0
 def run(self,priority,question):
     if question.startswith('mythbuntu/install_type'):
         installtype = self.frontend.get_installtype()
         self.preseed('mythbuntu/install_type', installtype)
     return FilteredCommand.run(self, priority, question)
コード例 #36
0
ファイル: partman.py プロジェクト: jamieboo/ubiquity
    def run(self, priority, question):
        if self.done:
            # user answered confirmation question or backed up
            return self.succeeded

        self.current_question = question
        options = self.snoop()
        menu_options = self.snoop_menu(options)
        self.debug("Partman: state = %s", self.__state)
        self.debug("Partman: auto_state = %s", self.auto_state)

        if question.endswith("automatically_partition"):
            self.autopartition_question = question
            choices = self.choices(question)

            if self.auto_state is None:
                self.some_device_desc = self.description("partman-auto/text/use_device")
                self.resize_desc = self.description("partman-auto/text/resize_use_free")
                self.manual_desc = self.description("partman-auto/text/custom_partitioning")
                self.biggest_free_desc = self.description("partman-auto/text/use_biggest_free")
                self.extra_options = {}
                if choices:
                    self.auto_state = [0, None]
            else:
                self.auto_state[0] += 1
            while self.auto_state[0] < len(choices):
                self.auto_state[1] = choices[self.auto_state[0]]
                if self.auto_state[1] == self.some_device_desc or self.auto_state[1] == self.resize_desc:
                    break
                else:
                    self.auto_state[0] += 1
            if self.auto_state[0] < len(choices):
                self.preseed_as_c(question, self.auto_state[1], seen=False)
                self.succeeded = True
                return True
            else:
                self.auto_state = None

            if self.resize_desc not in self.extra_options:
                try:
                    del choices[choices.index(self.resize_desc)]
                except ValueError:
                    pass
            regain_privileges()
            # {'/dev/sda' : ('/dev/sda1', 24973242, '32256-2352430079'), ...
            # TODO evand 2009-04-16: We should really use named tuples here.
            parted = parted_server.PartedServer()
            layout = {}
            for disk in parted.disks():
                parted.select_disk(disk)
                ret = []
                total = 0
                for partition in parted.partitions():
                    size = int(partition[2])
                    if partition[4] == "free":
                        dev = "free"
                    else:
                        dev = partition[5]
                    ret.append((dev, size, partition[1]))
                layout[disk] = ret

            self.frontend.set_disk_layout(layout)
            drop_privileges()

            # Set up translation mappings to avoid debian-installer
            # specific text ('Guided -').
            self.translation_mappings = {}

            def map_trans(di_string, ubiquity_string):
                ubiquity_string = self.description(ubiquity_string)
                self.translation_mappings[ubiquity_string] = di_string
                try:
                    choices[choices.index(di_string)] = ubiquity_string
                except ValueError:
                    pass
                if di_string in self.extra_options:
                    t = self.extra_options[di_string]
                    del self.extra_options[di_string]
                    self.extra_options[ubiquity_string] = t
                return ubiquity_string

            self.some_device_desc = map_trans(self.some_device_desc, "ubiquity/text/use_device")
            self.biggest_free_desc = map_trans(self.biggest_free_desc, "ubiquity/text/biggest_free")
            self.resize_desc = map_trans(self.resize_desc, "ubiquity/text/resize_use_free")
            self.manual_desc = map_trans(self.manual_desc, "ubiquity/text/custom_partitioning")

            biggest_free = self.find_script(menu_options, "biggest_free")
            if biggest_free:
                biggest_free = biggest_free[0][1]
                biggest_free = self.split_devpart(biggest_free)[1]
            self.extra_options[self.biggest_free_desc] = biggest_free

            self.frontend.set_autopartition_choices(
                choices, self.extra_options, self.resize_desc, self.manual_desc, self.biggest_free_desc
            )

        elif question == "partman-auto/select_disk":
            if self.auto_state is not None:
                self.extra_options[self.auto_state[1]] = self.choices(question)
                # Back up to autopartitioning question.
                self.succeeded = False
                return False
            else:
                assert self.extra_choice is not None
                self.preseed_as_c(question, self.extra_choice, seen=False)
                self.succeeded = True
                return True

        elif question == "partman/choose_partition":
            self.autopartition_question = None  # not autopartitioning any more

            if not self.building_cache and self.update_partitions:
                # Rebuild our cache of just these partitions.
                self.__state = [["", None, None]]
                self.building_cache = True
                if "ALL" in self.update_partitions:
                    self.update_partitions = None

            if self.building_cache:
                state = self.__state[-1]
                if state[0] == question:
                    # advance to next partition
                    self.frontend.debconf_progress_step(1)
                    self.frontend.refresh()
                    self.debug("Partman: update_partitions = %s", self.update_partitions)
                    state[1] = None
                    while self.update_partitions:
                        state[1] = self.update_partitions[0]
                        del self.update_partitions[0]
                        if state[1] not in self.partition_cache:
                            self.debug("Partman: %s not found in cache", partition)
                            state[1] = None
                            self.frontend.debconf_progress_step(1)
                            self.frontend.refresh()
                        else:
                            break

                    if state[1] is not None:
                        # Move on to the next partition.
                        partition = self.partition_cache[state[1]]
                        self.debug("Partman: Building cache (%s)", partition["parted"]["path"])
                        self.preseed(question, partition["display"], seen=False)
                        return True
                    else:
                        # Finished building the cache.
                        self.debug("Partman: Finished building cache")
                        self.__state.pop()
                        self.update_partitions = None
                        self.building_cache = False
                        self.frontend.debconf_progress_stop()
                        self.frontend.refresh()
                        self.frontend.update_partman(self.disk_cache, self.partition_cache, self.cache_order)
                else:
                    self.debug("Partman: Building cache")
                    regain_privileges()
                    parted = parted_server.PartedServer()
                    matches = self.find_script(menu_options, "partition_tree")

                    # If we're only updating our cache for certain
                    # partitions, then self.update_partitions will be a list
                    # of the partitions to update; otherwise, we build the
                    # cache from scratch.
                    rebuild_all = self.update_partitions is None

                    if rebuild_all:
                        self.disk_cache = {}
                        self.partition_cache = {}
                    self.cache_order = []

                    # Clear out the partitions we're updating to make sure
                    # stale keys are removed.
                    if self.update_partitions is not None:
                        for devpart in self.update_partitions:
                            if devpart in self.partition_cache:
                                del self.partition_cache[devpart]

                    # Initialise any items we haven't heard of yet.
                    for script, arg, option in matches:
                        dev, part_id = self.split_devpart(arg)
                        if not dev:
                            continue
                        parted.select_disk(dev)
                        self.cache_order.append(arg)
                        if part_id:
                            if rebuild_all or arg not in self.partition_cache:
                                self.partition_cache[arg] = {"dev": dev, "id": part_id, "parent": dev.replace("=", "/")}
                        else:
                            if rebuild_all or arg not in self.disk_cache:
                                device = parted.readline_device_entry("device")
                                self.disk_cache[arg] = {"dev": dev, "device": device}

                    if self.update_partitions is None:
                        self.update_partitions = self.partition_cache.keys()
                    else:
                        self.update_partitions = [
                            devpart for devpart in self.update_partitions if devpart in self.partition_cache
                        ]

                    # Update the display names of all disks and partitions.
                    for script, arg, option in matches:
                        dev, part_id = self.split_devpart(arg)
                        if not dev:
                            continue
                        parted.select_disk(dev)
                        if part_id:
                            self.partition_cache[arg]["display"] = "%s__________%s" % (script, arg)
                        else:
                            self.disk_cache[arg]["display"] = "%s__________%s" % (script, arg)

                    # Get basic information from parted_server for each
                    # partition being updated.
                    for devpart in self.update_partitions:
                        dev, part_id = self.split_devpart(devpart)
                        if not dev:
                            continue
                        parted.select_disk(dev)
                        info = parted.partition_info(part_id)
                        self.partition_cache[devpart]["parted"] = {
                            "num": info[0],
                            "id": info[1],
                            "size": info[2],
                            "type": info[3],
                            "fs": info[4],
                            "path": info[5],
                            "name": info[6],
                        }

                    drop_privileges()
                    self.frontend.debconf_progress_start(
                        0, len(self.update_partitions), self.description("partman/progress/init/parted")
                    )
                    self.frontend.refresh()
                    self.debug("Partman: update_partitions = %s", self.update_partitions)

                    # Selecting a disk will ask to create a new disklabel,
                    # so don't bother with that.

                    devpart = None
                    if self.partition_cache:
                        while self.update_partitions:
                            devpart = self.update_partitions[0]
                            del self.update_partitions[0]
                            if devpart not in self.partition_cache:
                                self.debug("Partman: %s not found in cache", partition)
                                devpart = None
                                self.frontend.debconf_progress_step(1)
                                self.frontend.refresh()
                            else:
                                break
                    if devpart is not None:
                        partition = self.partition_cache[devpart]
                        self.debug("Partman: Building cache (%s)", partition["parted"]["path"])
                        self.__state.append([question, devpart, None])
                        self.preseed(question, partition["display"], seen=False)
                        return True
                    else:
                        self.debug("Partman: Finished building cache " "(no partitions to update)")
                        self.update_partitions = None
                        self.building_cache = False
                        self.frontend.debconf_progress_stop()
                        self.frontend.refresh()
                        self.frontend.update_partman(self.disk_cache, self.partition_cache, self.cache_order)
            elif self.creating_partition:
                devpart = self.creating_partition["devpart"]
                if devpart in self.partition_cache:
                    self.frontend.update_partman(self.disk_cache, self.partition_cache, self.cache_order)
            elif self.editing_partition:
                devpart = self.editing_partition["devpart"]
                if devpart in self.partition_cache:
                    self.frontend.update_partman(self.disk_cache, self.partition_cache, self.cache_order)
            elif self.deleting_partition:
                raise AssertionError, "Deleting partition didn't rebuild cache?"

            if self.debug_enabled():
                import pprint

                self.debug("disk_cache:")
                printer = pprint.PrettyPrinter()
                for line in printer.pformat(self.disk_cache).split("\n"):
                    self.debug("%s", line)
                self.debug("disk_cache end")
                self.debug("partition_cache:")
                printer = pprint.PrettyPrinter()
                for line in printer.pformat(self.partition_cache).split("\n"):
                    self.debug("%s", line)
                self.debug("partition_cache end")

            self.__state = [["", None, None]]
            self.creating_label = None
            self.creating_partition = None
            self.editing_partition = None
            self.deleting_partition = None
            self.undoing = False
            self.finish_partitioning = False

            FilteredCommand.run(self, priority, question)

            if self.finish_partitioning or self.done:
                if self.succeeded:
                    self.preseed_script(question, menu_options, "finish")
                return self.succeeded

            elif self.creating_label:
                devpart = self.creating_label["devpart"]
                if devpart in self.disk_cache:
                    disk = self.disk_cache[devpart]
                    # No need to use self.__state to keep track of this.
                    self.preseed(question, disk["display"], seen=False)
                return True

            elif self.creating_partition:
                devpart = self.creating_partition["devpart"]
                if devpart in self.partition_cache:
                    partition = self.partition_cache[devpart]
                    self.__state.append([question, devpart, None])
                    self.preseed(question, partition["display"], seen=False)
                return True

            elif self.editing_partition:
                devpart = self.editing_partition["devpart"]
                if devpart in self.partition_cache:
                    partition = self.partition_cache[devpart]
                    self.__state.append([question, devpart, None])
                    self.preseed(question, partition["display"], seen=False)
                return True

            elif self.deleting_partition:
                devpart = self.deleting_partition["devpart"]
                if devpart in self.partition_cache:
                    partition = self.partition_cache[devpart]
                    # No need to use self.__state to keep track of this.
                    self.preseed(question, partition["display"], seen=False)
                return True

            elif self.undoing:
                self.preseed_script(question, menu_options, "undo")
                return True

            else:
                raise AssertionError, ("Returned to %s with nothing to do" % question)

        elif question == "partman-partitioning/confirm_new_label":
            if self.creating_label:
                response = self.frontend.question_dialog(
                    self.description(question),
                    self.extended_description(question),
                    ("ubiquity/text/go_back", "ubiquity/text/continue"),
                )
                if response is None or response == "ubiquity/text/continue":
                    self.preseed(question, "true", seen=False)
                else:
                    self.preseed(question, "false", seen=False)
                return True
            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question == "partman/free_space":
            if self.building_cache:
                state = self.__state[-1]
                assert state[0] == "partman/choose_partition"
                partition = self.partition_cache[state[1]]
                can_new = False
                if self.find_script(menu_options, "new"):
                    can_new = True
                partition["can_new"] = can_new
                # Back up to the previous menu.
                return False
            elif self.creating_partition:
                self.preseed_script(question, menu_options, "new")
                return True
            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question == "partman-partitioning/new_partition_size":
            if self.creating_partition:
                if "bad_size" in self.creating_partition:
                    return False
                size = self.creating_partition["size"]
                if re.search(r"^[0-9.]+$", size):
                    # ensure megabytes just in case partman's semantics change
                    size += "M"
                self.preseed(question, size, seen=False)
                return True
            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question == "partman-partitioning/new_partition_type":
            if self.creating_partition:
                if self.creating_partition["type"] == PARTITION_TYPE_PRIMARY:
                    self.preseed(question, "Primary", seen=False)
                else:
                    self.preseed(question, "Logical", seen=False)
                return True
            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question == "partman-partitioning/new_partition_place":
            if self.creating_partition:
                if self.creating_partition["place"] == PARTITION_PLACE_BEGINNING:
                    self.preseed(question, "Beginning", seen=False)
                else:
                    self.preseed(question, "End", seen=False)
                return True
            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question == "partman/active_partition":
            if self.building_cache:
                state = self.__state[-1]
                partition = self.partition_cache[state[1]]

                if state[0] == question:
                    state[2] += 1
                    if state[2] < len(partition["active_partition_build"]):
                        # Move on to the next item.
                        visit = partition["active_partition_build"]
                        self.preseed_as_c(question, visit[state[2]][2], seen=False)
                        return True
                    else:
                        # Finished building the cache for this submenu; go
                        # back to the previous one.
                        try:
                            del partition["active_partition_build"]
                        except KeyError:
                            pass
                        self.__state.pop()
                        return False

                assert state[0] == "partman/choose_partition"
                regain_privileges()
                parted = parted_server.PartedServer()

                parted.select_disk(partition["dev"])
                for entry in (
                    "method",
                    "filesystem",
                    "detected_filesystem",
                    "acting_filesystem",
                    "existing",
                    "formatable",
                    "mountpoint",
                ):
                    if parted.has_part_entry(partition["id"], entry):
                        partition[entry] = parted.readline_part_entry(partition["id"], entry)

                drop_privileges()
                visit = []
                for (script, arg, option) in menu_options:
                    if arg in ("method", "mountpoint"):
                        visit.append((script, arg, option))
                    elif arg == "format":
                        partition["can_activate_format"] = True
                    elif arg == "resize":
                        visit.append((script, arg, option))
                        partition["can_resize"] = True
                if visit:
                    partition["active_partition_build"] = visit
                    self.__state.append([question, state[1], 0])
                    self.preseed_as_c(question, visit[0][2], seen=False)
                    return True
                else:
                    # Back up to the previous menu.
                    return False

            elif self.creating_partition or self.editing_partition:
                if self.creating_partition:
                    request = self.creating_partition
                else:
                    request = self.editing_partition

                state = self.__state[-1]
                partition = self.partition_cache[state[1]]

                if state[0] != question:
                    # Set up our intentions for this menu.
                    visit = []
                    for item in ("method", "mountpoint", "format"):
                        if item in request and request[item] is not None:
                            visit.append(item)
                    if self.editing_partition and "size" in request and request["size"] is not None:
                        visit.append("resize")
                    partition["active_partition_edit"] = visit
                    self.__state.append([question, state[1], -1])
                    state = self.__state[-1]

                state[2] += 1
                while state[2] < len(partition["active_partition_edit"]):
                    # Move on to the next item.
                    visit = partition["active_partition_edit"]
                    item = visit[state[2]]
                    scripts = self.find_script(menu_options, None, item)
                    if scripts:
                        self.preseed_as_c(question, scripts[0][2], seen=False)
                        return True
                    state[2] += 1

                # If we didn't find anything to do, finish editing this
                # partition.
                try:
                    del partition["active_partition_edit"]
                except KeyError:
                    pass
                self.__state.pop()
                self.preseed_script(question, menu_options, "finish")
                return True

            elif self.deleting_partition:
                self.preseed_script(question, menu_options, "delete")
                self.deleting_partition = None
                return True

            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question == "partman-partitioning/confirm_resize":
            if self.autopartition_question is not None:
                if self.auto_state is not None:
                    # Proceed through confirmation question; we'll back up
                    # later.
                    self.preseed(question, "true", seen=False)
                    return True
                else:
                    response = self.frontend.question_dialog(
                        self.description(question),
                        self.extended_description(question),
                        ("ubiquity/text/go_back", "ubiquity/text/continue"),
                    )
                    if response is None or response == "ubiquity/text/continue":
                        self.preseed(question, "true", seen=False)
                    else:
                        self.preseed(question, "false", seen=False)
                    return True
            elif self.building_cache:
                state = self.__state[-1]
                assert state[0] == "partman/active_partition"
                # Proceed through to asking for the size; don't worry, we'll
                # back up from there.
                self.preseed(question, "true", seen=False)
                return True
            elif self.editing_partition:
                response = self.frontend.question_dialog(
                    self.description(question),
                    self.extended_description(question),
                    ("ubiquity/text/go_back", "ubiquity/text/continue"),
                )
                if response is None or response == "ubiquity/text/continue":
                    self.preseed(question, "true", seen=False)
                else:
                    self.preseed(question, "false", seen=False)
                return True
            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question == "partman-partitioning/new_size":
            if self.autopartition_question is not None:
                if self.auto_state is not None:
                    self.extra_options[self.auto_state[1]] = (
                        self.resize_min_size,
                        self.resize_max_size,
                        self.resize_orig_size,
                        self.resize_path,
                    )
                    # Back up to autopartitioning question.
                    self.succeeded = False
                    return False
                else:
                    assert self.extra_choice is not None
                    if self.bad_auto_size:
                        self.bad_auto_size = False
                        return False
                    self.preseed(question, self.extra_choice, seen=False)
                    self.succeeded = True
                    return True
            elif self.building_cache:
                # subst() should have gathered the necessary information.
                # Back up.
                return False
            elif self.editing_partition:
                if "bad_size" in self.editing_partition:
                    return False
                size = self.editing_partition["size"]
                if re.search(r"^[0-9.]+$", size):
                    # ensure megabytes just in case partman's semantics change
                    size += "M"
                self.preseed(question, size, seen=False)
                return True
            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question == "partman-target/choose_method":
            if self.building_cache:
                state = self.__state[-1]
                assert state[0] == "partman/active_partition"
                partition = self.partition_cache[state[1]]
                partition["method_choices"] = []
                for (script, arg, option) in menu_options:
                    partition["method_choices"].append((script, arg, option))
                # Back up to the previous menu.
                return False
            elif self.creating_partition or self.editing_partition:
                if self.creating_partition:
                    request = self.creating_partition
                else:
                    request = self.editing_partition

                self.preseed_script(question, menu_options, None, request["method"])
                return True
            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question in ("partman-basicfilesystems/mountpoint", "partman-basicfilesystems/fat_mountpoint"):
            if self.building_cache:
                state = self.__state[-1]
                assert state[0] == "partman/active_partition"
                partition = self.partition_cache[state[1]]
                partition["mountpoint_choices"] = []
                choices_c = self.choices_untranslated(question)
                choices = self.choices(question)
                assert len(choices_c) == len(choices)
                for i in range(len(choices_c)):
                    if choices_c[i].startswith("/"):
                        partition["mountpoint_choices"].append((choices_c[i].split(" ")[0], choices_c[i], choices[i]))
                # Back up to the previous menu.
                return False
            elif self.creating_partition or self.editing_partition:
                if self.creating_partition:
                    request = self.creating_partition
                else:
                    request = self.editing_partition
                if "bad_mountpoint" in request:
                    return False
                mountpoint = request["mountpoint"]

                if mountpoint == "" or mountpoint is None:
                    self.preseed(question, "Do not mount it", seen=False)
                else:
                    self.preseed(question, "Enter manually", seen=False)
                return True
            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question == "partman-basicfilesystems/mountpoint_manual":
            if self.creating_partition or self.editing_partition:
                if self.creating_partition:
                    request = self.creating_partition
                else:
                    request = self.editing_partition
                if "bad_mountpoint" in request:
                    return False

                self.preseed(question, request["mountpoint"], seen=False)
                return True
            else:
                raise AssertionError, "Arrived at %s unexpectedly" % question

        elif question.startswith("partman/confirm"):
            if question == "partman/confirm":
                self.db.set("ubiquity/partman-made-changes", "true")
            else:
                self.db.set("ubiquity/partman-made-changes", "false")
            self.preseed(question, "true", seen=False)
            self.succeeded = True
            self.done = True
            return True

        elif question == "partman/exception_handler":
            if priority == "critical" or priority == "high":
                response = self.frontend.question_dialog(
                    self.description(question),
                    self.extended_description(question),
                    self.choices(question),
                    use_templates=False,
                )
                self.preseed(question, response, seen=False)
            else:
                self.preseed(question, "unhandled", seen=False)
            return True

        elif question == "partman/exception_handler_note":
            if priority == "critical" or priority == "high":
                self.frontend.error_dialog(self.description(question), self.extended_description(question))
                return FilteredCommand.error(self, priority, question)
            else:
                return True

        elif question == "partman/installation_medium_mounted":
            self.frontend.installation_medium_mounted(self.extended_description(question))
            return True

        elif self.question_type(question) == "boolean":
            if question == "partman/unmount_active":
                yes = "ubiquity/imported/yes"
                no = "ubiquity/imported/no"
            else:
                yes = "ubiquity/text/continue"
                no = "ubiquity/text/go_back"
            response = self.frontend.question_dialog(
                self.description(question), self.extended_description(question), (no, yes)
            )

            answer_reversed = False
            if question in ("partman-jfs/jfs_boot", "partman-jfs/jfs_root", "partman/unmount_active"):
                answer_reversed = True
            if response is None or response == yes:
                answer = answer_reversed
            else:
                answer = not answer_reversed
            if answer:
                self.preseed(question, "true", seen=False)
            else:
                self.preseed(question, "false", seen=False)
            return True

        return FilteredCommand.run(self, priority, question)