diff --git a/gui.py b/gui.py index 1a359a2..577ca20 100644 --- a/gui.py +++ b/gui.py @@ -521,10 +521,10 @@ class WirelessSettingsDialog(AdvancedSettingsDialog): # Build the encryption menu activeID = -1 # Set the menu to this item when we are done - for x in self.encrypt_types: - self.combo_encryption.append_text(self.encrypt_types[x][0]) - if self.encrypt_types[x][1] == wireless.GetWirelessProperty(networkID, - "enctype"): + for x, enc_type in enumerate(self.encrypt_types): + self.combo_encryption.append_text(enc_type[0]) + if enc_type[1] == wireless.GetWirelessProperty(networkID, + "enctype"): activeID = x self.combo_encryption.set_active(activeID) if activeID != -1: @@ -1199,7 +1199,9 @@ class appGui: self.status_area.hide_all() - self.window.set_icon_from_file(wpath.etc + "wicd.png") + # self.window.set_icon_from_file(wpath.etc + "wicd.png") + if os.path.exists(wpath.etc + "wicd.png"): + self.window.set_icon_from_file(wpath.etc + "wicd.png") self.statusID = None self.first_dialog_load = True self.is_visible = True diff --git a/misc.py b/misc.py index b029b8d..c1e0907 100644 --- a/misc.py +++ b/misc.py @@ -189,24 +189,43 @@ def LoadEncryptionMethods(): loaded, the template must be listed in the "active" file. """ - encryptionTypes = {} - types = open("encryption/templates/active","r") - enctypes = types.readlines() + def parse_ent(line, key): + return line.replace(key, "").replace("=", "").strip() + + encryptionTypes = [] + try: + enctypes = open("encryption/templates/active","r").readlines() + except IOError, e: + print "Fatal Error: template index file is missing." + raise IOError(e) + + # Parse each encryption method for x in enctypes: - # Skip some lines, we don't care who the author is/was, etc - # we don't care about version either. - x = x.strip("\n") - current = open("encryption/templates/" + x,"r") - line = current.readlines() - # Get the length so we know where in the array to add data - typeID = len(encryptionTypes) - encryptionTypes[typeID] = {} - encryptionTypes[typeID][0] = line[0][7:].strip("\n") - encryptionTypes[typeID][1] = x - encryptionTypes[typeID][2] = {} - requiredFields = line[3][8:] - requiredFields = requiredFields.strip("\n") + x = x.strip() + try: + f = open("encryption/templates/" + x, "r") + except IOError: + print 'Failed to load encryption type ' + str(x) + continue + line = f.readlines() + f.close() + + cur_type = {} + cur_type[0] = parse_ent(line[0], "name") + cur_type[1] = x + cur_type[2] = {} + + # Find the line containing our required fields. + i = 1 + try: + while not line[i].startswith("require"): + i += 1 + except IndexError: + print "Bad encryption template: Couldn't find 'require' line" + requiredFields = parse_ent(line[i], "require") requiredFields = requiredFields.split(" ") + + # Get the required fields. index = -1 for current in requiredFields: # The pretty names will start with an * so we can @@ -214,13 +233,14 @@ def LoadEncryptionMethods(): if current[0] == "*": # Make underscores spaces # and remove the * - encryptionTypes[typeID][2][index][0] = current.replace("_", - " ").lstrip("*") + cur_type[2][index][0] = current.replace("_", " ").lstrip("*") else: # Add to the list of things that are required. - index = len(encryptionTypes[typeID][2]) - encryptionTypes[typeID][2][index] = {} - encryptionTypes[typeID][2][index][1] = current + index = len(cur_type[2]) + cur_type[2][index] = {} + cur_type[2][index][1] = current + # Add the current type to the dict of encryption types. + encryptionTypes.append(cur_type) return encryptionTypes def noneToString(text): diff --git a/wicd.py b/wicd.py index 3f995c9..a2b51b3 100755 --- a/wicd.py +++ b/wicd.py @@ -64,15 +64,7 @@ else: if getattr(dbus, 'version', (0, 0, 0)) >= (0, 41, 0): import dbus.glib -if sys.platform == 'linux2': - # Set process name. Only works on Linux >= 2.1.57. - try: - import dl - libc = dl.open('/lib/libc.so.6') - libc.call('prctl', 15, 'wicd\0', 0, 0, 0) # 15 is PR_SET_NAME - except Exception: - print 'Failed to rename wicd process' - pass +misc.RenameProcess("wicd") if __name__ == '__main__': wpath.chdir(__file__)