Example #1
0
    def set_defaults(self, widget=None, event=None):
        """ Put some default values into entries to help the user out. """
        self.txt_ip.set_text(self.txt_ip.get_text().strip())
        ipAddress = self.txt_ip.get_text()  # For easy typing :)
        netmask = self.txt_netmask
        gateway = self.txt_gateway
        ip_parts = misc.IsValidIP(ipAddress)
        if ip_parts:
            if stringToNone(gateway.get_text()) is None:  # Make sure the gateway box is blank
                # Fill it in with a .1 at the end
                gateway.set_text('.'.join(ip_parts[0:3]) + '.1')

            if stringToNone(netmask.get_text()) is None:  # Make sure the netmask is blank
                netmask.set_text('255.255.255.0')  # Fill in the most common one
        elif ipAddress != "":
            error(None, language['invalid_ip_address'])
Example #2
0
    def set_values(self):
        self.ip_edit.set_edit_text(self.format_entry("ip"))
        self.netmask_edit.set_edit_text(self.format_entry("netmask"))
        self.gateway_edit.set_edit_text(self.format_entry("gateway"))

        self.global_dns_cb.set_state(bool(wired.GetWiredProperty('use_global_dns')))
        self.static_dns_cb.set_state(bool(wired.GetWiredProperty('use_static_dns')))
        
        # Set static ip checkbox.  Forgot to do this the first time.
        if stringToNone(self.ip_edit.get_edit_text()):
            self.static_ip_cb.set_state(True)
        self.dns1.set_edit_text(self.format_entry( "dns1"))
        self.dns2.set_edit_text(self.format_entry( "dns2"))
        self.dns3.set_edit_text(self.format_entry( "dns3"))
        self.dns_dom_edit.set_edit_text(self.format_entry("dns_domain"))
        self.search_dom_edit.set_edit_text(self.format_entry("search_domain"))

        self.set_default.set_state(to_bool(wired.GetWiredProperty("default")))

        dhcphname = wired.GetWiredProperty("dhcphostname")
        if dhcphname is None:
            dhcphname = os.uname()[1]

        self.use_dhcp_h.set_state(bool(wired.GetWiredProperty('usedhcphostname')))
        self.dhcp_h.set_sensitive(self.use_dhcp_h.get_state())
        self.dhcp_h.set_edit_text(unicode(dhcphname))
Example #3
0
    def set_values(self):
        self.ip_edit.set_edit_text(self.format_entry("ip"))
        self.netmask_edit.set_edit_text(self.format_entry("netmask"))
        self.gateway_edit.set_edit_text(self.format_entry("gateway"))

        self.global_dns_cb.set_state(bool(wired.GetWiredProperty('use_global_dns')))
        self.static_dns_cb.set_state(bool(wired.GetWiredProperty('use_static_dns')))
        
        # Set static ip checkbox.  Forgot to do this the first time.
        if stringToNone(self.ip_edit.get_edit_text()):
            self.static_ip_cb.set_state(True)
        self.dns1.set_edit_text(self.format_entry( "dns1"))
        self.dns2.set_edit_text(self.format_entry( "dns2"))
        self.dns3.set_edit_text(self.format_entry( "dns3"))
        self.dns_dom_edit.set_edit_text(self.format_entry("dns_domain"))
        self.search_dom_edit.set_edit_text(self.format_entry("search_domain"))

        self.set_default.set_state(to_bool(wired.GetWiredProperty("default")))

        dhcphname = wired.GetWiredProperty("dhcphostname")
        if dhcphname is None:
            dhcphname = os.uname()[1]

        self.use_dhcp_h.set_state(bool(wired.GetWiredProperty('usedhcphostname')))
        self.dhcp_h.set_sensitive(self.use_dhcp_h.get_state())
        self.dhcp_h.set_edit_text(unicode(dhcphname))
Example #4
0
    def set_defaults(self, widget=None, event=None):
        """ Put some default values into entries to help the user out. """
        self.txt_ip.set_text(self.txt_ip.get_text().strip())
        ipAddress = self.txt_ip.get_text()  # For easy typing :)
        netmask = self.txt_netmask
        gateway = self.txt_gateway
        ip_parts = misc.IsValidIP(ipAddress)
        if ip_parts:
            if stringToNone(gateway.get_text()
                            ) is None:  # Make sure the gateway box is blank
                # Fill it in with a .1 at the end
                gateway.set_text('.'.join(ip_parts[0:3]) + '.1')

            if stringToNone(netmask.get_text()
                            ) is None:  # Make sure the netmask is blank
                netmask.set_text(
                    '255.255.255.0')  # Fill in the most common one
        elif ipAddress != "":
            error(None, language['invalid_ip_address'])
Example #5
0
    def reset_static_checkboxes(self):
        # Enable the right stuff
        if stringToNone(self.txt_ip.get_text()):
            self.chkbox_static_ip.set_active(True)
            self.chkbox_static_dns.set_active(True)
            self.chkbox_static_dns.set_sensitive(False)
        else:
            self.chkbox_static_ip.set_active(False)
            self.chkbox_static_dns.set_sensitive(True)

        if stringToNone(self.txt_dns_1.get_text()) or \
           self.chkbox_global_dns.get_active():
            self.chkbox_static_dns.set_active(True)
        else:
            self.chkbox_static_dns.set_active(False)

        # This will properly disable unused boxes.
        self.toggle_ip_checkbox()
        self.toggle_dns_checkbox()
        self.toggle_global_dns_checkbox()
Example #6
0
    def reset_static_checkboxes(self):
        # Enable the right stuff
        if stringToNone(self.txt_ip.get_text()):
            self.chkbox_static_ip.set_active(True)
            self.chkbox_static_dns.set_active(True)
            self.chkbox_static_dns.set_sensitive(False)
        else:
            self.chkbox_static_ip.set_active(False)
            self.chkbox_static_dns.set_sensitive(True)

        if stringToNone(self.txt_dns_1.get_text()) or \
           self.chkbox_global_dns.get_active():
            self.chkbox_static_dns.set_active(True)
        else:
            self.chkbox_static_dns.set_active(False)

        # This will properly disable unused boxes.
        self.toggle_ip_checkbox()
        self.toggle_dns_checkbox()
        self.toggle_global_dns_checkbox()
Example #7
0
    def set_values(self):
        """ Load saved values. """
        self.ip_edit.set_edit_text(self.format_entry("ip"))
        self.netmask_edit.set_edit_text(self.format_entry("netmask"))
        self.gateway_edit.set_edit_text(self.format_entry("gateway"))

        self.global_dns_cb.set_state(
            bool(wired.GetWiredProperty('use_global_dns'))
        )
        self.static_dns_cb.set_state(
            bool(wired.GetWiredProperty('use_static_dns'))
        )

        # Set static ip checkbox.  Forgot to do this the first time.
        if stringToNone(self.ip_edit.get_edit_text()):
            self.static_ip_cb.set_state(True)
        self.dns1.set_edit_text(self.format_entry("dns1"))
        self.dns2.set_edit_text(self.format_entry("dns2"))
        self.dns3.set_edit_text(self.format_entry("dns3"))
        self.dns_dom_edit.set_edit_text(self.format_entry("dns_domain"))
        self.search_dom_edit.set_edit_text(self.format_entry("search_domain"))

        self.set_default.set_state(to_bool(wired.GetWiredProperty("default")))

        # Throw the encryption stuff into a list
        l = []
        activeID = -1  # Set the menu to this item when we are done
        for x, enc_type in enumerate(self.encrypt_types):
            l.append(enc_type['name'])
            if enc_type['type'] == wired.GetWiredProperty("enctype"):
                activeID = x
        self.encryption_combo.set_list(l)

        self.encryption_combo.set_focus(activeID)
        if wired.GetWiredProperty("encryption_enabled"):
            self.encryption_chkbox.set_state(True, do_callback=False)
            self.encryption_combo.set_sensitive(True)
            #self.lbox_encrypt_info.set_sensitive(True)
        else:
            self.encryption_combo.set_focus(0)
            self.encryption_combo.set_sensitive(False)

        self.change_encrypt_method()

        dhcphname = wired.GetWiredProperty("dhcphostname")
        if dhcphname is None:
            dhcphname = os.uname()[1]

        self.use_dhcp_h.set_state(
            bool(wired.GetWiredProperty('usedhcphostname'))
        )
        self.dhcp_h.set_sensitive(self.use_dhcp_h.get_state())
        self.dhcp_h.set_edit_text(unicode(dhcphname))
Example #8
0
    def set_values(self):
        """ Set the various network settings to the right values. """
        networkID = self.networkid
        self.ip_edit.set_edit_text(self.format_entry(networkID,"ip"))
        self.netmask_edit.set_edit_text(self.format_entry(networkID,"netmask"))
        self.gateway_edit.set_edit_text(self.format_entry(networkID,"gateway"))

        self.global_dns_cb.set_state(bool(wireless.GetWirelessProperty(networkID,
                                                                  'use_global_dns')))
        self.static_dns_cb.set_state(bool(wireless.GetWirelessProperty(networkID,
                                                                  'use_static_dns')))
        
        if stringToNone(self.ip_edit.get_edit_text()):
            self.static_ip_cb.set_state(True)
        self.dns1.set_edit_text(self.format_entry(networkID, "dns1"))
        self.dns2.set_edit_text(self.format_entry(networkID, "dns2"))
        self.dns3.set_edit_text(self.format_entry(networkID, "dns3"))
        self.dns_dom_edit.set_edit_text(self.format_entry(networkID, "dns_domain"))
        self.search_dom_edit.set_edit_text(self.format_entry(networkID, "search_domain"))
        
        self.autoconnect_chkbox.set_state(to_bool(self.format_entry(networkID, "automatic")))

        #self.reset_static_checkboxes()
        self.encryption_chkbox.set_state(bool(wireless.GetWirelessProperty(networkID,
            'encryption')),do_callback=False)
        self.global_settings_chkbox.set_state(bool(wireless.GetWirelessProperty(networkID
            ,'use_settings_globally')))

        # Throw the encryption stuff into a list
        list = []
        activeID = -1  # Set the menu to this item when we are done
        for x, enc_type in enumerate(self.encrypt_types):
            list.append(enc_type['name'])
            if enc_type['type'] == wireless.GetWirelessProperty(networkID, "enctype"):
                activeID = x
        self.encryption_combo.set_list(list)

        self.encryption_combo.set_focus(activeID)
        if activeID != -1:
            self.encryption_chkbox.set_state(True,do_callback=False)
            self.encryption_combo.set_sensitive(True)
            #self.lbox_encrypt_info.set_sensitive(True)
        else:
            self.encryption_combo.set_focus(0)

        self.change_encrypt_method()
        dhcphname = wireless.GetWirelessProperty(networkID,"dhcphostname")
        if dhcphname is None:
            dhcphname = os.uname()[1]
        self.use_dhcp_h.set_state(bool(wireless.GetWirelessProperty(networkID,'usedhcphostname')))
        self.dhcp_h.set_sensitive(self.use_dhcp_h.get_state())
        self.dhcp_h.set_edit_text(unicode(dhcphname))
Example #9
0
    def set_values(self):
        """ Set the various network settings to the right values. """
        networkID = self.networkid
        self.ip_edit.set_edit_text(self.format_entry(networkID,"ip"))
        self.netmask_edit.set_edit_text(self.format_entry(networkID,"netmask"))
        self.gateway_edit.set_edit_text(self.format_entry(networkID,"gateway"))

        self.global_dns_cb.set_state(bool(wireless.GetWirelessProperty(networkID,
                                                                  'use_global_dns')))
        self.static_dns_cb.set_state(bool(wireless.GetWirelessProperty(networkID,
                                                                  'use_static_dns')))
        
        if stringToNone(self.ip_edit.get_edit_text()):
            self.static_ip_cb.set_state(True)
        self.dns1.set_edit_text(self.format_entry(networkID, "dns1"))
        self.dns2.set_edit_text(self.format_entry(networkID, "dns2"))
        self.dns3.set_edit_text(self.format_entry(networkID, "dns3"))
        self.dns_dom_edit.set_edit_text(self.format_entry(networkID, "dns_domain"))
        self.search_dom_edit.set_edit_text(self.format_entry(networkID, "search_domain"))
        
        self.autoconnect_chkbox.set_state(to_bool(self.format_entry(networkID, "automatic")))

        #self.reset_static_checkboxes()
        self.encryption_chkbox.set_state(bool(wireless.GetWirelessProperty(networkID,
            'encryption')),do_callback=False)
        self.global_settings_chkbox.set_state(bool(wireless.GetWirelessProperty(networkID
            ,'use_settings_globally')))

        # Throw the encryption stuff into a list
        list = []
        activeID = -1  # Set the menu to this item when we are done
        for x, enc_type in enumerate(self.encrypt_types):
            list.append(enc_type['name'])
            if enc_type['type'] == wireless.GetWirelessProperty(networkID, "enctype"):
                activeID = x
        self.encryption_combo.set_list(list)

        self.encryption_combo.set_focus(activeID)
        if activeID != -1:
            self.encryption_chkbox.set_state(True,do_callback=False)
            self.encryption_combo.set_sensitive(True)
            #self.lbox_encrypt_info.set_sensitive(True)
        else:
            self.encryption_combo.set_focus(0)

        self.change_encrypt_method()
        dhcphname = wireless.GetWirelessProperty(networkID,"dhcphostname")
        if dhcphname is None:
            dhcphname = os.uname()[1]
        self.use_dhcp_h.set_state(bool(wireless.GetWirelessProperty(networkID,'usedhcphostname')))
        self.dhcp_h.set_sensitive(self.use_dhcp_h.get_state())
        self.dhcp_h.set_edit_text(unicode(dhcphname))
Example #10
0
    def set_values(self):
        """ Load saved values. """
        self.ip_edit.set_edit_text(self.format_entry("ip"))
        self.netmask_edit.set_edit_text(self.format_entry("netmask"))
        self.gateway_edit.set_edit_text(self.format_entry("gateway"))

        self.global_dns_cb.set_state(
            bool(wired.GetWiredProperty('use_global_dns')))
        self.static_dns_cb.set_state(
            bool(wired.GetWiredProperty('use_static_dns')))

        # Set static ip checkbox.  Forgot to do this the first time.
        if stringToNone(self.ip_edit.get_edit_text()):
            self.static_ip_cb.set_state(True)
        self.dns1.set_edit_text(self.format_entry("dns1"))
        self.dns2.set_edit_text(self.format_entry("dns2"))
        self.dns3.set_edit_text(self.format_entry("dns3"))
        self.dns_dom_edit.set_edit_text(self.format_entry("dns_domain"))
        self.search_dom_edit.set_edit_text(self.format_entry("search_domain"))

        self.set_default.set_state(to_bool(wired.GetWiredProperty("default")))

        # Throw the encryption stuff into a list
        l = []
        activeID = -1  # Set the menu to this item when we are done
        for x, enc_type in enumerate(self.encrypt_types):
            l.append(enc_type['name'])
            if enc_type['type'] == wired.GetWiredProperty("enctype"):
                activeID = x
        self.encryption_combo.set_list(l)

        self.encryption_combo.set_focus(activeID)
        if wired.GetWiredProperty("encryption_enabled"):
            self.encryption_chkbox.set_state(True, do_callback=False)
            self.encryption_combo.set_sensitive(True)
            #self.lbox_encrypt_info.set_sensitive(True)
        else:
            self.encryption_combo.set_focus(0)
            self.encryption_combo.set_sensitive(False)

        self.change_encrypt_method()

        dhcphname = wired.GetWiredProperty("dhcphostname")
        if dhcphname is None:
            dhcphname = os.uname()[1]

        self.use_dhcp_h.set_state(
            bool(wired.GetWiredProperty('usedhcphostname')))
        self.dhcp_h.set_sensitive(self.use_dhcp_h.get_state())
        self.dhcp_h.set_edit_text(str(dhcphname))
	def get_option(self, section, option, default=None):
        """ Wrapper around ConfigParser.get.
        Automatically adds any missing sections, adds the ability
        to write a default value, and if one is provided prints if
        the default or a previously saved value is returned.
        """
        if not self.has_section(section):
            self.add_section(section)
        if self.has_option(section, option):
            ret = ConfigParser.get(self, section, option)
            if default:
                print ''.join(['found ', option, ' in configuration ', ret])
        else:
            print ''.join(['did not find ', option,                           ' in configuration, setting default ', str(default)])
            self.set(section, option, str(default), save=True)
            ret = default
        try:
            ret = int(ret)
        except ValueError, TypeError:
            ret = stringToNone(ret)
Example #12
0
 def test_string_to_none_4(self):
     self.assertEquals(misc.stringToNone('abcdef'), 'abcdef')
Example #13
0
 def test_string_to_none_3(self):
     self.assertEquals(misc.stringToNone(None), None)
Example #14
0
 def test_string_to_none_2(self):
     self.assertEquals(misc.stringToNone('None'), None)
Example #15
0
 def test_string_to_none_4(self):
     self.assertEqual(misc.stringToNone('abcdef'), 'abcdef')
Example #16
0
 def test_string_to_none_3(self):
     self.assertEqual(misc.stringToNone(None), None)
Example #17
0
 def test_string_to_none_2(self):
     self.assertEqual(misc.stringToNone('None'), None)
Example #18
0
 def test_string_to_none_1(self):
     self.assertEquals(misc.stringToNone(''), None)