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


Python TypeConvert.is_valid_mac_address方法代码示例

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


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

示例1: is_wired_setting_ok

# 需要导入模块: from nmlib.nm_utils import TypeConvert [as 别名]
# 或者: from nmlib.nm_utils.TypeConvert import is_valid_mac_address [as 别名]
    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,代码行数:31,代码来源:nmconnection.py

示例2: save_settings

# 需要导入模块: from nmlib.nm_utils import TypeConvert [as 别名]
# 或者: from nmlib.nm_utils.TypeConvert import is_valid_mac_address [as 别名]
    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,代码行数:42,代码来源:lan_config.py

示例3: entry_changed

# 需要导入模块: from nmlib.nm_utils import TypeConvert [as 别名]
# 或者: from nmlib.nm_utils.TypeConvert import is_valid_mac_address [as 别名]
 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,代码行数:17,代码来源:wlan_config.py

示例4: save_settings

# 需要导入模块: from nmlib.nm_utils import TypeConvert [as 别名]
# 或者: from nmlib.nm_utils.TypeConvert import is_valid_mac_address [as 别名]
 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,代码行数:19,代码来源:dsl_config.py

示例5: is_wireless_setting_ok

# 需要导入模块: from nmlib.nm_utils import TypeConvert [as 别名]
# 或者: from nmlib.nm_utils.TypeConvert import is_valid_mac_address [as 别名]
    def is_wireless_setting_ok(self, info_dict):
        if info_dict["connection"]["type"] != "802-11-wireless":
            return False
        else:
            if not self.check_conn_setting(info_dict):
                return False

            if not self.check_ip4_setting(info_dict):
                return False

            if "802-11-wireless" not in info_dict.keys():
                print "missing 802-11-wireless setting "
                return False

            if len(info_dict["802-11-wireless"]["ssid"]) == 0:
                print "wireless invalid ssid"
                return False

            if "mode" in info_dict["802-11-wireless"].keys():
                if info_dict["802-11-wireless"]["mode"] not in ["infrastructure", "ad-hoc", "ap"]:
                    print "wireless invalid mode"
                    return False

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

            if "802-11-wireless-security" in info_dict.iterkeys():
                if info_dict["802-11-wireless-security"]["key-mgmt"] == "none":
                    ####wep
                    if "wep-tx-keyidx" in info_dict["802-11-wireless-security"].iterkeys():
                        if info_dict["802-11-wireless-security"]["wep-tx-keyidx"] == 0:
                            if not info_dict["802-11-wireless-security"]["wep-key0"]:
                                print "wireless invalid wep-key0"
                                return False

                        elif info_dict["802-11-wireless-security"]["wep-tx-keyidx"] == 1:
                            if not info_dict["802-11-wireless-security"]["wep-key1"]:
                                print "wireless invalid wep-key1"
                                return False

                        elif info_dict["802-11-wireless-security"]["wep-tx-keyidx"] == 2:
                            if not info_dict["802-11-wireless-security"]["wep-key2"]:
                                print "wireless invalid wep-key2"
                                return False

                        elif info_dict["802-11-wireless-security"]["wep-tx-keyidx"] == 3:
                            if not info_dict["802-11-wireless-security"]["wep-key3"]:
                                print "wireless invalid wep-key3"
                                return False
                        else:
                            print "wireless invalid wep tx keyidx"
                            return False
                    else:
                        if not info_dict["802-11-wireless-security"]["wep-key0"]:
                            print "wireless invalid wep-key0"
                            return False
                    ###psk
                elif info_dict["802-11-wireless-security"]["key-mgmt"] == "wpa-psk":
                    if not info_dict["802-11-wireless-security"]["psk"]:
                        print "wireless invalid psk"
                        return False

                elif info_dict["802-11-wireless-security"]["key-mgmt"] == "ieee8021x":
                    print "wireless currently doesn't support ieee8021x"
                    return False

                elif info_dict["802-11-wireless-security"]["key-mgmt"] == "wpa-eap":
                    print "wireless currently not support wpa-eap"
                    return False
                else:
                    print "wireless invalid security method"
                    return False

        return True
开发者ID:martyr-deepin,项目名称:deepin-system-settings,代码行数:80,代码来源:nmconnection.py


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