本文整理汇总了Python中zenmapGUI.higwidgets.higdialogs.HIGAlertDialog类的典型用法代码示例。如果您正苦于以下问题:Python HIGAlertDialog类的具体用法?Python HIGAlertDialog怎么用?Python HIGAlertDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HIGAlertDialog类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: refresh_diff
def refresh_diff(self, widget):
"""This method is called whenever the diff output might have changed,
such as when a different scan was selected in one of the choosers."""
log.debug("Refresh diff.")
if (self.ndiff_process is not None and
self.ndiff_process.poll() is None):
# Put this in the list of old processes we keep track of.
self.old_processes.append(self.ndiff_process)
self.ndiff_process = None
scan_a = self.scan_chooser_a.parsed_scan
scan_b = self.scan_chooser_b.parsed_scan
if scan_a is None or scan_b is None:
self.diff_view.clear()
else:
try:
self.ndiff_process = zenmapCore.Diff.ndiff(scan_a, scan_b)
except OSError, e:
alert = HIGAlertDialog(
message_format=_("Error running ndiff"),
secondary_text=_(
"There was an error running the ndiff program.\n\n"
) + str(e).decode(sys.getdefaultencoding(), "replace"))
alert.run()
alert.destroy()
else:
示例2: open_file
def open_file(self, widget):
file_chooser = ResultsFileSingleChooserDialog(_("Select Scan Result"))
response = file_chooser.run()
file_chosen = file_chooser.get_filename()
file_chooser.destroy()
if response == gtk.RESPONSE_OK:
try:
parser = NmapParser()
parser.parse_file(file_chosen)
except xml.sax.SAXParseException, e:
alert = HIGAlertDialog(
message_format='<b>%s</b>' % _('Error parsing file'),
secondary_text=_(
"The file is not an Nmap XML output file. "
"The parsing error that occurred was\n%s") % str(e))
alert.run()
alert.destroy()
return False
except Exception, e:
alert = HIGAlertDialog(
message_format='<b>%s</b>' % _(
'Cannot open selected file'),
secondary_text=_("""\
This error occurred while trying to open the file:
%s""") % str(e))
alert.run()
alert.destroy()
return False
示例3: excepthook
def excepthook(type, value, tb):
import traceback
traceback.print_exception(type, value, tb)
# Cause an exception if PyGTK can't open a display. Normally this just
# produces a warning, but the lack of a display eventually causes a
# segmentation fault. See http://live.gnome.org/PyGTK/WhatsNew210.
import warnings
warnings.filterwarnings("error", module="gtk")
import gtk
warnings.resetwarnings()
gtk.gdk.threads_enter()
from zenmapGUI.higwidgets.higdialogs import HIGAlertDialog
from zenmapGUI.CrashReport import CrashReport
if type == ImportError:
d = HIGAlertDialog(type=gtk.MESSAGE_ERROR,
message_format=_("Import error"),
secondary_text=_("""A required module was not found.
""" + unicode(value)))
d.run()
d.destroy()
else:
c = CrashReport(type, value, tb)
c.show_all()
gtk.main()
gtk.gdk.threads_leave()
gtk.main_quit()
示例4: run
def run():
if os.name == "posix":
signal.signal(signal.SIGHUP, safe_shutdown)
signal.signal(signal.SIGTERM, safe_shutdown)
signal.signal(signal.SIGINT, safe_shutdown)
DEVELOPMENT = os.environ.get(APP_NAME.upper() + "_DEVELOPMENT", False)
if not DEVELOPMENT:
install_excepthook()
zenmapCore.I18N.install_gettext(Path.locale_dir)
try:
# Create the ~/.zenmap directory by copying from the system-wide
# template directory.
zenmapCore.Paths.create_user_config_dir(Path.user_config_dir, Path.config_dir)
except (IOError, OSError), e:
error_dialog = HIGAlertDialog(message_format = _("Error creating the per-user configuration directory"),
secondary_text = _("""\
There was an error creating the directory %s or one of the files in it. \
The directory is created by copying the contents of %s. \
The specific error was\n\
\n\
%s\n\
\n\
%s needs to create this directory to store information such as the list of \
scan profiles. Check for access to the directory and try again.\
""") % (repr(Path.user_config_dir), repr(Path.config_dir), repr(str(e)), APP_DISPLAY_NAME))
error_dialog.run()
error_dialog.destroy()
sys.exit(1)
示例5: execute_command
def execute_command(self, command, target = None, profile = None):
"""Run the given Nmap command. Add it to the list of running scans.
Schedule a timer to refresh the output and check the scan for
completion."""
command_execution = NmapCommand(command)
command_execution.profile = profile
try:
command_execution.run_scan()
except Exception, e:
text = str(e)
if isinstance(e, OSError):
# Handle ENOENT specially.
if e.errno == errno.ENOENT:
# nmap_command_path comes from zenmapCore.NmapCommand.
text += "\n\n" + _("This means that the nmap executable was not found in your system PATH, which is") + "\n\n" + os.getenv("PATH", _("<undefined>"))
path_env = os.getenv("PATH")
if path_env is None:
default_paths = []
else:
default_paths = path_env.split(os.pathsep)
extra_paths = get_extra_executable_search_paths()
extra_paths = [p for p in extra_paths if p not in default_paths]
if len(extra_paths) > 0:
if len(extra_paths) == 1:
text += "\n\n" + _("plus the extra directory")
else:
text += "\n\n" + _("plus the extra directories")
text += "\n\n" + os.pathsep.join(extra_paths)
warn_dialog = HIGAlertDialog(message_format=_("Error executing command"),
secondary_text=text, type=gtk.MESSAGE_ERROR)
warn_dialog.run()
warn_dialog.destroy()
return
示例6: __init__
def __init__(self):
warning_text = _('''You are trying to run %s with a non-root user!
Some %s options need root privileges to work.''') % (
APP_DISPLAY_NAME, NMAP_DISPLAY_NAME)
HIGAlertDialog.__init__(self, message_format=_('Non-root user'),
secondary_text=warning_text)
示例7: check_ndiff_process
def check_ndiff_process(self):
"""Check if the ndiff subprocess is done and show the diff if it is.
Also remove any finished processes from the old process list."""
# Check if any old background processes have finished.
for p in self.old_processes[:]:
if p.poll() is not None:
p.close()
self.old_processes.remove(p)
if self.ndiff_process is not None:
# We're running the most recent scan. Check if it's done.
status = self.ndiff_process.poll()
if status is None:
# Keep calling this function on a timer until the process
# finishes.
self.progress.pulse()
return True
if status == 0 or status == 1:
# Successful completion.
try:
diff = self.ndiff_process.get_scan_diff()
except zenmapCore.Diff.NdiffParseException as e:
alert = HIGAlertDialog(
message_format=_("Error parsing ndiff output"),
secondary_text=str(e))
alert.run()
alert.destroy()
else:
self.diff_view.show_diff(diff)
else:
# Unsuccessful completion.
error_text = _(
"The ndiff process terminated with status code %d."
) % status
stderr = self.ndiff_process.stderr.read()
if len(stderr) > 0:
error_text += "\n\n" + stderr
alert = HIGAlertDialog(
message_format=_("Error running ndiff"),
secondary_text=error_text)
alert.run()
alert.destroy()
self.progress.hide()
self.ndiff_process.close()
self.ndiff_process = None
if len(self.old_processes) > 0:
# Keep calling this callback.
return True
else:
# All done.
self.timer_id = None
return False
示例8: execute_command
def execute_command(self, command, target=None, profile=None):
"""Run the given Nmap command. Add it to the list of running scans.
Schedule a timer to refresh the output and check the scan for
completion."""
try:
command_execution = NmapCommand(command)
except IOError, e:
warn_dialog = HIGAlertDialog(
message_format=_("Error building command"),
secondary_text=_("Error message: %s") % str(e),
type=gtk.MESSAGE_ERROR)
warn_dialog.run()
warn_dialog.destroy()
return
示例9: save_profile
def save_profile(self, widget):
if self.overwrite:
self.profile.remove_profile(self.profile_name)
profile_name = self.profile_name_entry.get_text()
if profile_name == "":
alert = HIGAlertDialog(
message_format=_("Unnamed profile"),
secondary_text=_(
"You must provide a name \
for this profile."
),
)
alert.run()
alert.destroy()
self.profile_name_entry.grab_focus()
return None
command = self.ops.render_string()
buf = self.profile_description_text.get_buffer()
description = buf.get_text(buf.get_start_iter(), buf.get_end_iter())
try:
self.profile.add_profile(profile_name, command=command, description=description)
except ValueError:
alert = HIGAlertDialog(
message_format=_("Disallowed profile name"),
secondary_text=_(
'Sorry, the name "%s" \
is not allowed due to technical limitations. (The underlying ConfigParser \
used to store profiles does not allow it.) Choose a different \
name.'
% profile_name
),
)
alert.run()
alert.destroy()
return
self.scan_interface.toolbar.profile_entry.update()
self.destroy()
示例10: __response_cb
def __response_cb(self, widget, response_id):
"""Intercept the "response" signal to check if someone used the "By
extension" file type with an unknown extension."""
if response_id == gtk.RESPONSE_OK and self.get_filetype() is None:
ext = self.__get_extension()
if ext == "":
filename = self.get_filename() or ""
dir, basename = os.path.split(filename)
alert = HIGAlertDialog(
message_format=_("No filename extension"),
secondary_text=_("""\
The filename "%s" does not have an extension, \
and no specific file type was chosen.
Enter a known extension or select the file type from the list.""" % basename))
else:
alert = HIGAlertDialog(
message_format=_("Unknown filename extension"),
secondary_text=_("""\
There is no file type known for the filename extension "%s".
Enter a known extension or select the file type from the list.\
""") % self.__get_extension())
alert.run()
alert.destroy()
# Go back to the dialog.
self.emit_stop_by_name("response")
示例11: get_extra_executable_search_paths
path_env = os.getenv("PATH")
if path_env is None:
default_paths = []
else:
default_paths = path_env.split(os.pathsep)
extra_paths = get_extra_executable_search_paths()
extra_paths = [p for p in extra_paths if (
p not in default_paths)]
if len(extra_paths) > 0:
if len(extra_paths) == 1:
text += "\n\n" + _("plus the extra directory")
else:
text += "\n\n" + _("plus the extra directories")
text += "\n\n" + os.pathsep.join(extra_paths)
warn_dialog = HIGAlertDialog(
message_format=_("Error executing command"),
secondary_text=text, type=gtk.MESSAGE_ERROR)
warn_dialog.run()
warn_dialog.destroy()
return
log.debug("Running command: %s" % command_execution.command)
self.jobs.append(command_execution)
i = self.scans_store.add_running_scan(command_execution)
self.scan_result.scan_result_notebook.nmap_output.set_active_iter(i)
# When scan starts, change to nmap output view tab and refresh output
self.scan_result.change_to_nmap_output_tab()
self.scan_result.refresh_nmap_output()
示例12: HIGAlertDialog
error_dialog.destroy()
sys.exit(1)
try:
# Read the ~/.zenmap/zenmap.conf configuration file.
zenmapCore.UmitConf.config_parser.read(Path.user_config_file)
except ConfigParser.ParsingError, e:
# ParsingError can leave some values as lists instead of strings. Just
# blow it all away if we have this problem.
zenmapCore.UmitConf.config_parser = zenmapCore.UmitConf.config_parser.__class__()
error_dialog = HIGAlertDialog(
message_format=_("Error parsing the configuration file"),
secondary_text=_("""\
There was an error parsing the configuration file %s. \
The specific error was
%s
%s can continue without this file but any information in it will be ignored \
until it is repaired.""") % (Path.user_config_file, str(e), APP_DISPLAY_NAME)
)
error_dialog.run()
error_dialog.destroy()
global_config_path = os.path.join(Path.config_dir, APP_NAME + '.conf')
repair_dialog = HIGAlertDialog(
type=gtk.MESSAGE_QUESTION,
message_format=_("Restore default configuration?"),
secondary_text=_("""\
To avoid further errors parsing the configuration file %s, \
you can copy the default configuration from %s.
示例13: repr
%s needs to create this directory to store information such as the list of \
scan profiles. Check for access to the directory and try again.\
""") % (repr(Path.user_config_dir), repr(Path.config_dir), repr(str(e)), APP_DISPLAY_NAME))
error_dialog.run()
error_dialog.destroy()
sys.exit(1)
try:
# Read the ~/.zenmap/zenmap.conf configuration file.
zenmapCore.UmitConf.config_parser.read(Path.user_config_file)
except ConfigParser.ParsingError, e:
error_dialog = HIGAlertDialog(message_format = _("Error parsing the configuration file"),
secondary_text = _("""\
There was an error parsing the configuration file %s. \
The specific error was\n\
\n\
%s\n\
\n\
%s can continue without this file but any information in it will be ignored \
until it is repaired.\
""") % (Path.user_config_file, str(e), APP_DISPLAY_NAME))
error_dialog.run()
error_dialog.destroy()
# Display a "you're not root" warning if appropriate.
if not is_root():
non_root = NonRootWarning()
non_root.run()
non_root.destroy()
# Load files given as command-line arguments.
filenames = option_parser.get_open_results()