diff --git a/nping/nping-dev/ipv6fp.py b/nping/nping-dev/ipv6fp.py index b21dbdd36..9e951bb6f 100755 --- a/nping/nping-dev/ipv6fp.py +++ b/nping/nping-dev/ipv6fp.py @@ -252,7 +252,7 @@ def print_received_packet(packet): try: packet.show(label_lvl=" ") hexdump(packet) - except: + except Exception: return return diff --git a/zenmap/radialnet/gui/Application.py b/zenmap/radialnet/gui/Application.py index 125a5203a..4a76b3aa6 100644 --- a/zenmap/radialnet/gui/Application.py +++ b/zenmap/radialnet/gui/Application.py @@ -200,9 +200,9 @@ class Application(BWMainWindow): self.__parser = XMLReader(file) self.__parser.parse() - except: + except Exception as e: - text = 'It is not possible open file: %s.' % file + text = 'It is not possible open file %s: %s' % (file, e) alert = BWAlertDialog(self, primary_text='Error opening file.', diff --git a/zenmap/zenmapCore/NetworkInventory.py b/zenmap/zenmapCore/NetworkInventory.py index f0ad98510..a0bc38a28 100644 --- a/zenmap/zenmapCore/NetworkInventory.py +++ b/zenmap/zenmapCore/NetworkInventory.py @@ -648,7 +648,7 @@ class NetworkInventoryTest(unittest.TestCase): inv.add_scan(scan_2) try: inv.remove_scan(scan_3) - except: + except Exception: pass self.assertEqual(added_ips, inv.hosts.keys()) self.assertEqual(host_a.hostnames, ["a"]) diff --git a/zenmap/zenmapCore/NmapCommand.py b/zenmap/zenmapCore/NmapCommand.py index 4763ce628..d97bc9ba7 100644 --- a/zenmap/zenmapCore/NmapCommand.py +++ b/zenmap/zenmapCore/NmapCommand.py @@ -274,14 +274,14 @@ class NmapCommand(object): log.debug(">>> SIGTERM has not worked even after waiting for 5 seconds. Using SIGKILL.") # noqa os.kill(self.command_process.pid, SIGKILL) self.command_process.wait() - except: + except Exception: pass else: try: import ctypes ctypes.windll.kernel32.TerminateProcess( int(self.command_process._handle), -1) - except: + except Exception: pass def get_path(self): diff --git a/zenmap/zenmapCore/Paths.py b/zenmap/zenmapCore/Paths.py index 26f0dcb90..f99873cd1 100644 --- a/zenmap/zenmapCore/Paths.py +++ b/zenmap/zenmapCore/Paths.py @@ -238,7 +238,7 @@ class Paths(object): try: return self.__dict__[name] - except: + except Exception: raise NameError(name) def __setattr__(self, name, value): diff --git a/zenmap/zenmapCore/RecentScans.py b/zenmap/zenmapCore/RecentScans.py index 977713405..eaeeda51a 100644 --- a/zenmap/zenmapCore/RecentScans.py +++ b/zenmap/zenmapCore/RecentScans.py @@ -137,7 +137,7 @@ class RecentScans(object): try: self.recent_scans_file = Path.recent_scans - except: + except Exception: self.recent_scans_file = False if (self.recent_scans_file and diff --git a/zenmap/zenmapCore/SearchResult.py b/zenmap/zenmapCore/SearchResult.py index 08ec8b947..0f0df22c7 100644 --- a/zenmap/zenmapCore/SearchResult.py +++ b/zenmap/zenmapCore/SearchResult.py @@ -552,7 +552,7 @@ class SearchDir(SearchResult, object): try: parsed = NmapParser() parsed.parse_file(scan_file) - except: + except Exception: pass else: self.scan_results.append(parsed) diff --git a/zenmap/zenmapCore/TargetList.py b/zenmap/zenmapCore/TargetList.py index 08fba320f..a1261e41e 100644 --- a/zenmap/zenmapCore/TargetList.py +++ b/zenmap/zenmapCore/TargetList.py @@ -137,7 +137,7 @@ class TargetList(object): try: self.target_list_file = Path.target_list - except: + except Exception: self.target_list_file = False #import pdb; pdb.set_trace() diff --git a/zenmap/zenmapCore/UmitConf.py b/zenmap/zenmapCore/UmitConf.py index d4932ddd8..9cba452d7 100644 --- a/zenmap/zenmapCore/UmitConf.py +++ b/zenmap/zenmapCore/UmitConf.py @@ -229,7 +229,7 @@ class SearchConfig(UmitConfigParser, object): def get_converted_save_time(self): try: return int(self.save_time[0]) * self.time_list[self.save_time[1]] - except: + except Exception: # If something goes wrong, return a save time of 60 days return 60 * 60 * 24 * 60 @@ -307,7 +307,7 @@ class Profile(UmitConfigParser, object): def remove_profile(self, profile_name): try: self.remove_section(profile_name) - except: + except Exception: pass self.save_changes() @@ -470,7 +470,7 @@ class NmapOutputHighlight(object): return self.sanity_settings([ config_parser.get( property_name, prop, True) for prop in self.setts]) - except: + except Exception: settings = [] prop_settings = self.default_highlights[p_name] settings.append(prop_settings["bold"]) diff --git a/zenmap/zenmapCore/UmitDB.py b/zenmap/zenmapCore/UmitDB.py index 567bfdf05..c3111d52b 100644 --- a/zenmap/zenmapCore/UmitDB.py +++ b/zenmap/zenmapCore/UmitDB.py @@ -155,7 +155,7 @@ umitdb = "" try: umitdb = Path.db -except: +except Exception: import os.path from BasePaths import base_paths @@ -268,7 +268,7 @@ class UmitDB(object): try: self.cursor.execute(drop_string) - except: + except Exception: connection.rollback() else: connection.commit() diff --git a/zenmap/zenmapGUI/FileChoosers.py b/zenmap/zenmapGUI/FileChoosers.py index d379166f2..ea6f45fa8 100644 --- a/zenmap/zenmapGUI/FileChoosers.py +++ b/zenmap/zenmapGUI/FileChoosers.py @@ -179,7 +179,7 @@ class UnicodeFileChooserDialog(gtk.FileChooserDialog): encoding = sys.getfilesystemencoding() or "UTF-8" try: filename = filename.decode(encoding) - except: + except Exception: pass return filename diff --git a/zenmap/zenmapGUI/MainWindow.py b/zenmap/zenmapGUI/MainWindow.py index aeddc0a1f..019830135 100644 --- a/zenmap/zenmapGUI/MainWindow.py +++ b/zenmap/zenmapGUI/MainWindow.py @@ -246,7 +246,7 @@ class ScanWindow(UmitScanWindow): # gtk.STOCK_ABOUT is only available in PyGTK 2.6 and later. try: about_icon = gtk.STOCK_ABOUT - except: + except AttributeError: about_icon = None self.main_actions = [ diff --git a/zenmap/zenmapGUI/NmapOutputViewer.py b/zenmap/zenmapGUI/NmapOutputViewer.py index e128f3bab..75d767c83 100644 --- a/zenmap/zenmapGUI/NmapOutputViewer.py +++ b/zenmap/zenmapGUI/NmapOutputViewer.py @@ -321,7 +321,7 @@ class NmapOutputViewer (gtk.VBox): buf = self.text_view.get_buffer() try: running = (command is not None and command.scan_state() is True) - except: + except Exception: running = False complete = False else: diff --git a/zenmap/zenmapGUI/ScanHostsView.py b/zenmap/zenmapGUI/ScanHostsView.py index f90a61371..9b8ab50d9 100644 --- a/zenmap/zenmapGUI/ScanHostsView.py +++ b/zenmap/zenmapGUI/ScanHostsView.py @@ -235,7 +235,7 @@ class ScanHostsView(HIGVBox, object): try: child = self.scrolled.get_child() self.scrolled.remove(child) - except: + except Exception: pass def _set_scrolled(self): diff --git a/zenmap/zenmapGUI/ScanInterface.py b/zenmap/zenmapGUI/ScanInterface.py index c66ff961e..c9d114242 100644 --- a/zenmap/zenmapGUI/ScanInterface.py +++ b/zenmap/zenmapGUI/ScanInterface.py @@ -618,8 +618,8 @@ class ScanInterface(HIGVBox): alive = scan.scan_state() if alive: continue - except: - log.debug("Scan terminated unexpectedly: %s" % scan.command) + except Exception as e: + log.debug("Scan terminated unexpectedly: %s (%s)" % (scan.command, e)) self.scans_store.fail_running_scan(scan) else: log.debug("Scan finished: %s" % scan.command) @@ -650,7 +650,7 @@ class ScanInterface(HIGVBox): # Some options like --iflist cause Nmap to emit an empty XML # file. Ignore the exception in this case. st = os.stat(command.get_xml_output_filename()) - except: + except Exception: st = None if st is None or st.st_size > 0: warn_dialog = HIGAlertDialog( diff --git a/zenmap/zenmapGUI/ScriptInterface.py b/zenmap/zenmapGUI/ScriptInterface.py index 7625f947d..b22f288f1 100644 --- a/zenmap/zenmapGUI/ScriptInterface.py +++ b/zenmap/zenmapGUI/ScriptInterface.py @@ -313,7 +313,7 @@ class ScriptInterface: def script_list_timer_callback(self, process, callback): try: status = process.scan_state() - except: + except Exception: status = None log.debug("Script interface: script_list_timer_callback %s" % repr(status)) diff --git a/zenmap/zenmapGUI/higwidgets/higdialogs.py b/zenmap/zenmapGUI/higwidgets/higdialogs.py index 06c04fc62..51fcc66b9 100644 --- a/zenmap/zenmapGUI/higwidgets/higdialogs.py +++ b/zenmap/zenmapGUI/higwidgets/higdialogs.py @@ -180,7 +180,7 @@ class HIGAlertDialog(gtk.MessageDialog): # GTK up to version 2.4 does not have secondary_text try: self.format_secondary_text(secondary_text) - except: + except Exception: pass