Beispiel #1
0
    def captureState(self):
        """Determines the state of the items on managed by this plugin"""
        #Parent functionality for state capturing
        MCCPlugin.clearParentState(self)
        #If this is a first run of capturing, we might need to fill
        #in our remote_count
        self.state = {}
        for item in ['lirc', 'mythbuntu-lirc-generator']:
            self.state[item] = self.query_installed(item)

        #TODO, detect smartphone type somehow.
        self.state['type'] = 'native'

        if self.state['lirc']:
            self.state['type'] = 'lirc'
            if self.count["remote"] is 0:
                self.lirc = LircHandler()
                self.populate_lirc()
            #Read in our /etc/lirc/hardware.conf
            self.lirc.read_hardware_conf()
Beispiel #2
0
    def __init__(self):
        """Initializes the Mythbuntu installer extra objects"""

        #Configure Parent cclass First so we can override things
        ParentInstall.__init__(self)

        self.lirc=LircHandler()
        self.vnc=VNCHandler()
        self.type = self.db.get('mythbuntu/install_type')

        #This forces install_langpacks to do Nothing
        self.langpacks={}
 def populate_lirc(self):
         """Fills the lirc pages with the appropriate data"""
         self.remote_count = 0
         self.transmitter_count = 0
         self.lirc=LircHandler()
         for item in self.lirc.get_possible_devices("remote"):
             self.remote_list.append_text(item)
             self.remote_count = self.remote_count + 1
         for item in self.lirc.get_possible_devices("transmitter"):
             self.transmitter_list.append_text(item)
             self.transmitter_count = self.transmitter_count + 1
         self.remote_list.set_active(0)
         self.transmitter_list.set_active(0)
Beispiel #4
0
 def root_scripted_changes(self, reconfigure):
     """System-wide changes that need root access to be applied.
        This function is ran by the dbus backend"""
     lirc = LircHandler()
     found = False
     for item in reconfigure:
         if item == "remote" or item == "transmitter":
             logging.debug("Setting item %s to %s." %
                           (item, reconfigure[item]))
             lirc.set_device({item: reconfigure[item]}, item)
             found = True
     if found:
         logging.debug("Writing out /etc/lirc/hardware.conf")
         lirc.write_hardware_conf()
         logging.debug("Reconfiguring LIRC package")
         lirc.reconfigure_lirc(interactive=False)
     return found
class Wizard(ubiquity.frontend.gtk_ui.Wizard):

#Overriden Methods
    def __init__(self, distro):
        del os.environ['UBIQUITY_MIGRATION_ASSISTANT']
        ubiquity.frontend.gtk_ui.Wizard.__init__(self,distro)

        self.populate_lirc()
        self.populate_video()
        self.backup=False

    def run(self):
        """run the interface."""
        def skip_pages(old_backup,old_name,new_name):
            """Skips a mythbuntu page if we should"""
            advanced=self.get_advanced()
            #advanced install conditionally skips a few pages
            if advanced:
                type = self.get_installtype()
                if (type == "Master Backend" or type == "Slave Backend") and \
                   (new_name == 'MythbuntuThemes' or new_name == 'MythbuntuRemote'):
                    if not old_backup:
                        self.dbfilter.ok_handler()
                    else:
                        self.dbfilter.cancel_handler()
                        self.backup=True
            #standard install should fly right through forward
            else:
                if new_name == 'MythbuntuInstallType' or \
                   new_name == 'MythbuntuPlugins' or \
                   new_name == 'MythbuntuThemes' or \
                   new_name == 'MythbuntuServices' or \
                   new_name == 'MythbuntuPasswords':
                    if not old_backup:
                        self.dbfilter.ok_handler()
                    else:
                        self.dbfilter.cancel_handler()
                        self.backup=True

        if os.getuid() != 0:
            title = ('This installer must be run with administrative '
                     'privileges, and cannot continue without them.')
            dialog = gtk.MessageDialog(self.live_installer, gtk.DIALOG_MODAL,
                                       gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE,
                                       title)
            dialog.run()
            sys.exit(1)

        self.disable_volume_manager()

        # show interface
        got_intro = self.show_intro()
        self.allow_change_step(True)

        # Declare SignalHandler
        self.glade.signal_autoconnect(self)

        # Some signals need to be connected by hand so that we have the
        # handler ids.
        self.username_changed_id = self.username.connect(
            'changed', self.on_username_changed)
        self.hostname_changed_id = self.hostname.connect(
            'changed', self.on_hostname_changed)

        # Start the interface
        if got_intro:
            global BREADCRUMB_STEPS, BREADCRUMB_MAX_STEP
            for step in BREADCRUMB_STEPS:
                BREADCRUMB_STEPS[step] += 1
            BREADCRUMB_STEPS["stepWelcome"] = 1
            BREADCRUMB_MAX_STEP += 1
            ubiquity.frontend.gtk_ui.BREADCRUMB_STEPS = BREADCRUMB_STEPS
            ubiquity.frontend.gtk_ui.BREADCRUMB_MAX_STEP = BREADCRUMB_MAX_STEP
            first_step = self.stepWelcome
        else:
            first_step = self.stepLanguage
        self.set_current_page(self.steps.page_num(first_step))
        if got_intro:
            # intro_label was the only focusable widget, but got can-focus
            # removed, so we end up with no input focus and thus pressing
            # Enter doesn't activate the default widget. Work around this.
            self.next.grab_focus()

        self.pages = [language.Language, timezone.Timezone,
            console_setup.ConsoleSetup, partman.Partman,
            usersetup.UserSetup, mythbuntu.MythbuntuAdvancedType,
            mythbuntu.MythbuntuInstallType, mythbuntu.MythbuntuPlugins,
            mythbuntu.MythbuntuThemes, mythbuntu.MythbuntuServices,
            mythbuntu.MythbuntuPasswords, mythbuntu.MythbuntuRemote,
            mythbuntu.MythbuntuDrivers, mythbuntu_summary.Summary]
        self.pagesindex = 0
        pageslen = len(self.pages)

        if got_intro:
            gtk.main()

        while(self.pagesindex < pageslen):
            if not self.installing:
                # Make sure any started progress bars are stopped.
                while self.progress_position.depth() != 0:
                    self.debconf_progress_stop()

            old_backup = self.backup
            self.backup = False
            old_dbfilter = self.dbfilter
            self.dbfilter = self.pages[self.pagesindex](self)

            # Non-debconf steps are no longer possible as the interface is now
            # driven by whether there is a question to ask.
            if self.dbfilter is not None and self.dbfilter != old_dbfilter:
                self.allow_change_step(False)
                self.dbfilter.start(auto_process=True)
                skip_pages(old_backup,old_dbfilter.__class__.__name__,self.dbfilter.__class__.__name__)
            gtk.main()

            if self.backup or self.dbfilter_handle_status():
                if self.installing:
                    self.progress_loop()
                elif self.current_page is not None and not self.backup:
                    self.process_step()
                    self.pagesindex = self.pagesindex + 1
                if self.backup:
                    if self.pagesindex > 0:
                        self.pagesindex = self.pagesindex - 1

            self.back.show()

            # TODO: Move this to after we're done processing GTK events, or is
            # that not worth the CPU time?
            if self.current_page == None:
                break

            while gtk.events_pending():
                gtk.main_iteration()

            # needed to be here for --automatic as there might not be any
            # current page in the event all of the questions have been
            # preseeded.
            if self.pagesindex == pageslen:
                # Ready to install
                self.live_installer.hide()
                self.current_page = None
                self.installing = True
                self.progress_loop()

        #After (and if) install is done, decide what to do
        if self.pagesindex == pageslen:
            self.run_success_cmd()
            if self.get_installtype() == "Frontend":
                if not self.get_reboot_seen():
                    self.finished_dialog.run()
                elif self.get_reboot():
                    self.reboot()
            else:
                self.live_installer.show()
                self.installing = False
                self.steps.next_page()
                self.back.hide()
                self.cancel.hide()
                self.next.set_label("Finish")
                gtk.main()
                self.live_installer.hide()
                self.finished_dialog.run()
        return self.returncode

    def process_step(self):
        """Process and validate the results of this step."""

        # setting actual step
        step_num = self.steps.get_current_page()
        step = self.step_name(step_num)

        #Figure out if this is a mythbuntu specific step
        if step == "mythbuntu_stepBackendSetup":
            syslog.syslog('Step_before = %s' % step)
            self.live_installer.hide()
            self.current_page = None
            self.finished_dialog.run()
        else:
            ubiquity.frontend.gtk_ui.Wizard.process_step(self)

    def progress_loop(self):
        """prepare, copy and config the system in the core install process."""

        syslog.syslog('progress_loop()')

        self.current_page = None

        self.debconf_progress_start(
            0, 100, self.get_string('ubiquity/install/title'))
        self.debconf_progress_region(0, 15)

        dbfilter = partman_commit.PartmanCommit(self)
        if dbfilter.run_command(auto_process=True) != 0:
            while self.progress_position.depth() != 0:
                self.debconf_progress_stop()
            self.debconf_progress_window.hide()
            self.return_to_partitioning()
            return

        # No return to partitioning from now on
        self.installing_no_return = True

        self.debconf_progress_region(15, 100)

        dbfilter = mythbuntu_install.Install(self)
        ret = dbfilter.run_command(auto_process=True)
        if ret != 0:
            self.installing = False
            if ret == 3:
                # error already handled by Install
                sys.exit(ret)
            elif (os.WIFSIGNALED(ret) and
                  os.WTERMSIG(ret) in (signal.SIGINT, signal.SIGKILL,
                                       signal.SIGTERM)):
                sys.exit(ret)
            elif os.path.exists('/var/lib/ubiquity/install.trace'):
                tbfile = open('/var/lib/ubiquity/install.trace')
                realtb = tbfile.read()
                tbfile.close()
                raise RuntimeError, ("Install failed with exit code %s\n%s" %
                                     (ret, realtb))
            else:
                raise RuntimeError, ("Install failed with exit code %s; see "
                                     "/var/log/syslog" % ret)

        while self.progress_position.depth() != 0:
            self.debconf_progress_stop()

        # just to make sure
        self.debconf_progress_window.hide()

        self.installing = False

    def set_page(self, n):
        self.run_automation_error_cmd()
        gtk_ui_pages  = ['Language', 'ConsoleSetup', 'Timezone', 'Partman', 'UserSetup', 'Summary', 'MigrationAssistant']
        found = False
        for item in gtk_ui_pages:
            if n == item:
                found = True
                ubiquity.frontend.gtk_ui.Wizard.set_page(self,n)
                break
        if not found:
            self.live_installer.show()
            if n == 'MythbuntuAdvancedType':
                self.set_current_page(self.steps.page_num(self.mythbuntu_stepInstallType))
            elif n == 'MythbuntuRemote':
                self.set_current_page(self.steps.page_num(self.tab_remote_control))
            elif n == 'MythbuntuDrivers':
                self.set_current_page(self.steps.page_num(self.mythbuntu_stepDrivers))
            if n == 'MythbuntuInstallType':
                self.set_current_page(self.steps.page_num(self.mythbuntu_stepCustomInstallType))
            elif n == 'MythbuntuPlugins':
                self.set_current_page(self.steps.page_num(self.mythbuntu_stepPlugins))
            elif n == 'MythbuntuThemes':
                self.set_current_page(self.steps.page_num(self.tab_themes))
            elif n == 'MythbuntuPasswords':
                self.set_current_page(self.steps.page_num(self.mythbuntu_stepPasswords))
                installtype=self.get_installtype()
                if installtype != "Master Backend/Frontend" and installtype != "Master Backend":
                    self.allow_go_forward(False)
            elif n == 'MythbuntuServices':
                self.set_current_page(self.steps.page_num(self.mythbuntu_stepServices))

#Added Methods
    def populate_lirc(self):
            """Fills the lirc pages with the appropriate data"""
            self.remote_count = 0
            self.transmitter_count = 0
            self.lirc=LircHandler()
            for item in self.lirc.get_possible_devices("remote"):
                self.remote_list.append_text(item)
                self.remote_count = self.remote_count + 1
            for item in self.lirc.get_possible_devices("transmitter"):
                self.transmitter_list.append_text(item)
                self.transmitter_count = self.transmitter_count + 1
            self.remote_list.set_active(0)
            self.transmitter_list.set_active(0)

    def populate_video(self):
        """Finds the currently active video driver"""
        #disable reading xorg.conf.  not really a good idea anymore
        #with how empty it is as of Hardy
        self.video_driver.append_text("Open Source Driver")
        self.video_driver.set_active(5)
        self.tvoutstandard.set_active(0)
        self.tvouttype.set_active(0)

        #vid = open('/etc/X11/xorg.conf')
        #start_filter = re.compile("Section \"Device\"")
        #driver_filter = re.compile("Driver")
        #section=False
        #for line in vid:
        #   if not section and start_filter.search(line):
        #        section=True
        #    elif section and driver_filter.search(line):
        #        list = string.split(line, '"')
        #        if len(list) > 1:
        #            self.video_driver.append_text("Open Source Driver: " + list[1])
        #            self.video_driver.set_active(5)
        #            self.tvoutstandard.set_active(0)
        #            self.tvouttype.set_active(0)
        #            break
        #        else:
        #            section = False
        #if not section:
        #    self.video_driver.append_text("Open Source Driver")
        #    self.video_driver.set_active(5)
        #    self.tvoutstandard.set_active(0)
        #    self.tvouttype.set_active(0)
        #vid.close()

    def allow_go_backward(self, allowed):
        self.back.set_sensitive(allowed and self.allowed_change_step)
        self.allowed_go_backward = allowed

    def mythbuntu_password(self,widget):
        """Checks that certain passwords meet requirements"""
        #For the services page, the only password we have is the VNC
        if (widget is not None and widget.get_name() == 'vnc_password'):
            password= widget.get_text().split(' ')[0]
            if len(password) >= 6:
                self.allow_go_forward(True)
                self.allow_go_backward(True)
                self.vnc_error_image.hide()
            else:
                self.allow_go_forward(False)
                self.allow_go_backward(False)
                self.vnc_error_image.show()
        elif (widget is not None and widget.get_name() == 'mythweb_username'):
            username = widget.get_text().split(' ')[0]
            if len(username) >= 1:
                self.mythweb_user_error_image.hide()
            else:
                self.mythweb_user_error_image.show()
        elif (widget is not None and widget.get_name() == 'mythweb_password'):
            password = widget.get_text().split(' ')[0]
            if len(password) >= 1:
                self.mythweb_pass_error_image.hide()
            else:
                self.mythweb_pass_error_image.show()

        elif (widget is not None and widget.get_name() == 'mysql_root_password'):
            password = widget.get_text().split(' ')[0]
            if len(password) >= 1:
                self.mysql_root_error_image.hide()
            else:
                self.mysql_root_error_image.show()

        #The password check page is much more complex. Pieces have to be
        #done in a sequential order
        if (self.usemysqlrootpassword.get_active() or self.usemythwebpassword.get_active()):
            mysql_root_flag = self.mysql_root_error_image.flags() & gtk.VISIBLE
            mythweb_user_flag = self.mythweb_user_error_image.flags() & gtk.VISIBLE
            mythweb_pass_flag = self.mythweb_pass_error_image.flags() & gtk.VISIBLE
            result = not (mythweb_user_flag | mythweb_pass_flag | mysql_root_flag)
            self.allow_go_forward(result)
            self.allow_go_backward(result)

    def do_mythtv_setup(self,widget):
        """Spawn MythTV-Setup binary."""
        os.seteuid(0)
        execute("/usr/share/ubiquity/mythbuntu-setup")
        drop_privileges()

    def do_connection_test(self,widget):
        """Tests to make sure that the backend is accessible"""
        host = self.mysql_server.get_text()
        database = self.mysql_database.get_text()
        user = self.mysql_user.get_text()
        password = self.mysql_password.get_text()
        try:
            db = MySQLdb.connect(host=host, user=user, passwd=password,db=database)
            cursor = db.cursor()
            cursor.execute("SELECT NULL")
            result = cursor.fetchone()
            cursor.close()
            db.close()
            result = "Successful"
            self.allow_go_forward(True)
        except:
            result = "Failure"
            self.allow_go_forward(False)
        self.connection_results_label.show()
        self.connection_results.set_text(result)

    def toggle_installtype (self,widget):
        """Called whenever standard or full are toggled"""
        if self.standardinstall.get_active() :
            #Make sure that we have everything turned on in case they came back to this page
            #and changed their mind
            #Note: This will recursively handle changing the values on the pages
            self.master_be_fe.set_active(True)
            self.enablessh.set_active(True)
            self.enablevnc.set_active(False)
            self.enablenfs.set_active(False)
            self.enablesamba.set_active(True)
            self.enablemysql.set_active(False)

        else:
            self.theme_mythbuntu.set_sensitive(False)
            self.master_backend_expander.hide()
            self.mythweb_expander.show()
            self.mysql_server_expander.show()

    def toggle_customtype (self,widget):
        """Called whenever a custom type is toggled"""

        def set_fe_drivers(self,enable):
            """Toggle Visible Frontend Applicable Drivers"""
            if enable:
                self.frontend_driver_list.show()
            else:
                self.frontend_driver_list.hide()

        def set_be_drivers(self,enable):
            """Toggles Visible Backend Applicable Drivers"""
            if enable:
                self.backend_driver_list.show()
                self.tuner0.set_active(0)
                self.tuner1.set_active(0)
                self.tuner2.set_active(0)
                self.tuner3.set_active(0)
                self.tuner4.set_active(0)
            else:
                self.backend_driver_list.hide()

        def set_all_services(self,enable):
            """Toggles visibility on all possible services"""
            if enable:
                self.ssh_option_hbox.show()
                self.samba_option_hbox.show()
                self.nfs_option_hbox.show()
                self.mysql_option_hbox.show()
            else:
                self.ssh_option_hbox.hide()
                self.samba_option_hbox.hide()
                self.nfs_option_hbox.hide()
                self.mysql_option_hbox.hide()

        def set_all_passwords(self,enable):
            """Toggles visibility on all password selection boxes"""
            if enable:
                self.master_backend_expander.show()
                self.mythweb_expander.show()
                self.mysql_server_expander.show()
            else:
                self.master_backend_expander.hide()
                self.mythweb_expander.hide()
                self.mysql_server_expander.hide()

        def set_all_themes(self,enable):
            """Enables all themes for defaults"""
            self.communitythemes.set_active(enable)
            self.officialthemes.set_active(enable)

        def set_all_fe_plugins(self,enable):
            """ Enables all frontend plugins for defaults"""
            self.mytharchive.set_active(enable)
            self.mythbrowser.set_active(enable)
            self.mythcontrols.set_active(enable)
            self.mythflix.set_active(enable)
            self.mythgallery.set_active(enable)
            self.mythgame.set_active(enable)
            self.mythmovies.set_active(enable)
            self.mythmusic.set_active(enable)
            self.mythnews.set_active(enable)
            self.mythphone.set_active(enable)
            self.mythstream.set_active(enable)
            self.mythvideo.set_active(enable)
            self.mythweather.set_active(enable)

        def set_all_be_plugins(self,enable):
            """ Enables all backend plugins for defaults"""
            self.mythweb.set_active(enable)

        if self.master_be_fe.get_active():
            set_all_themes(self,True)
            set_all_fe_plugins(self,True)
            set_all_be_plugins(self,True)
            set_all_passwords(self,True)
            set_all_services(self,True)
            self.enablessh.set_active(True)
            self.enablesamba.set_active(True)
            self.frontend_plugin_list.show()
            self.backend_plugin_list.show()
            self.febe_heading_label.set_label("Choose Frontend / Backend Plugins")
            self.master_backend_expander.hide()
            set_fe_drivers(self,True)
            set_be_drivers(self,True)
        elif self.slave_be_fe.get_active():
            set_all_themes(self,True)
            set_all_fe_plugins(self,True)
            set_all_be_plugins(self,True)
            set_all_services(self,True)
            set_all_passwords(self,True)
            self.enablessh.set_active(True)
            self.enablesamba.set_active(True)
            self.frontend_plugin_list.show()
            self.backend_plugin_list.show()
            self.febe_heading_label.set_label("Choose Frontend / Backend Plugins")
            self.mysql_server_expander.hide()
            self.mysql_option_hbox.hide()
            set_fe_drivers(self,True)
            set_be_drivers(self,True)
        elif self.master_be.get_active():
            set_all_themes(self,False)
            set_all_fe_plugins(self,False)
            set_all_be_plugins(self,True)
            set_all_services(self,True)
            set_all_passwords(self,True)
            self.enablessh.set_active(True)
            self.enablesamba.set_active(True)
            self.frontend_plugin_list.hide()
            self.backend_plugin_list.show()
            self.febe_heading_label.set_label("Choose Backend Plugins")
            self.master_backend_expander.hide()
            set_fe_drivers(self,False)
            set_be_drivers(self,True)
        elif self.slave_be.get_active():
            set_all_themes(self,False)
            set_all_fe_plugins(self,False)
            set_all_be_plugins(self,True)
            set_all_services(self,True)
            set_all_passwords(self,True)
            self.enablessh.set_active(True)
            self.enablesamba.set_active(True)
            self.frontend_plugin_list.hide()
            self.backend_plugin_list.show()
            self.febe_heading_label.set_label("Choose Backend Plugins")
            self.mysql_server_expander.hide()
            self.mysql_option_hbox.hide()
            set_fe_drivers(self,False)
            set_be_drivers(self,True)
        else:
            set_all_themes(self,True)
            set_all_fe_plugins(self,True)
            set_all_be_plugins(self,False)
            set_all_services(self,True)
            set_all_passwords(self,True)
            self.enablessh.set_active(True)
            self.enablesamba.set_active(False)
            self.enablenfs.set_active(False)
            self.enablemysql.set_active(False)
            self.frontend_plugin_list.show()
            self.backend_plugin_list.hide()
            self.febe_heading_label.set_label("Choose Frontend Plugins")
            self.mythweb_expander.hide()
            self.mysql_server_expander.hide()
            self.mysql_option_hbox.hide()
            self.nfs_option_hbox.hide()
            self.samba_option_hbox.hide()
            set_fe_drivers(self,True)
            set_be_drivers(self,False)

    def toggle_ir(self,widget):
        """Called whenever a request to enable/disable remote is called"""
        if widget is not None:
            #turn on/off IR remote
            if widget.get_name() == 'remotecontrol':
                self.remote_hbox.set_sensitive(widget.get_active())
                self.generate_lircrc_checkbox.set_sensitive(widget.get_active())
                if widget.get_active() and self.remote_list.get_active() == 0:
                        self.remote_list.set_active(1)
                else:
                    self.remote_list.set_active(0)
            #turn on/off IR transmitter
            elif widget.get_name() == "transmittercontrol":
                self.transmitter_hbox.set_sensitive(widget.get_active())
                if widget.get_active():
                    if self.transmitter_list.get_active() == 0:
                        self.transmitter_list.set_active(1)
                else:
                    self.transmitter_list.set_active(0)
            #if our selected remote itself changed
            elif widget.get_name() == 'remote_list':
                self.generate_lircrc_checkbox.set_active(True)
                if self.remote_list.get_active() == 0:
                    custom = False
                    self.remotecontrol.set_active(False)
                    self.generate_lircrc_checkbox.set_active(False)
                elif self.remote_list.get_active_text() == "Custom":
                    custom = True
                else:
                    custom = False
                    self.remote_driver.set_text("")
                    self.remote_modules.set_text("")
                    self.remote_device.set_text("")
                self.remote_driver_hbox.set_sensitive(custom)
                self.remote_modules_hbox.set_sensitive(custom)
                self.remote_device_hbox.set_sensitive(custom)
                self.remote_configuration_hbox.set_sensitive(custom)
                self.browse_remote_lircd_conf.set_filename("/usr/share/lirc/remotes")
            #if our selected transmitter itself changed
            elif widget.get_name() == 'transmitter_list':
                if self.transmitter_list.get_active() == 0:
                    custom = False
                    self.transmittercontrol.set_active(False)
                elif self.transmitter_list.get_active_text() == "Custom":
                    custom = True
                else:
                    custom = False
                    self.transmitter_driver.set_text("")
                    self.transmitter_modules.set_text("")
                    self.transmitter_device.set_text("")
                self.transmitter_driver_hbox.set_sensitive(custom)
                self.transmitter_modules_hbox.set_sensitive(custom)
                self.transmitter_device_hbox.set_sensitive(custom)
                self.transmitter_configuration_hbox.set_sensitive(custom)
                self.browse_transmitter_lircd_conf.set_filename("/usr/share/lirc/transmitters")

    def mythweb_toggled(self,widget):
        """Called when the checkbox to install Mythweb is toggled"""
        if (self.mythweb.get_active()):
            self.mythweb_expander.show()
        else:
            self.mythweb_expander.hide()

    def enablevnc_toggled(self,widget):
        """Called when the checkbox to turn on VNC is toggled"""
        if (self.enablevnc.get_active()):
            self.vnc_pass_hbox.set_sensitive(True)
            self.allow_go_forward(False)
            self.allow_go_backward(False)
            self.vnc_error_image.show()
        else:
            self.vnc_pass_hbox.set_sensitive(False)
            self.vnc_password.set_text("")
            self.allow_go_forward(True)
            self.allow_go_backward(True)
            self.vnc_error_image.hide()

    def uselivemysqlinfo_toggled(self,widget):
        """Called when the checkbox to copy live mysql information is pressed"""
        if (self.uselivemysqlinfo.get_active()):
            #disable modifying
            self.master_backend_table.set_sensitive(False)
            #read in mysql.txt to set the new defaults
            try:
                in_f=open("/etc/mythtv/mysql.txt")
                for line in in_f:
                    if re.compile("^DBHostName").search(line):
                        text=string.split(string.split(line,"=")[1],'\n')[0]
                        self.old_mysql_server=self.mysql_server.get_text()
                        self.mysql_server.set_text(text)
                    elif re.compile("^DBUserName").search(line):
                        text=string.split(string.split(line,"=")[1],'\n')[0]
                        self.old_mysql_user=self.mysql_user.get_text()
                        self.mysql_user.set_text(text)
                    elif re.compile("^DBName").search(line):
                        text=string.split(string.split(line,"=")[1],'\n')[0]
                        self.old_mysql_database=self.mysql_database.get_text()
                        self.mysql_database.set_text(text)
                    elif re.compile("^DBPassword").search(line):
                        text=string.split(string.split(line,"=")[1],'\n')[0]
                        self.old_mysql_password=self.mysql_password.get_text()
                        self.mysql_password.set_text(text)
                in_f.close()
            except IOError:
                #in case for some reason we are missing mysql.txt
                self.usemysqlinfo.set_active(False)
        else:
            self.allow_go_forward(False)
            self.connection_results_label.hide()
            self.connection_results.set_text("Please Test your connection to proceed")
            self.master_backend_table.set_sensitive(True)
            self.mysql_server.set_text(self.old_mysql_server)
            self.mysql_user.set_text(self.old_mysql_user)
            self.mysql_password.set_text(self.old_mysql_password)
            self.mysql_database.set_text(self.old_mysql_database)

    def usemythwebpassword_toggled(self,widget):
        """Called when the checkbox to set a mythweb password is pressed"""
        if (self.usemythwebpassword.get_active()):
            self.mythweb_table.show()
            self.allow_go_forward(False)
            self.allow_go_backward(False)
            self.mythweb_user_error_image.show()
            self.mythweb_pass_error_image.show()
        else:
            self.mythweb_table.hide()
            self.mythweb_password.set_text("")
            self.mythweb_username.set_text("")
            self.mythweb_user_error_image.hide()
            self.mythweb_pass_error_image.hide()
            if (not self.usemysqlrootpassword.get_active() or not self.mysql_root_error_image.flags() & gtk.VISIBLE):
                self.allow_go_forward(True)
                self.allow_go_backward(True)

    def usemysqlrootpassword_toggled(self,widget):
        """Called when the checkbox to set a MySQL root password is pressed"""
        if (self.usemysqlrootpassword.get_active()):
            self.mysql_server_hbox.show()
            self.allow_go_forward(False)
            self.allow_go_backward(False)
            self.mysql_root_error_image.show()
        else:
            self.mysql_server_hbox.hide()
            self.mysql_root_password.set_text("")
            self.mysql_root_error_image.hide()
            if (not self.usemythwebpassword.get_active() or ((not self.mythweb_pass_error_image.flags() & gtk.VISIBLE) and (not self.mythweb_user_error_image.flags() & gtk.VISIBLE))):
                self.allow_go_forward(True)
                self.allow_go_backward(True)

    def toggle_number_tuners (self,widget):
        """Called whenever a number of tuners is changed"""
        num = self.number_tuners.get_value()
        if num > 0:
            if num > 1:
                if num > 2:
                    if num > 3:
                        if num > 4:
                            self.tuner0.show()
                            self.tuner1.show()
                            self.tuner2.show()
                            self.tuner3.show()
                            self.tuner4.show()
                        else:
                            self.tuner0.show()
                            self.tuner1.show()
                            self.tuner2.show()
                            self.tuner3.show()
                            self.tuner4.hide()
                            self.tuner4.set_active(0)
                    else:
                        self.tuner0.show()
                        self.tuner1.show()
                        self.tuner2.show()
                        self.tuner3.hide()
                        self.tuner3.set_active(0)
                        self.tuner4.hide()
                        self.tuner4.set_active(0)
                else:
                    self.tuner0.show()
                    self.tuner1.show()
                    self.tuner2.hide()
                    self.tuner2.set_active(0)
                    self.tuner3.hide()
                    self.tuner3.set_active(0)
                    self.tuner4.hide()
                    self.tuner4.set_active(0)
            else:
                self.tuner0.show()
                self.tuner1.hide()
                self.tuner1.set_active(0)
                self.tuner2.hide()
                self.tuner2.set_active(0)
                self.tuner3.hide()
                self.tuner3.set_active(0)
                self.tuner4.hide()
                self.tuner4.set_active(0)
        else:
            self.tuner0.hide()
            self.tuner0.set_active(0)
            self.tuner1.hide()
            self.tuner1.set_active(0)
            self.tuner2.hide()
            self.tuner2.set_active(0)
            self.tuner3.hide()
            self.tuner3.set_active(0)
            self.tuner4.hide()
            self.tuner4.set_active(0)

    def toggle_tuners (self,widget):
        """Checks to make sure no tuner widgets have same value"""
        def return_tuner_val(self,num):
            if num == 0:
                return self.tuner0.get_active()
            elif num == 1:
                return self.tuner1.get_active()
            elif num == 2:
                return self.tuner2.get_active()
            elif num == 3:
                return self.tuner3.get_active()
            elif num == 4:
                return self.tuner4.get_active()

        number_tuners = self.number_tuners.get_value_as_int()
        enable_warning=False
        for i in range(number_tuners):
            #Check for the unknown Analogue or Digital Option
            if (return_tuner_val(self,i) == 19 or return_tuner_val(self,i) == 20):
                enable_warning=True
        if enable_warning == True:
            self.tunernotice.show()
        else:
            self.tunernotice.hide()

    def video_changed (self,widget):
        """Called whenever the modify video driver option is toggled or its kids"""
        if (widget is not None and widget.get_name() == 'modifyvideodriver'):
            if (widget.get_active()):
                self.videodrivers_hbox.set_sensitive(True)
            else:
                self.tvout_vbox.set_sensitive(False)
                self.videodrivers_hbox.set_sensitive(False)
                self.video_driver.set_active(5)
                self.tvoutstandard.set_active(0)
                self.tvouttype.set_active(0)
        elif (widget is not None and widget.get_name() == 'video_driver'):
            type = widget.get_active()
            if (type == 0 or type == 1 or type == 2 or type == 3 or type == 4):
                self.tvout_vbox.set_sensitive(True)
            else:
                self.tvout_vbox.set_sensitive(False)
                self.tvoutstandard.set_active(0)
                self.tvouttype.set_active(0)

    def toggle_tv_out (self,widget):
        """Called when the tv-out type is toggled"""
        if (self.tvouttype.get_active() == 0):
            self.tvoutstandard.set_active(0)
        elif ((self.tvouttype.get_active() == 1 or self.tvouttype.get_active() == 2) and (self.tvoutstandard.get_active() == 0 or self.tvoutstandard.get_active() >= 11 )):
            self.tvoutstandard.set_active(10)
        elif self.tvouttype.get_active() == 3:
            self.tvoutstandard.set_active(11)

    def toggle_tv_standard(self,widget):
        """Called when the tv standard is toggled"""
        if (self.tvoutstandard.get_active() >= 11):
            self.tvouttype.set_active(3)
        elif (self.tvoutstandard.get_active() < 11 and self.tvoutstandard.get_active() > 0 and self.tvouttype.get_active() == 0):
            self.tvouttype.set_active(1)
        elif (self.tvoutstandard.get_active() < 11 and self.tvouttype.get_active() ==3):
            self.tvouttype.set_active(1)
        elif (self.tvoutstandard.get_active() == 0):
            self.tvouttype.set_active(0)

    def get_advanced(self):
        """Returns if this is an advanced install"""
        return self.custominstall.get_active()

    def get_installtype(self):
        """Returns the current custom installation type"""
        if self.master_be_fe.get_active():
                return "Master Backend/Frontend"
        elif self.slave_be_fe.get_active():
                return "Slave Backend/Frontend"
        elif self.master_be.get_active():
                return "Master Backend"
        elif self.slave_be.get_active():
                return "Slave Backend"
        elif self.fe.get_active():
                return "Frontend"

    def get_mytharchive(self):
        """Returns the status of the mytharchive plugin"""
        if self.mytharchive.get_active():
            return True
        else:
            return False

    def get_mythbrowser(self):
        """Returns the status of the mythbrowser plugin"""
        if self.mythbrowser.get_active():
            return True
        else:
            return False

    def get_mythcontrols(self):
        """Returns the status of the mythcontrols plugin"""
        if self.mythcontrols.get_active():
            return True
        else:
            return False

    def get_mythmovies(self):
        """Returns the status of the mythmovies plugin"""
        if self.mythmovies.get_active():
            return True
        else:
            return False

    def get_mythflix(self):
        """Returns the status of the mythflix plugin"""
        if self.mythflix.get_active():
            return True
        else:
            return False

    def get_mythgallery(self):
        """Returns the status of the mythgallery plugin"""
        if self.mythgallery.get_active():
            return True
        else:
            return False

    def get_mythgame(self):
        """Returns the status of the mythgame plugin"""
        if self.mythgame.get_active():
            return True
        else:
            return False

    def get_mythmusic(self):
        """Returns the status of the mythmusic plugin"""
        if self.mythmusic.get_active():
            return True
        else:
            return False

    def get_mythnews(self):
        """Returns the status of the mythnews plugin"""
        if self.mythnews.get_active():
            return True
        else:
            return False

    def get_mythphone(self):
        """Returns the status of the mythphone plugin"""
        if self.mythphone.get_active():
            return True
        else:
            return False

    def get_mythstream(self):
        """Returns the status of the mythstream plugin"""
        if self.mythstream.get_active():
            return True
        else:
            return False

    def get_mythvideo(self):
        """Returns the status of the mythvideo plugin"""
        if self.mythvideo.get_active():
            return True
        else:
            return False

    def get_mythweather(self):
        """Returns the status of the mythweather plugin"""
        if self.mythweather.get_active():
            return True
        else:
            return False

    def get_mythweb(self):
        """Returns the status of the mythweb plugin"""
        if self.mythweb.get_active():
            return True
        else:
            return False

    def get_officialthemes(self):
        """Returns the status of the official themes"""
        return get_official_theme_dictionary(self)

    def get_communitythemes(self):
        """Returns the status of the community themes"""
        return get_community_theme_dictionary(self)
    def get_video(self):
        """Returns the status of the video graphics drivers"""
        if (self.modifyvideodriver.get_active()):
            driver = self.video_driver.get_active()
            if driver == 0:
                return "fglrx"
            elif driver == 1:
                return "nvidia_legacy"
            elif driver == 2:
                return "nvidia"
            elif driver == 3:
                return "nvidia_new"
            elif driver == 4:
                return "pvr_350"
            else:
                return "None"
        else:
            return "None"

    def get_tvout(self):
        """Returns the status of the TV Out type"""
        if (self.modifyvideodriver.get_active()):
            return self.tvouttype.get_active_text()
        else:
            return "Disable TV-Out"

    def get_tvstandard(self):
        """Returns the status of the TV Standard type"""
        if (self.modifyvideodriver.get_active()):
            return self.tvoutstandard.get_active_text()
        else:
            return "Disable TV-Out"

    def get_uselivemysqlinfo(self):
        if (self.uselivemysqlinfo.get_active()):
            return True
        else:
            return False

    def get_mysqluser(self):
        return self.mysql_user.get_text()

    def get_mysqlpass(self):
        return self.mysql_password.get_text()

    def get_mysqldatabase(self):
        return self.mysql_database.get_text()

    def get_mysqlserver(self):
        return self.mysql_server.get_text()

    def get_secure_mysql(self):
        if self.usemysqlrootpassword.get_active():
            return True
        else:
            return False

    def get_mysql_root_password(self):
        return self.mysql_root_password.get_text()

    def get_secure_mythweb(self):
        if self.usemythwebpassword.get_active():
            return True
        else:
            return False

    def get_mythweb_username(self):
        return self.mythweb_username.get_text()

    def get_mythweb_password(self):
        return self.mythweb_password.get_text()

    def get_vnc(self):
        if self.enablevnc.get_active():
            return True
        else:
            return False

    def get_vnc_password(self):
        return self.vnc_password.get_text()

    def get_ssh(self):
        if self.enablessh.get_active():
            return True
        else:
            return False

    def get_samba(self):
        if self.enablesamba.get_active():
            return True
        else:
            return False

    def get_nfs(self):
        if self.enablenfs.get_active():
            return True
        else:
            return False

    def get_mysql_port(self):
        if self.enablemysql.get_active():
            return True
        else:
            return False

    def get_lirc(self,type):
        item = {"modules":"","device":"","driver":"","lircd_conf":""}
        if type == "remote":
            item["remote"]=self.remote_list.get_active_text()
            if item["remote"] == "Custom":
                item["modules"]=self.remote_modules.get_text()
                item["device"]=self.remote_device.get_text()
                item["driver"]=self.remote_driver.get_text()
                item["lircd_conf"]=self.browse_remote_lircd_conf.get_filename()
        elif type == "transmitter":
            item["transmitter"]=self.transmitter_list.get_active_text()
            if item["transmitter"] == "Custom":
                item["modules"]=self.transmitter_modules.get_text()
                item["device"]=self.transmitter_device.get_text()
                item["driver"]=self.transmitter_driver.get_text()
                item["lircd_conf"]=self.browse_transmitter_lircd_conf.get_filename()
        return item

    def get_hdhomerun(self):
        return self.hdhomerun.get_active()

    def get_xmltv(self):
        return self.xmltv.get_active()

    def get_dvbutils(self):
        return self.dvbutils.get_active()

    def toggle_meta(self,widget):
        """Called whenever a request to enable / disable all plugins"""
        if widget is not None:
            list = []
            name = widget.get_name()
            if (name == 'officialthemes'):
                list = get_official_theme_dictionary(self)
            elif (name == 'communitythemes'):
                list = get_community_theme_dictionary(self)

            toggle = widget.get_active()
            for item in list:
                if list[item].flags() & gtk.SENSITIVE:
                    list[item].set_active(toggle)
Beispiel #6
0
class Install(ParentInstall):

    def __init__(self):
        """Initializes the Mythbuntu installer extra objects"""

        #Configure Parent cclass First so we can override things
        ParentInstall.__init__(self)

        self.lirc=LircHandler()
        self.vnc=VNCHandler()
        self.type = self.db.get('mythbuntu/install_type')

        #This forces install_langpacks to do Nothing
        self.langpacks={}

    def configure_user(self):
        """Configures by the regular user configuration stuff
        followed by mythbuntu specific user addons"""

        #Before beginning, set the initial root sql pass to the user pass
        self.passwd=self.db.get('passwd/user-password')
        self.set_debconf('mythtv/mysql_admin_password',self.passwd)
        self.set_debconf('mysql-server/root_password',self.passwd)
        self.set_debconf('mysql-server/root_password_again',self.passwd)

        #Regular ubuntu user configuration
        ParentInstall.configure_user(self)

        #We'll be needing the username, uid, gid
        self.user = self.db.get('passwd/username')
        self.uid = self.gid = ''
        try:
            self.uid = self.db.get('passwd/user-uid')
        except debconf.DebconfError:
            pass
        try:
            self.gid = self.db.get('passwd/user-gid')
        except debconf.DebconfError:
            pass
        if self.uid == '':
            self.uid = 1000
        else:
            self.uid = int(self.uid)
        if self.gid == '':
            self.gid = 1000
        else:
            self.gid = int(self.gid)

        #Create a .mythtv directory
        home_mythtv_dir = self.target + '/home/' + self.user + '/.mythtv'
        if not os.path.isdir(home_mythtv_dir):
            #in case someone made a symlink or file for the directory
            if os.path.islink(home_mythtv_dir) or os.path.exists(home_mythtv_dir):
                os.remove(home_mythtv_dir)
            os.mkdir(home_mythtv_dir)
            os.chown(home_mythtv_dir,self.uid,self.gid)

        #Remove mysql.txt from home directory if it's there, then make one
        sql_txt= home_mythtv_dir + '/mysql.txt'
        if os.path.islink(sql_txt) or os.path.exists(sql_txt):
            os.remove(sql_txt)
        try:
            os.symlink('/etc/mythtv/mysql.txt',sql_txt)
        except OSError:
            #on a live disk there is a chance this was a broken link
            #depending on what the user did in the livefs
            pass

        #mythtv.desktop autostart
        if 'Frontend' in self.type:
            config_dir = self.target + '/home/' + self.user + '/.config'
            autostart_dir =  config_dir + '/autostart'
            autostart_link = autostart_dir + '/mythtv.desktop'
            if not os.path.isdir(config_dir):
                os.makedirs(config_dir)
                os.chown(config_dir,self.uid,self.gid)
            if not os.path.isdir(autostart_dir):
                os.makedirs(autostart_dir)
                os.chown(autostart_dir,self.uid,self.gid)
            elif os.path.islink(autostart_link) or os.path.exists(autostart_link):
                os.remove(autostart_link)
            try:
                os.symlink('/usr/share/applications/mythtv.desktop',autostart_link)
            except OSError:
                #on a live disk, this will appear a broken link, but it works
                pass

        #group membership
        self.chrex('adduser', self.user, 'mythtv')
        self.chrex('adduser', self.user, 'video')

    def configure_ma(self):
        """Overrides module assistant configuration method.  Mythbuntu doesn't
           use module assistant, but we can instead run MySQL and mythweb config
           here"""
        self.db.progress('INFO', 'ubiquity/install/mythbuntu')

        #Copy a few debconf questions that were answered in the installer
        for question in ('mythtv/mysql_mythtv_user','mythtv/mysql_mythtv_password',\
                         'mythtv/mysql_mythtv_dbname','mythtv/mysql_host'):
            answer=self.db.get(question)
            self.set_debconf(question,answer)

        #Setup mysql.txt nicely
        os.remove(self.target + '/etc/mythtv/mysql.txt')
        self.reconfigure('mythtv-common')

        #only reconfigure database if appropriate
        if 'Master' in self.type:
            #Prepare
            self.chrex('mount', '-t', 'proc', 'proc', '/proc')

            #Setup database
            self.reconfigure('mysql-server-5.0')
            self.reconfigure('mythtv-database')

            #Cleanup
            self.chrex('invoke-rc.d','mysql','stop')
            self.chrex('umount', '/proc')

            #Mythweb
            self.set_debconf('mythweb/enable', 'true')
            self.set_debconf('mythweb/username', self.user)
            self.set_debconf('mythweb/password', self.passwd)
            self.reconfigure('mythweb')

    def install_extras(self):
        """Overrides main install_extras function to add in Mythbuntu
           drivers and services, and then call the parent function"""
        video_driver = self.db.get('mythbuntu/video_driver')
        vnc = self.db.get('mythbuntu/x11vnc')
        nfs = self.db.get('mythbuntu/nfs-kernel-server')
        to_install = []
        to_remove = set()
        if video_driver != "Open Source Driver":
            to_install.append(video_driver)
        if vnc == 'true':
            to_install.append('x11vnc')
        if nfs == 'true':
            to_install.append('nfs-kernel-server')
            to_install.append('portmap')

        #Remove any conflicts before installing new items
        if to_remove != []:
            self.do_remove(to_remove)
        #Mark new items
        self.record_installed(to_install)

        #Actually install extras
        ParentInstall.install_extras(self)

        #Run depmod if we might be using a DKMS enabled driver
        if video_driver != "Open Source Driver":
            self.chrex('/sbin/depmod','-a')

    def configure_hardware(self):
        """Overrides parent function to add in hooks for configuring
           drivers and services"""

        #Drivers
        self.db.progress('INFO', 'ubiquity/install/drivers')
        video_driver = self.db.get('mythbuntu/video_driver')
        out = self.db.get('mythbuntu/tvout')
        standard = self.db.get('mythbuntu/tvstandard')
        if 'nvidia' in video_driver:
            self.enable_nvidia(out,standard)
        elif 'fglrx' in video_driver:
            self.enable_amd(out,standard)

        #Services
        self.db.progress('INFO', 'ubiquity/install/services')
        if self.db.get('mythbuntu/samba') == 'true':
            shutil.copy('/usr/share/mythbuntu-common/examples/smb.conf.dist',self.target + '/etc/samba/smb.conf')
        if self.db.get('mythbuntu/nfs-kernel-server') == 'true':
            shutil.copy('/usr/share/mythbuntu-common/examples/exports.dist',self.target + '/etc/exports')
        if self.db.get('mythbuntu/openssh-server') == 'true':
            for file in ['ssh_host_dsa_key','ssh_host_dsa_key.pub','ssh_host_rsa_key','ssh_host_rsa_key.pub']:
                os.remove(self.target + '/etc/ssh/' + file)
            self.reconfigure('openssh-server')
        if self.db.get('mythbuntu/mysql-server') == 'true':
            f=open(self.target + '/etc/mysql/conf.d/mythtv.cnf','w')
            print >>f, """\
[mysqld]
bind-address=0.0.0.0"""
            f.close()
        if self.db.get('mythbuntu/x11vnc') == 'true':
            self.vnc.create_password(self.passwd)
            directory = self.target + '/home/' + self.user + '/.vnc'
            if not os.path.exists(directory):
                os.mkdir(directory)
            shutil.move('/root/.vnc/passwd', directory + '/passwd')
            os.system('chown ' + str(self.uid) + ':' + str(self.gid) + ' -R ' + directory)

        #Remotes & Transmitters
        self.db.progress('INFO', 'ubiquity/install/ir')
        self.configure_ir()

        #Regular parent hardware configure f/n
        self.db.progress('INFO', 'ubiquity/install/hardware')
        ParentInstall.configure_hardware(self)

    def configure_ir(self):
        """Configures the remote & transmitter per user choices"""
        #configure lircd for remote and transmitter
        ir_device={"modules":"","driver":"","device":"","lircd_conf":"","remote":"","transmitter":""}
        self.chroot_setup()
        self.chrex('dpkg-divert', '--package', 'ubiquity', '--rename',
                   '--quiet', '--add', '/sbin/udevd')
        try:
            os.symlink('/bin/true', '/target/sbin/udevd')
        except OSError:
            pass

        try:
            ir_device["remote"] = self.db.get('lirc/remote')
            self.set_debconf('lirc/remote',ir_device["remote"])
            ir_device["modules"] = ""
            ir_device["driver"] = ""
            ir_device["device"] = ""
            ir_device["lircd_conf"] = ""
            self.lirc.set_device(ir_device,"remote")
        except debconf.DebconfError:
            pass

        try:
            ir_device["transmitter"] = self.db.get('lirc/transmitter')
            self.set_debconf('lirc/transmitter',ir_device["transmitter"])
            ir_device["modules"] = ""
            ir_device["driver"] = ""
            ir_device["device"] = ""
            ir_device["lircd_conf"] = ""
            self.lirc.set_device(ir_device,"transmitter")
        except debconf.DebconfError:
            pass

        self.lirc.write_hardware_conf(self.target + '/etc/lirc/hardware.conf')

        try:
            self.reconfigure('lirc')
        finally:
            try:
                os.unlink('/target/sbin/udevd')
            except OSError:
                pass
            self.chrex('dpkg-divert', '--package', 'ubiquity', '--rename',
                       '--quiet', '--remove', '/sbin/udevd')
        self.chroot_cleanup()

        #configure lircrc
        home = '/target/home/' + self.db.get('passwd/username')
        os.putenv('HOME',home)
        self.lirc.create_lircrc(self.target + "/etc/lirc/lircd.conf",False)
        os.system('chown ' + str(self.uid) + ':' + str(self.gid) + ' -R ' + home + '/.lirc*')

    def enable_amd(self,type,format):
        if type == 'Composite Video Output':
            self.chrex('/usr/bin/aticonfig','--tvs VIDEO', '--tvf ' + format)
        elif type == 'S-Video Video Output':
            self.chrex('/usr/bin/aticonfig','--tvs VIDEO', '--tvf ' + format)
        elif type == 'Component Video Output':
            self.chrex('/usr/bin/aticonfig','--tvs YUV', '--tvf ' + format)
        else:
            self.chrex('/usr/bin/aticonfig')

    def enable_nvidia(self,type,format):
        """Enables an NVIDIA graphics driver using XKit"""
        xorg_conf=XKit.xutils.XUtils("/etc/X11/xorg.conf")

        extra_conf_options={'NoLogo': '1',
                           'DPI': '100x100',
                           'UseEvents': '1'}

        if type == 'Composite Video Output':
            extra_conf_options["ConnectedMonitor"]="TV"
            extra_conf_options["TVOutFormat"]="COMPOSITE"
            extra_conf_options["TVStandard"]=format
        elif type == 'S-Video Video Output':
            extra_conf_options["ConnectedMonitor"]="TV"
            extra_conf_options["TVOutFormat"]="SVIDEO"
            extra_conf_options["TVStandard"]=format
        elif type == 'Component Video Output':
            extra_conf_options["ConnectedMonitor"]="TV"
            extra_conf_options["TVOutFormat"]="COMPONENT"
            extra_conf_options["TVStandard"]=format

        #Set up device section
        relevant_devices = []
        if len(xorg_conf.globaldict['Device']) == 0:
            device = xorg_conf.makeSection('Device', identifier='Default Device')
            relevant_devices.append(device)
            xorg_conf.setDriver('Device', 'nvidia', device)
        else:
            devices = xorg_conf.getDevicesInUse()
            if len(devices) > 0:
                relevant_devices = devices
            else:
                relevant_devices = xorg_conf.globaldict['Device'].keys()
            for device in relevant_devices:
                xorg_conf.setDriver('Device', 'nvidia', device)

        for device_section in relevant_devices:
            for k, v in extra_conf_options.iteritems():
                xorg_conf.addOption('Device', k, v, optiontype='Option', position=device_section)

        #Set up screen section
        if len(xorg_conf.globaldict['Screen']) == 0:
            screen = xorg_conf.makeSection('Screen', identifier='Default Screen')

        xorg_conf.addOption('Screen', 'DefaultDepth', '24', position=0, prefix='')

        xorg_conf.writeFile(self.target + "/etc/X11/xorg.conf")

    def remove_extras(self):
        """Try to remove packages that are installed on the live CD but not on
        the installed system."""
        #First remove normal live-desktop packages
        ParentInstall.remove_extras(self)

        #now take care of mythbuntu specifics
        packages=set()
        ## system role
        if 'Slave' in self.type or self.type == 'Frontend':
            packages.add('mythtv-backend-master')
        if 'Frontend' not in self.type:
            packages.add('mythtv-frontend')
        ## services that are installed by default
        for service in ['samba','openssh-server']:
            if self.db.get('mythbuntu/' + service) == "false":
                packages.add(service)

        if len(packages) >= 0:
            #recursively remove to make sure we get plugins and services that
            #aren't necessary anymore
            self.do_remove(packages,True)
Beispiel #7
0
class RemotePlugin(MCCPlugin):
    """A GUI configuration tool for LIRC"""
    def __init__(self):
        #Initialize parent class
        information = {}
        information["name"] = "Infrared"
        information["icon"] = "gtk-media-record"
        information["ui"] = "tab_remote_control"
        MCCPlugin.__init__(self, information)

        self.count = {}
        self.count["remote"] = 0
        self.count["transmitter"] = 0

    #Helper functions
    def populate_lirc(self):
        """Fills the lirc pages with the appropriate data"""
        def fill_array(list, possible_items):
            """Fills an individual array up"""
            count = 0
            for item in possible_items:
                list.append([item])
                count = count + 1
            return count

        for type in ('remote', 'transmitter'):
            list = self.builder.get_object(type + '_list')
            model = list.get_model()
            self.count[type]=fill_array(model, \
                                        self.lirc.get_possible_devices(type))
            list.set_active_iter(model.get_iter(Gtk.TreePath([0, 0])))

    def find_lircrc(self):
        """Determines if there is current a lircrc for the current user"""
        return os.path.exists(os.getenv('HOME') + '/.lircrc')

    #Inherited, overridden functions
    def captureState(self):
        """Determines the state of the items on managed by this plugin"""
        #Parent functionality for state capturing
        MCCPlugin.clearParentState(self)
        #If this is a first run of capturing, we might need to fill
        #in our remote_count
        self.state = {}
        for item in ['lirc', 'mythbuntu-lirc-generator']:
            self.state[item] = self.query_installed(item)

        #TODO, detect smartphone type somehow.
        self.state['type'] = 'native'

        if self.state['lirc']:
            self.state['type'] = 'lirc'
            if self.count["remote"] is 0:
                self.lirc = LircHandler()
                self.populate_lirc()
            #Read in our /etc/lirc/hardware.conf
            self.lirc.read_hardware_conf()

    def applyStateToGUI(self):
        """Takes the current state in formation and sets the GUI"""
        def match_object(saved_setting, list, count):
            """Attempts to match a saved object to a GTK list of objects"""
            if saved_setting is "Custom":
                return True
            elif saved_setting != "None":
                for item in range(count):
                    model = list.get_model()
                    iter = model.get_iter(Gtk.TreePath([item, 0]))
                    list.set_active_iter(iter)
                    if model[iter][0] == saved_setting:
                        return True
            return False

        def load_custom(type, dictionary):
            """Loads a custom remote or transmitter into the GUI"""
            modules = self.builder.get_object(type + '_modules')
            device = self.builder.get_object(type + '_device')
            driver = self.builder.get_object(type + '_driver')
            conf = self.builder.get_object('browse_' + type + '_lircd_conf')
            modules.set_text(dictionary[type + "_modules"])
            driver.set_text(dictionary[type + "_driver"])
            device.set_text(dictionary[type + "_device"])
            conf.select_filename("/usr/share/lirc/" + type)
            if os.path.exists("/usr/share/lirc/" + type + '/' +
                              dictionary[type + "_lircd_conf"]):
                conf.select_filename("/usr/share/lirc/" + type + '/' +
                                     dictionary[type + "_lircd_conf"])

        if self.state['type'] == 'lirc':
            self.smartphone_vbox.set_sensitive(False)
            self.lirc_vbox.set_sensitive(True)
            self.lirc_support.set_active(True)
            for type in ('remote', 'transmitter'):
                dict = self.lirc.get_device_dictionary(type)
                list = self.builder.get_object(type + '_list')
                checkbox = self.builder.get_object(type + 'control')
                found = match_object(dict[type], list, self.count[type])
                checkbox.set_active(found)
                self.toggle_ir(checkbox, True)

                #"Custom" support
                load_custom(type, dict)
        elif self.state['type'] == 'native':
            self.lirc_vbox.set_sensitive(False)
            self.smartphone_vbox.set_sensitive(False)
        else:
            self.lirc_vbox.set_sensitive(False)
            self.smartphone_vbox.set_sensitive(True)

    def compareState(self):
        """Determines what items have been modified on this plugin"""
        def test_basic_changes(type):
            """Test for changes in a regular remote or transmitter"""
            old = self.lirc.get_device_dictionary(type)[type]
            list = self.builder.get_object(type + '_list')
            model = list.get_model()
            current = model[list.get_active_iter()][0]
            if old != current:
                self._markReconfigureRoot(type, current)
            return current

        def test_custom_changes(type):
            """Tests for changes in a custom remote or transmitter"""
            old = {}
            new = {}
            old['modules'] = self.lirc.get_device_dictionary(type)[type +
                                                                   "_modules"]
            old['device'] = self.lirc.get_device_dictionary(type)[type +
                                                                  "_device"]
            old['driver'] = self.lirc.get_device_dictionary(type)[type +
                                                                  "_driver"]
            old['lircd_conf'] = self.lirc.get_device_dictionary(type)[
                type + "_lircd_conf"]
            new['modules'] = self.builder.get_object(type +
                                                     '_modules').get_text()
            new['device'] = self.builder.get_object(type +
                                                    '_device').get_text()
            new['driver'] = self.builder.get_object(type +
                                                    '_driver').get_text()
            new['lircd_conf'] = self.builder.get_object(
                'browse_' + type + '_lircd_conf').get_filename()
            for item in old:
                if old[item] != new[item]:
                    self._markReconfigureRoot(type + '_' + item, new[item])

        #Prepare for state capturing
        MCCPlugin.clearParentState(self)

        #check for type changes
        if self.native_support.get_active():
            radio = 'native'
        elif self.lirc_support.get_active():
            radio = 'lirc'
        else:
            radio = 'smartphone'

        #figure out if we are installing lirc or removing it
        if self.state['type'] != radio:
            if radio == 'lirc' and not self.state['lirc']:
                self._markInstall('lirc')
            elif self.state['lirc']:
                self._markRemove('lirc')

        if self.state['lirc']:
            for type in ('remote', 'transmitter'):
                value = test_basic_changes(type)
                if value == 'Custom':
                    test_custom_changes(type)

            if self.generate_lircrc_checkbox.get_active():
                if not self.state['mythbuntu-lirc-generator']:
                    self._markInstall('mythbuntu-lirc-generator')
                if self.enable_irexec_checkbox.get_active():
                    self._markReconfigureUser("generate_lircrc_irexec", True)
                else:
                    self._markReconfigureUser("generate_lircrc", True)
            elif self.enable_irexec_checkbox.get_active():
                if not self.state['mythbuntu-lirc-generator']:
                    self._markInstall('mythbuntu-lirc-generator')
                self._markReconfigureUser("generate_lircrc_irexec_only", True)

    def toggle_ir(self, widget, internal=False):
        """Callback used for any widgets in the remote plugin"""
        def toggle_active_section(widget, type):
            """Turns on or off an IR remote"""
            hbox = self.builder.get_object(type + '_hbox')
            list = self.builder.get_object(type + '_list')
            hbox.set_sensitive(widget.get_active())
            if widget.get_active():
                if list.get_active() == 0:
                    list.set_active(1)
            else:
                list.set_active(0)

        def toggle_active_object_selection(widget, type):
            """Toggles the active device selection and related items"""
            control = self.builder.get_object(type + 'control')
            list = self.builder.get_object(type + '_list')
            driver = self.builder.get_object(type + '_driver_hbox')
            modules = self.builder.get_object(type + '_modules_hbox')
            device = self.builder.get_object(type + '_device_hbox')
            config = self.builder.get_object(type + '_configuration_hbox')

            if list.get_model()[list.get_active_iter()][0] == "Custom":
                custom = True
            else:
                custom = False
                if list.get_active() == 0:
                    control.set_active(False)
                    return False

            for item in (driver, modules, device, config):
                if custom:
                    item.show()
                else:
                    item.hide()
            return True

        if internal and self.find_lircrc():
            self.generate_lircrc_checkbox.set_active(False)
            self.enable_irexec_checkbox.set_active(False)

        if widget is not None:
            #toggle types on the page
            if type(widget) is Gtk.RadioButton:
                #they all have callbacks, only use the active one
                if widget.get_active():
                    name = widget.get_name()
                    if name == 'native_support':
                        self.smartphone_vbox.set_sensitive(False)
                        self.lirc_vbox.set_sensitive(False)
                    elif name == 'smartphone_support':
                        self.smartphone_vbox.set_sensitive(True)
                        self.lirc_vbox.set_sensitive(False)
                        self.emit_progress(
                            "Smartphone support selected.\n\nYou must enable the 'Network Remote Control interface' in the frontend\n\nSetup > General > Remote Control (6th screen)",
                            100)
                    #the lirc package needs to be installed to show this
                    elif self.state['lirc']:
                        self.smartphone_vbox.set_sensitive(False)
                        self.lirc_vbox.set_sensitive(True)

            #turn on/off IR remote
            elif widget.get_name() == 'remotecontrol':
                toggle_active_section(widget, "remote")

            #turn on/off IR transmitter
            elif widget.get_name() == "transmittercontrol":
                toggle_active_section(widget, "transmitter")

            #if our selected remote itself changed
            elif widget.get_name() == 'remote_list':
                if toggle_active_object_selection(widget, "remote"):
                    self.generate_lircrc_checkbox.set_active(True)
                else:
                    self.generate_lircrc_checkbox.set_active(False)

            #if our selected transmitter itself changed
            elif widget.get_name() == 'transmitter_list':
                toggle_active_object_selection(widget, "transmitter")

    def user_scripted_changes(self, reconfigure):
        """Local changes that can be performed by the user account.
           This function will be ran by the frontend."""
        for item in reconfigure:
            if item == "generate_lircrc":
                self.lirc.create_lircrc(change_permissions=False)
            elif item == "generate_lircrc_irexec":
                self.lirc.create_lircrc(change_permissions=False, irexec=True)
            elif item == "generate_lircrc_irexec_only":
                self.lirc.create_lircrc(change_permissions=False,
                                        irexec=True,
                                        irexec_only=True)

    def root_scripted_changes(self, reconfigure):
        """System-wide changes that need root access to be applied.
           This function is ran by the dbus backend"""
        lirc = LircHandler()
        found = False
        for item in reconfigure:
            if item == "remote" or item == "transmitter":
                logging.debug("Setting item %s to %s." %
                              (item, reconfigure[item]))
                lirc.set_device({item: reconfigure[item]}, item)
                found = True
        if found:
            logging.debug("Writing out /etc/lirc/hardware.conf")
            lirc.write_hardware_conf()
            logging.debug("Reconfiguring LIRC package")
            lirc.reconfigure_lirc(interactive=False)
        return found
Beispiel #8
0
class Wizard(ParentFrontend.Wizard):

#Overriden Methods
    def __init__(self, distro):
        #Remove migration assistant
        if 'UBIQUITY_MIGRATION_ASSISTANT' in os.environ:
            del os.environ['UBIQUITY_MIGRATION_ASSISTANT']
        place=ParentFrontend.BREADCRUMB_STEPS["stepReady"]

        #Max steps
        ParentFrontend.BREADCRUMB_MAX_STEP = place + len(MYTHPAGES)

        #update location of summary page
        ParentFrontend.BREADCRUMB_STEPS["stepReady"]=place+len(MYTHPAGES)-1

        #Add in final page
        final_page=MYTHPAGES.pop()
        ParentFrontend.BREADCRUMB_STEPS[final_page]=place+len(MYTHPAGES)+1
        ParentFrontend.SUBPAGES.append(final_page)

        #Add in individual mythpages pages
        for string in MYTHPAGES:
            ParentFrontend.BREADCRUMB_STEPS[string]=place
            ParentFrontend.SUBPAGES.insert(len(ParentFrontend.SUBPAGES)-2,string)
            place+=1

        ParentFrontend.Wizard.__init__(self,distro)

    def customize_installer(self):
        """Initial UI setup."""
        #Default to auto login, but don't make it mandatory
        #This requires disabling encrypted FS
        self.set_auto_login(True)
        self.login_encrypt.set_sensitive(False)

        #Remove their summary page.  ours is better
        self.pages.pop()

        #Insert all of our pages
        for page in [mythbuntu.MythbuntuInstallType, mythbuntu.MythbuntuServices,
            mythbuntu.MythbuntuRemote, mythbuntu.MythbuntuDrivers,
            mythbuntu.MythbuntuPasswords, mythbuntu_install.Summary]:
            self.pages.append(page)

        #Prepopulate some dynamic pages
        self.populate_lirc()
        self.populate_video()
        self.populate_mysql()
        self.backup=False

        ParentFrontend.Wizard.customize_installer(self)

    def run_success_cmd(self):
        """Runs mythbuntu post post install GUI step"""
        if not 'UBIQUITY_AUTOMATIC' in os.environ and self.get_installtype() != "Frontend":
            self.live_installer.show()
            self.installing = False
            self.steps.next_page()
            self.back.hide()
            self.quit.hide()
            self.next.set_label("Finish")
            gtk.main()
            self.live_installer.hide()
        ParentFrontend.Wizard.run_success_cmd(self)

    def set_page(self, n):
        if n == 'MythbuntuRemote':
            cur = self.tab_remote_control
        elif n == 'MythbuntuDrivers':
            cur = self.mythbuntu_stepDrivers
        elif n == 'MythbuntuInstallType':
            cur = self.mythbuntu_stepCustomInstallType
        elif n == 'MythbuntuPasswords':
            cur = self.mythbuntu_stepPasswords
            if "Master" not in self.get_installtype():
                self.allow_go_forward(False)
        elif n == 'MythbuntuServices':
            cur = self.mythbuntu_stepServices
            self.vnc_option_hbox.set_sensitive(len(self.get_password()) >= 6)
        else:
            ParentFrontend.Wizard.set_page(self,n)
            return
        self.run_automation_error_cmd()
        self.backup = False
        self.live_installer.show()
        self.set_current_page(self.steps.page_num(cur))

####################
#Helper Functions  #
####################
#Called for initialization and calculation on a page

    def populate_lirc(self):
            """Fills the lirc pages with the appropriate data"""
            self.remote_count = 0
            self.transmitter_count = 0
            self.lirc=LircHandler()
            for item in self.lirc.get_possible_devices("remote"):
                if "Custom" not in item and "Blaster" not in item:
                    self.remote_list.append_text(item)
                    self.remote_count = self.remote_count + 1
            for item in self.lirc.get_possible_devices("transmitter"):
                if "Custom" not in item:
                    self.transmitter_list.append_text(item)
                    self.transmitter_count = self.transmitter_count + 1
            self.remote_list.set_active(0)
            self.transmitter_list.set_active(0)

    def populate_video(self):
        """Finds the currently active video driver"""
        dictionary=get_graphics_dictionary()
        if len(dictionary) > 0:
            for driver in dictionary:
                self.video_driver.append_text(driver)
            self.video_driver.append_text("Open Source Driver")
            self.video_driver.set_active(len(dictionary))
            self.tvoutstandard.set_active(0)
            self.tvouttype.set_active(0)
        else:
            for step in ParentFrontend.BREADCRUMB_STEPS:
                if (ParentFrontend.BREADCRUMB_STEPS[step] >
                    ParentFrontend.BREADCRUMB_STEPS[VIDEOPAGE]):
                    ParentFrontend.BREADCRUMB_STEPS[step] -= 1
            ParentFrontend.BREADCRUMB_MAX_STEP -= 1
            self.steps.remove_page(self.steps.page_num(self.mythbuntu_stepDrivers))
            self.pages.remove(mythbuntu.MythbuntuDrivers)

    def populate_mysql(self):
        """Puts a new random mysql password into the UI for each run
           This ensures that passwords don't ever get cached"""
        self.mysql=MySQLHandler()
        new_pass_caller = subprocess.Popen(['pwgen','-s','8'],stdout=subprocess.PIPE)
        self.mysql_password.set_text(string.split(new_pass_caller.communicate()[0])[0])

    def do_mythtv_setup(self,widget):
        """Spawn MythTV-Setup binary."""
        self.live_installer.hide()
        self.refresh()
        execute_root("/usr/share/ubiquity/mythbuntu-setup")
        self.live_installer.show()

    def do_connection_test(self,widget):
        """Tests to make sure that the backend is accessible"""
        config={}
        config["user"]=self.mysql_user.get_text()
        config["password"]=self.mysql_password.get_text()
        config["server"]=self.mysql_server.get_text()
        config["database"]=self.mysql_database.get_text()
        self.mysql.update_config(config)
        result=self.mysql.do_connection_test()
        self.allow_go_forward(True)
        self.connection_results_label.show()
        self.connection_results.set_text(result)

#####################
#Preseeding Functions#
#####################
#Used to preset the status of an element in the GUI

    def set_installtype(self,type):
        """Preseeds the type of custom install"""
        if type == "Set Top Box":
            self.stb.set_active(True)
        elif type == "Frontend":
            self.fe.set_active(True)
        elif type == "Slave Backend":
            self.slave_be.set_active(True)
        elif type == "Master Backend":
            self.master_be.set_active(True)
        elif type == "Slave Backend/Frontend":
            self.slave_be_fe.set_active(True)
        else:
            self.master_be_fe.set_active(True)

    def set_service(self,name,value):
        """Preseeds the status of a service"""
        lists = [get_services_dictionary(self)]
        self._preseed_list(lists,name,value)

    def set_driver(self,name,value):
        """Preseeds the status of a driver"""
        lists = [{'video_driver': self.video_driver,
                  'tvout': self.tvouttype,
                  'tvstandard': self.tvoutstandard}]
        self._preseed_list(lists,name,value)

    def set_password(self,name,value):
        """Preseeds a password"""
        lists = [{'mysql_mythtv_user':self.mysql_user,
                  'mysql_mythtv_password':self.mysql_password,
                  'mysql_mythtv_dbname':self.mysql_database,
                  'mysql_host':self.mysql_server}]
        self._preseed_list(lists,name,value)

    def set_lirc(self,question,answer):
        """Preseeds a lirc configuration item"""
        if question == "remote":
            for i in range(0,self.remote_count):
                self.remote_list.set_active(i)
                found=False
                if self.remote_list.get_active_text() == answer:
                    found = True
                    break
                if not found:
                    self.remote_list.set_active(0)
        if question == "transmitter":
            for i in range(0,self.transmitter_count):
                self.transmitter_list.set_active(i)
                found=False
                if self.transmitter_list.get_active_text() == answer:
                    found = True
                    break
                if not found:
                    self.transmitter_list.set_active(0)

    def _preseed_list(self,lists,names,value):
        """Helper function for preseeding dictionary based lists"""
        new_value = create_bool(value)
        for list in lists:
            for item in list:
                for name in string.split(names):
                    if item == name:
                        #be careful what type of item we are deealing with
                        if type(list[item]) == gtk.CheckButton:
                            list[item].set_active(new_value)
                        elif type(list[item]) == gtk.Entry:
                            list[item].set_text(new_value)
                        elif type(list[item]) == gtk.ComboBox:
                            for iteration in range(len(list[item]),0):
                                list[item].set_active(iteration)
                                if list[item].get_active_text() == new_value:
                                    break
                        else:
                            list[item].set_active_text(new_value)

##################
#Status Reading  #
##################
#Functions for reading the status of Frontend elements

    def get_installtype(self):
        """Returns the current custom installation type"""
        if self.master_be_fe.get_active():
            return "Master Backend/Frontend"
        elif self.slave_be_fe.get_active():
            return "Slave Backend/Frontend"
        elif self.master_be.get_active():
            return "Master Backend"
        elif self.slave_be.get_active():
            return "Slave Backend"
        elif self.fe.get_active():
            return "Frontend"
        elif self.stb.get_active():
            return "Set Top Box"

    def _build_static_list(self,lists):
        """Creates a flat list"""
        total_list= {}
        for list in lists:
            for item in list:
                if type(list[item]) == str:
                    total_list[item]=list[item]
                elif type(list[item]) == gtk.CheckButton:
                    total_list[item]=list[item].get_active()
                elif type(list[item]) == gtk.Entry:
                    total_list[item]=list[item].get_text()
                else:
                    total_list[item]=list[item].get_active_text()
        return total_list

    def get_services(self):
        """Returns the status of all installable services"""
        return self._build_static_list([get_services_dictionary(self)])

    def get_drivers(self):
        video_drivers=get_graphics_dictionary()
        active_video_driver=self.video_driver.get_active_text()
        for item in video_drivers:
            if (active_video_driver == item):
                active_video_driver=video_drivers[item]
                break
        return self._build_static_list([{'video_driver': active_video_driver,
                                         'tvout': self.tvouttype,
                                         'tvstandard': self.tvoutstandard}])

    def get_mythtv_passwords(self):
        return self._build_static_list([{'mysql_mythtv_user':self.mysql_user,
                                         'mysql_mythtv_password':self.mysql_password,
                                         'mysql_mythtv_dbname':self.mysql_database,
                                         'mysql_host':self.mysql_server}])

    def get_lirc(self,type):
        item = {"modules":"","device":"","driver":"","lircd_conf":""}
        if type == "remote":
            item["remote"]=self.remote_list.get_active_text()
        elif type == "transmitter":
            item["transmitter"]=self.transmitter_list.get_active_text()
        return item

##################
#Toggle functions#
##################
#Called when a widget changes and other GUI elements need to react

    def toggle_tv_out (self,widget):
        """Called when the tv-out type is toggled"""
        if (self.tvouttype.get_active() == 0):
            self.tvoutstandard.set_active(0)
        elif ((self.tvouttype.get_active() == 1 or self.tvouttype.get_active() == 2) and (self.tvoutstandard.get_active() == 0 or self.tvoutstandard.get_active() >= 11 )):
            self.tvoutstandard.set_active(10)
        elif self.tvouttype.get_active() == 3:
            self.tvoutstandard.set_active(11)

    def toggle_tv_standard(self,widget):
        """Called when the tv standard is toggled"""
        if (self.tvoutstandard.get_active() >= 11):
            self.tvouttype.set_active(3)
        elif (self.tvoutstandard.get_active() < 11 and self.tvoutstandard.get_active() > 0 and self.tvouttype.get_active() == 0):
            self.tvouttype.set_active(1)
        elif (self.tvoutstandard.get_active() < 11 and self.tvouttype.get_active() ==3):
            self.tvouttype.set_active(1)
        elif (self.tvoutstandard.get_active() == 0):
            self.tvouttype.set_active(0)

    def video_changed (self,widget):
        """Called whenever the modify video driver option is toggled or its kids"""
        drivers=get_graphics_dictionary()
        if (widget is not None and widget.get_name() == 'video_driver'):
            type = widget.get_active()
            if (type < len(drivers)):
                self.tvout_vbox.set_sensitive(True)
            else:
                self.tvout_vbox.set_sensitive(False)
                self.tvoutstandard.set_active(0)
                self.tvouttype.set_active(0)

    def toggle_customtype (self,widget):
        """Called whenever a custom type is toggled"""

        if "Master" in self.get_installtype():
            self.mysql_option_hbox.show()
        else:
            self.enablemysql.set_active(False)
            self.mysql_option_hbox.hide()

        if "Backend" in self.get_installtype():
            self.samba_option_hbox.show()
            self.nfs_option_hbox.show()
        else:
            self.enablesamba.set_active(False)
            self.enablenfs.set_active(False)
            self.samba_option_hbox.hide()
            self.nfs_option_hbox.hide()

    def toggle_ir(self,widget):
        """Called whenever a request to enable/disable remote is called"""
        if widget is not None:
            #turn on/off IR remote
            if widget.get_name() == 'remotecontrol':
                self.remote_hbox.set_sensitive(widget.get_active())
                self.generate_lircrc_checkbox.set_sensitive(widget.get_active())
                if widget.get_active() and self.remote_list.get_active() == 0:
                        self.remote_list.set_active(1)
                else:
                    self.remote_list.set_active(0)
            #turn on/off IR transmitter
            elif widget.get_name() == "transmittercontrol":
                self.transmitter_hbox.set_sensitive(widget.get_active())
                if widget.get_active():
                    if self.transmitter_list.get_active() == 0:
                        self.transmitter_list.set_active(1)
                else:
                    self.transmitter_list.set_active(0)
            #if our selected remote itself changed
            elif widget.get_name() == 'remote_list':
                self.generate_lircrc_checkbox.set_active(True)
                if self.remote_list.get_active() == 0:
                    self.remotecontrol.set_active(False)
                    self.generate_lircrc_checkbox.set_active(False)
            #if our selected transmitter itself changed
            elif widget.get_name() == 'transmitter_list':
                if self.transmitter_list.get_active() == 0:
                    self.transmittercontrol.set_active(False)