当前位置: 首页>>代码示例>>Python>>正文


Python nm_utils.TypeConvert类代码示例

本文整理汇总了Python中nmlib.nm_utils.TypeConvert的典型用法代码示例。如果您正苦于以下问题:Python TypeConvert类的具体用法?Python TypeConvert怎么用?Python TypeConvert使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TypeConvert类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: is_wired_setting_ok

    def is_wired_setting_ok(self, info_dict):
        if info_dict["connection"]["type"] != "802-3-ethernet":
            return False
        else:
            if not self.check_conn_setting(info_dict):
                return False

            if not self.check_ip4_setting(info_dict):
                return False

            if "mac-address" in info_dict["802-3-ethernet"].keys():
                if not TypeConvert.is_valid_mac_address(
                    TypeConvert.mac_address_array2string(info_dict["802-3-ethernet"]["mac-address"])
                ):
                    print "wired invalid mac address"
                    return False

            if "cloned-mac-address" in info_dict["802-3-ethernet"].keys():
                if not TypeConvert.is_valid_mac_address(
                    TypeConvert.mac_address_array2string(info_dict["802-3-ethernet"]["mac-address"])
                ):
                    print "wired invalid clone mac address"
                    return False

            if "duplex" in info_dict["802-3-ethernet"].keys():
                if info_dict["802-3-ethernet"]["duplex"] not in ["full", "half"]:
                    print "wired invalid duplex"
                    return False
        return True
开发者ID:martyr-deepin,项目名称:deepin-system-settings,代码行数:29,代码来源:nmconnection.py

示例2: check_valid

 def check_valid(self, name):
     if name == "ip4":
         return TypeConvert.is_valid_ip4(self.ip[0])
     elif name == "netmask":
         return TypeConvert.is_valid_netmask(self.ip[1])
     elif name == "gw":
         return TypeConvert.is_valid_gw(self.ip[0], self.ip[1], self.ip[2])
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:7,代码来源:ipsettings.py

示例3: set_wep_key

 def set_wep_key(self, idx, key):
     if idx == 0:
         self.prop_dict["wep-key0"] = TypeConvert.py2_dbus_string(key)
     elif idx == 1:
         self.prop_dict["wep-key1"] = TypeConvert.py2_dbus_string(key)
     elif idx == 2:
         self.prop_dict["wep-key2"] = TypeConvert.py2_dbus_string(key)
     elif idx == 3:
         self.prop_dict["wep-key3"] = TypeConvert.py2_dbus_string(key)
     else:
         print "invalid idx"
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:11,代码来源:nmsetting_wireless_security.py

示例4: check_setting_finish

    def check_setting_finish(self):
        ###check if user complete his setting, avoid the missing property exception
        info_dict = TypeConvert.dbus2py(self.settings_dict)
        try:
            if info_dict["connection"]["type"] == "802-3-ethernet":
                return self.is_wired_setting_ok(info_dict)

            elif info_dict["connection"]["type"] == "802-11-wireless":
                return self.is_wireless_setting_ok(info_dict)

            elif info_dict["connection"]["type"] == "pppoe":
                return self.is_dsl_setting_ok(info_dict)

            elif info_dict["connection"]["type"] == "vpn":
                return self.is_vpn_setting_ok(info_dict)

            elif info_dict["connection"]["type"] == "cdma":
                return self.is_cdma_setting_ok(info_dict)

            elif info_dict["connection"]["type"] == "gsm":
                return self.is_gsm_setting_ok(info_dict)

            else:
                return False
        except:
            traceback.print_exc()
开发者ID:martyr-deepin,项目名称:deepin-system-settings,代码行数:26,代码来源:nmconnection.py

示例5: add_dns_search

 def add_dns_search(self, dns):
     if dns in self.dns_search:
         print "already have the dns search"
     else:    
         if "dns-search" not in self.prop_dict.iterkeys():    
             self.clear_dns_search()
         self.prop_dict["dns-search"].append(TypeConvert.py2_dbus_string(dns))
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:7,代码来源:nmsetting_ip6config.py

示例6: check_complete_dns

 def check_complete_dns(self):
     dns = []
     for address in self.dns:
         if TypeConvert.is_valid_ip6(address):
             dns.append(address)
         else:
             return dns
     return dns
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:8,代码来源:ipsettings.py

示例7: save_settings

    def save_settings(self, widget, content, types):
        #value = None
        if types:
            setattr(self.ethernet, types, content)
        if self.settings_obj is None:
            return
        
        # check mac address whether is valid
        if types == "mac_address":
            mac_address = content
            cloned_mac_address = self.clone_entry.get_address()
        elif types == "cloned_mac_address":
            mac_address = self.mac_entry.get_address()
            cloned_mac_address = content
        else:
            mac_address = self.mac_entry.get_address()
            cloned_mac_address = self.clone_entry.get_address()

        if (mac_address == ":::::") or \
                (mac_address == "") or \
                (TypeConvert.is_valid_mac_address(mac_address)):
            mac_address_is_valid = True
        else:
            mac_address_is_valid = False
        if (cloned_mac_address == ":::::") or \
                (cloned_mac_address == "") or \
                (TypeConvert.is_valid_mac_address(cloned_mac_address)):
            cloned_mac_address_is_valid = True
        else:
            cloned_mac_address_is_valid = False
        if mac_address_is_valid and cloned_mac_address_is_valid:
            self.settings_obj.mac_is_valid = True
        else:
            self.settings_obj.mac_is_valid = False

        # 统一调用shared_methods.Settings的set_button
        log.debug('set_button True')
        self.settings_obj.set_button("save", True)

        """
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:40,代码来源:lan_config.py

示例8: check_ip4_setting

    def check_ip4_setting(self, info_dict):
        if "ipv4" in info_dict.keys():
            if info_dict["ipv4"]["method"] == "manual":

                if not info_dict["ipv4"]["addresses"]:
                    print "ipv4 addresses not complete"
                    return False
                else:
                    [address, netmask, gateway] = TypeConvert.ip4address_net2native(info_dict["ipv4"]["addresses"][0])

                    if not TypeConvert.is_valid_ip4(address):
                        print "ipv4 invalid address"
                        return False

                    if not TypeConvert.is_valid_netmask(netmask):
                        print "ipv4 invalid netmask"
                        return False

                    if not TypeConvert.is_valid_gw(address, netmask, gateway):
                        print "ipv4 invalid gateway"
                        return False

            if "dns" in info_dict["ipv4"].keys() and len(info_dict["ipv4"]["dns"]) > 0:
                for dns in info_dict["ipv4"]["dns"]:
                    if not TypeConvert.is_valid_ip4(TypeConvert.ip4_net2native(dns)):
                        print "ipv4 invalid dns"
                        return False
        return True
开发者ID:martyr-deepin,项目名称:deepin-system-settings,代码行数:28,代码来源:nmconnection.py

示例9: check_setting_commit

    def check_setting_commit(self):
        ###delete invalid setting property before update
        for key in self.settings_dict.keys():
            for key2 in self.settings_dict[key]:
                if self.settings_dict[key][key2] == None:
                    self.settings_dict[key][key2] = ""

        info_dict = TypeConvert.dbus2py(self.settings_dict)
        try:
            if info_dict["connection"]["type"] == "802-3-ethernet":
                if not self.get_setting("802-3-ethernet").wired_valid():
                    ###or raise exception
                    return False
                self.get_setting("ipv4").adapt_ip4config_commit()

                if "ipv6" in info_dict.iterkeys():
                    self.get_setting("ipv6").adapt_ip6config_commit()

            elif info_dict["connection"]["type"] == "802-11-wireless":
                self.get_setting("802-11-wireless").adapt_wireless_commit()

                if "802-11-wireless-security" in info_dict.iterkeys():
                    self.get_setting("802-11-wireles-security").adapt_wireless_security_commit()

                self.get_setting("ipv4").adapt_ip4config_commit()

                if "ipv6" in info_dict.iterkeys():
                    self.get_setting("ipv6").adapt_ip6config_commit()

            elif info_dict["connection"]["type"] == "pppoe":
                if not self.get_setting("802-3-ethernet").wired_valid():
                    return False
                self.get_setting("ipv4").adapt_ip4config_commit()

                if "ipv6" in info_dict.iterkeys():
                    self.get_setting("ipv6").adapt_ip6config_commit()

            elif info_dict["connection"]["type"] == "vpn":
                pass

            elif info_dict["connection"]["type"] == "cdma":
                pass

            elif info_dict["connection"]["type"] == "gsm":
                pass

            else:
                print "invalid connection_type"
        except:
            pass
开发者ID:martyr-deepin,项目名称:deepin-system-settings,代码行数:50,代码来源:nmconnection.py

示例10: entry_changed

 def entry_changed(self, widget, content, types):
     is_valid = True
     if types == "ssid":
         setattr(self.wireless, types, content)
     else:
         from nmlib.nm_utils import TypeConvert
         if (content == "") or TypeConvert.is_valid_mac_address(content):
             setattr(self.wireless, types, content)
             #check_settings(self.connection, self.set_button)
             is_valid = self.connection.check_setting_finish()
         else:
             is_valid = False
             #Dispatcher.set_button("save", False)
     self.settings_obj.mac_is_valid = is_valid
     self.settings_obj.set_button("save", is_valid)
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:15,代码来源:wlan_config.py

示例11: save_settings

 def save_settings(self, widget, value, types):
     if type(value) is str:
         if (value == "") or TypeConvert.is_valid_mac_address(value):
             setattr(self.ethernet_setting, types, value)
             #if self.connection.check_setting_finish():
                 #Dispatcher.set_button("save", True)
             is_valid = self.connection.check_setting_finish()
         else:
             is_valid = False
             #Dispatcher.set_button("save", False)
         self.settings_obj.mac_is_valid = is_valid
         if not self._init:
             self.settings_obj.set_button("save", is_valid)
     else:
         setattr(self.ethernet_setting, types, value)
         if self.connection.check_setting_finish() and not self._init:
             Dispatcher.set_button("save", True)
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:17,代码来源:dsl_config.py

示例12: set_dns_address

    def set_dns_address(self, widget, content, index):
        self.dns[index] = content
        names = ["master", "slaver"]
        dns = self.check_complete_dns()
        if dns:
            is_valid = True
            self.setting.clear_dns()
            for d in dns:
                self.setting.add_dns(d)
        else:
            is_valid = False
            self.setting.clear_dns()

        if TypeConvert.is_valid_ip6(content):
            setattr(self, names[index] + "_flag", True)
        else:
            setattr(self, names[index] + "_flag", False)

        ############
        # 检查dns
        if self.settings_obj:
            self.settings_obj.ipv6_dns_is_valid = is_valid
            self.settings_obj.set_button("save", is_valid)
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:23,代码来源:ipsettings.py

示例13: id

 def id(self):
     if "id" in self.prop_dict.iterkeys():
         return TypeConvert.dbus2py(self.prop_dict["id"])
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:3,代码来源:nmsetting_connection.py

示例14: autoconnect

 def autoconnect(self, new_autoconnect):
     self.prop_dict["autoconnect"] = TypeConvert.py2_dbus_boolean(new_autoconnect)
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:2,代码来源:nmsetting_connection.py

示例15: permissions

 def permissions(self, new_permissions):
     self.prop_dict["permissions"] = TypeConvert.py2_dbus_array(new_permissions)
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:2,代码来源:nmsetting_connection.py


注:本文中的nmlib.nm_utils.TypeConvert类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。