mirror of
https://github.com/gryf/wicd.git
synced 2025-12-23 06:37:59 +01:00
Testing/Experimental:
- Fixed an indentation problem - Use misc.RenameProcess for process renaming in wicd.py Experimental: - Make the encryption template file parsing used for the GUI a little more robust.
This commit is contained in:
8
gui.py
8
gui.py
@@ -521,9 +521,9 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
|
|||||||
|
|
||||||
# Build the encryption menu
|
# Build the encryption menu
|
||||||
activeID = -1 # Set the menu to this item when we are done
|
activeID = -1 # Set the menu to this item when we are done
|
||||||
for x in self.encrypt_types:
|
for x, enc_type in enumerate(self.encrypt_types):
|
||||||
self.combo_encryption.append_text(self.encrypt_types[x][0])
|
self.combo_encryption.append_text(enc_type[0])
|
||||||
if self.encrypt_types[x][1] == wireless.GetWirelessProperty(networkID,
|
if enc_type[1] == wireless.GetWirelessProperty(networkID,
|
||||||
"enctype"):
|
"enctype"):
|
||||||
activeID = x
|
activeID = x
|
||||||
self.combo_encryption.set_active(activeID)
|
self.combo_encryption.set_active(activeID)
|
||||||
@@ -1199,6 +1199,8 @@ class appGui:
|
|||||||
|
|
||||||
self.status_area.hide_all()
|
self.status_area.hide_all()
|
||||||
|
|
||||||
|
# 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.window.set_icon_from_file(wpath.etc + "wicd.png")
|
||||||
self.statusID = None
|
self.statusID = None
|
||||||
self.first_dialog_load = True
|
self.first_dialog_load = True
|
||||||
|
|||||||
62
misc.py
62
misc.py
@@ -189,24 +189,43 @@ def LoadEncryptionMethods():
|
|||||||
loaded, the template must be listed in the "active" file.
|
loaded, the template must be listed in the "active" file.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
encryptionTypes = {}
|
def parse_ent(line, key):
|
||||||
types = open("encryption/templates/active","r")
|
return line.replace(key, "").replace("=", "").strip()
|
||||||
enctypes = types.readlines()
|
|
||||||
|
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:
|
for x in enctypes:
|
||||||
# Skip some lines, we don't care who the author is/was, etc
|
x = x.strip()
|
||||||
# we don't care about version either.
|
try:
|
||||||
x = x.strip("\n")
|
f = open("encryption/templates/" + x, "r")
|
||||||
current = open("encryption/templates/" + x,"r")
|
except IOError:
|
||||||
line = current.readlines()
|
print 'Failed to load encryption type ' + str(x)
|
||||||
# Get the length so we know where in the array to add data
|
continue
|
||||||
typeID = len(encryptionTypes)
|
line = f.readlines()
|
||||||
encryptionTypes[typeID] = {}
|
f.close()
|
||||||
encryptionTypes[typeID][0] = line[0][7:].strip("\n")
|
|
||||||
encryptionTypes[typeID][1] = x
|
cur_type = {}
|
||||||
encryptionTypes[typeID][2] = {}
|
cur_type[0] = parse_ent(line[0], "name")
|
||||||
requiredFields = line[3][8:]
|
cur_type[1] = x
|
||||||
requiredFields = requiredFields.strip("\n")
|
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(" ")
|
requiredFields = requiredFields.split(" ")
|
||||||
|
|
||||||
|
# Get the required fields.
|
||||||
index = -1
|
index = -1
|
||||||
for current in requiredFields:
|
for current in requiredFields:
|
||||||
# The pretty names will start with an * so we can
|
# The pretty names will start with an * so we can
|
||||||
@@ -214,13 +233,14 @@ def LoadEncryptionMethods():
|
|||||||
if current[0] == "*":
|
if current[0] == "*":
|
||||||
# Make underscores spaces
|
# Make underscores spaces
|
||||||
# and remove the *
|
# and remove the *
|
||||||
encryptionTypes[typeID][2][index][0] = current.replace("_",
|
cur_type[2][index][0] = current.replace("_", " ").lstrip("*")
|
||||||
" ").lstrip("*")
|
|
||||||
else:
|
else:
|
||||||
# Add to the list of things that are required.
|
# Add to the list of things that are required.
|
||||||
index = len(encryptionTypes[typeID][2])
|
index = len(cur_type[2])
|
||||||
encryptionTypes[typeID][2][index] = {}
|
cur_type[2][index] = {}
|
||||||
encryptionTypes[typeID][2][index][1] = current
|
cur_type[2][index][1] = current
|
||||||
|
# Add the current type to the dict of encryption types.
|
||||||
|
encryptionTypes.append(cur_type)
|
||||||
return encryptionTypes
|
return encryptionTypes
|
||||||
|
|
||||||
def noneToString(text):
|
def noneToString(text):
|
||||||
|
|||||||
10
wicd.py
10
wicd.py
@@ -64,15 +64,7 @@ else:
|
|||||||
if getattr(dbus, 'version', (0, 0, 0)) >= (0, 41, 0):
|
if getattr(dbus, 'version', (0, 0, 0)) >= (0, 41, 0):
|
||||||
import dbus.glib
|
import dbus.glib
|
||||||
|
|
||||||
if sys.platform == 'linux2':
|
misc.RenameProcess("wicd")
|
||||||
# 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
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
wpath.chdir(__file__)
|
wpath.chdir(__file__)
|
||||||
|
|||||||
Reference in New Issue
Block a user