本文整理汇总了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
示例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)
"""
示例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)
示例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)
示例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