diff --git a/zenmap/zenmapGUI/ScanInterface.py b/zenmap/zenmapGUI/ScanInterface.py index 67ecec11f..bfd2874bb 100644 --- a/zenmap/zenmapGUI/ScanInterface.py +++ b/zenmap/zenmapGUI/ScanInterface.py @@ -550,42 +550,48 @@ class ScanInterface(HIGVBox): try: command_execution.run_scan() - except Exception, e: - text = unicode(e.message, errors='replace') - if isinstance(e, OSError): - # Handle ENOENT specially. - if e.errno == errno.ENOENT: - # nmap_command_path comes from zenmapCore.NmapCommand. - path_env = os.getenv("PATH") - if path_env is None: - default_paths = [] - else: - fsencoding = sys.getfilesystemencoding() - if fsencoding: - path_env = path_env.decode(fsencoding, 'replace') - default_paths = path_env.split(os.pathsep) - text += u"\n\n{}\n\n{}".format( - _("This means that the nmap executable was " - "not found in your system PATH, which is"), - path_env or _("") - ) - 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 += u"\n\n" + _("plus the extra directory") - else: - text += u"\n\n" + _("plus the extra directories") - text += u"\n\n" + os.pathsep.join(extra_paths) + except OSError, e: + text = unicode(e.strerror, errors='replace') + # Handle ENOENT specially. + if e.errno == errno.ENOENT: + # nmap_command_path comes from zenmapCore.NmapCommand. + path_env = os.getenv("PATH") + if path_env is None: + default_paths = [] else: - text += u" (%d)" % e.errno + fsencoding = sys.getfilesystemencoding() + if fsencoding: + path_env = path_env.decode(fsencoding, 'replace') + default_paths = path_env.split(os.pathsep) + text += u"\n\n{}\n\n{}".format( + _("This means that the nmap executable was " + "not found in your system PATH, which is"), + path_env or _("") + ) + 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 += u"\n\n" + _("plus the extra directory") + else: + text += u"\n\n" + _("plus the extra directories") + text += u"\n\n" + os.pathsep.join(extra_paths) + else: + text += u" (%d)" % e.errno warn_dialog = HIGAlertDialog( message_format=_("Error executing command"), secondary_text=text, type=gtk.MESSAGE_ERROR) warn_dialog.run() warn_dialog.destroy() return + except Exception, e: + warn_dialog = HIGAlertDialog( + message_format=_("Error executing command"), + secondary_text=unicode(e, errors='replace'), type=gtk.MESSAGE_ERROR) + warn_dialog.run() + warn_dialog.destroy() + return log.debug("Running command: %s" % command_execution.command) self.jobs.append(command_execution)