From 862c65ae8b162fff3523a98564dd73ecfe487dcf Mon Sep 17 00:00:00 2001 From: Sean Robinson Date: Mon, 1 Jun 2009 05:15:19 -0700 Subject: [PATCH] BUG FIX: catch error and report missing iwconfig command Part of series to fix bug 15787. Signed-off-by: Sean Robinson --- wifi-radar | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/wifi-radar b/wifi-radar index 5c810fb..81e682e 100755 --- a/wifi-radar +++ b/wifi-radar @@ -643,7 +643,12 @@ class ConnectionManager(): # string or None -- the ESSID or None (if no there is no current association) def get_current_essid( self ): """Returns the current ESSID if any by calling iwconfig""" - iwconfig_info = Popen([self.confFile.get_opt('DEFAULT.iwconfig_command'), get_network_device(self.confFile.get_opt('DEFAULT.interface'))], stdout=PIPE, stderr=STDOUT).stdout + try: + iwconfig_info = Popen([self.confFile.get_opt('DEFAULT.iwconfig_command'), get_network_device(self.confFile.get_opt('DEFAULT.interface'))], stdout=PIPE, stderr=STDOUT).stdout + except OSError, (errno, strerror): + if errno == 2: + logger.critical("iwconfig command not found, please set this in the preferences.") + iwconfig_info = open("/dev/null", "r") # Be careful to the language (inet adr: in French for example) essid_re = re.compile( "ESSID\s*(:|=)\s*\"([^\"]+)\"", re.I | re.M | re.S ) line = iwconfig_info.read() @@ -662,7 +667,12 @@ class ConnectionManager(): # string or None -- the BSSID or None (if no there is no current association) def get_current_bssid( self ): """Returns the current BSSID if any by calling iwconfig""" - iwconfig_info = Popen([self.confFile.get_opt('DEFAULT.iwconfig_command'), get_network_device(self.confFile.get_opt('DEFAULT.interface'))], stdout=PIPE, stderr=STDOUT).stdout + try: + iwconfig_info = Popen([self.confFile.get_opt('DEFAULT.iwconfig_command'), get_network_device(self.confFile.get_opt('DEFAULT.interface'))], stdout=PIPE, stderr=STDOUT).stdout + except OSError, (errno, strerror): + if errno == 2: + logger.critical("iwconfig command not found, please set this in the preferences.") + iwconfig_info = open("/dev/null", "r") bssid_re = re.compile( "Access Point\s*(:|=)\s*([a-zA-Z0-9:]+)", re.I | re.M | re.S ) line = iwconfig_info.read() if bssid_re.search( line ): @@ -1649,7 +1659,12 @@ class preferences_dialog: # network interface selecter self.w_interface = gtk.combo_box_entry_new_text() - iwconfig_info = Popen([self.confFile.get_opt('DEFAULT.iwconfig_command')], stdout=PIPE, stderr=STDOUT).stdout + try: + iwconfig_info = Popen([self.confFile.get_opt('DEFAULT.iwconfig_command')], stdout=PIPE, stderr=STDOUT).stdout + except OSError, (errno, strerror): + if errno == 2: + logger.critical("iwconfig command not found, please set this in the preferences.") + iwconfig_info = "" wireless_devices = [ (x[0:x.find(" ")]) for x in iwconfig_info if ("ESSID" in x)] for device in wireless_devices: if device != self.confFile.get_opt('DEFAULT.interface'): -- 2.11.4.GIT