本文整理匯總了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()