本文整理匯總了Python中GLIUtility.is_ip方法的典型用法代碼示例。如果您正苦於以下問題:Python GLIUtility.is_ip方法的具體用法?Python GLIUtility.is_ip怎麽用?Python GLIUtility.is_ip使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類GLIUtility
的用法示例。
在下文中一共展示了GLIUtility.is_ip方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: set_network_netmask
# 需要導入模塊: import GLIUtility [as 別名]
# 或者: from GLIUtility import is_ip [as 別名]
def set_network_netmask(self, xml_path, netmask, xml_attr=None):
if not GLIUtility.is_ip(netmask):
raise GLIException("IPAddressError", 'fatal','set_network_netmask', 'The specified netmask is not a valid IP Address!')
else:
# Need to guess the netmask... just in case (probably need the gateway..)
pass
self._network_netmask = netmask
示例2: update_mount
# 需要導入模塊: import GLIUtility [as 別名]
# 或者: from GLIUtility import is_ip [as 別名]
def update_mount(self, button, data=None):
if not GLIUtility.is_ip(self.mount_info_host.get_text()) and not GLIUtility.is_hostname(
self.mount_info_host.get_text()
):
msgdialog = Widgets.Widgets().error_Box(
"Invalid Host or IP", "You must specify a valid hostname or IP address"
)
result = msgdialog.run()
if result == gtk.RESPONSE_ACCEPT:
msgdialog.destroy()
return
if self.mount_info_export.get_child().get_text() == "":
msgdialog = Widgets.Widgets().error_Box("Invalid Entry", "You must enter a value for the export field")
result = msgdialog.run()
if result == gtk.RESPONSE_ACCEPT:
msgdialog.destroy()
return
if self.mount_info_mountpoint.get_text() == "":
msgdialog = Widgets.Widgets().error_Box("Invalid Entry", "You must enter a mountpoint")
result = msgdialog.run()
if result == gtk.RESPONSE_ACCEPT:
msgdialog.destroy()
return
if self.active_entry == -1:
self.netmounts.append(
{
"host": self.mount_info_host.get_text(),
"export": self.mount_info_export.get_child().get_text(),
"type": self.mount_types[self.mount_info_type.get_active()],
"mountpoint": self.mount_info_mountpoint.get_text(),
"mountopts": self.mount_info_mountopts.get_text(),
}
)
self.active_entry = -1
self.mount_button_update.set_sensitive(False)
self.mount_button_delete.set_sensitive(False)
self.mount_button_populate.set_sensitive(False)
else:
self.netmounts[self.active_entry]["host"] = self.mount_info_host.get_text()
self.netmounts[self.active_entry]["export"] = self.mount_info_export.get_child().get_text()
self.netmounts[self.active_entry]["type"] = self.mount_info_type.get_text()
self.netmounts[self.active_entry]["mountpoint"] = self.mount_info_mountpoint.get_text()
self.netmounts[self.active_entry]["mountopts"] = self.mount_info_mountopts.get_text()
self.refresh_list_at_top()
self.disable_all_fields()
示例3: populate_exports
# 需要導入模塊: import GLIUtility [as 別名]
# 或者: from GLIUtility import is_ip [as 別名]
def populate_exports(self, button, data=None):
host = self.mount_info_host.get_text()
oldtext = self.mount_info_export.get_child().get_text()
if GLIUtility.is_ip(host) or GLIUtility.is_hostname(host):
remotemounts = commands.getoutput(
"/usr/sbin/showmount -e " + host + " 2>&1 | egrep '^/' | cut -d ' ' -f 1 && echo"
)
mountlist = gtk.ListStore(gobject.TYPE_STRING)
self.mount_info_export.set_model(mountlist)
while remotemounts.find("\n") != -1:
index = remotemounts.find("\n") + 1
remotemount = remotemounts[:index]
remotemounts = remotemounts[index:]
remotemount = string.strip(remotemount)
mountlist.append([remotemount])
self.mount_info_export.get_child().set_text(oldtext)
else:
msgdialog = Widgets.Widgets().error_Box(
"Invalid Host or IP", "You must specify a valid hostname or IP address to scan for exports"
)
result = msgdialog.run()
if result == gtk.RESPONSE_ACCEPT:
msgdialog.destroy()
示例4: set_network_ip
# 需要導入模塊: import GLIUtility [as 別名]
# 或者: from GLIUtility import is_ip [as 別名]
def set_network_ip(self, xml_path, ip, xml_attr=None):
if not GLIUtility.is_ip(ip):
raise GLIException("IPAddressError", 'fatal', 'set_network_ip', 'The specified IP ' + ip + ' is not a valid IP Address!')
self._network_ip = ip
示例5: set_network_gateway
# 需要導入模塊: import GLIUtility [as 別名]
# 或者: from GLIUtility import is_ip [as 別名]
def set_network_gateway(self, xml_path, gateway, xml_attr=None):
if not GLIUtility.is_ip(gateway):
raise GLIException("IPAddressError", 'fatal', 'set_network_gateway', "The gateway IP provided is not a valid gateway!!")
self._network_gateway = gateway
示例6: set_network_broadcast
# 需要導入模塊: import GLIUtility [as 別名]
# 或者: from GLIUtility import is_ip [as 別名]
def set_network_broadcast(self, xml_path, broadcast, xml_attr=None):
if not GLIUtility.is_ip(broadcast):
raise GLIException("IPAddressError", 'fatal','set_network_broadcast', 'The specified broadcast is not a valid IP Address!')
self._network_broadcast = broadcast