本文整理汇总了Python中GLIUtility.is_hostname方法的典型用法代码示例。如果您正苦于以下问题:Python GLIUtility.is_hostname方法的具体用法?Python GLIUtility.is_hostname怎么用?Python GLIUtility.is_hostname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLIUtility
的用法示例。
在下文中一共展示了GLIUtility.is_hostname方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_mount
# 需要导入模块: import GLIUtility [as 别名]
# 或者: from GLIUtility import is_hostname [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()
示例2: populate_exports
# 需要导入模块: import GLIUtility [as 别名]
# 或者: from GLIUtility import is_hostname [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()