mirror of
https://github.com/gryf/wicd.git
synced 2025-12-20 21:08:06 +01:00
Merge.
This commit is contained in:
53
wicd/misc.py
53
wicd/misc.py
@@ -223,19 +223,34 @@ def ParseEncryption(network):
|
||||
"""
|
||||
enctemplate = open(wpath.encryption + network["enctype"])
|
||||
template = enctemplate.readlines()
|
||||
# Set these to nothing so that we can hold them outside the loop
|
||||
z = "ap_scan=1\n"
|
||||
# Loop through the lines in the template, selecting ones to use
|
||||
for y, x in enumerate(template):
|
||||
x = x.strip("\n")
|
||||
if y > 4:
|
||||
# replace values
|
||||
x = x.replace("$_SCAN","0")
|
||||
for t in network:
|
||||
# Don't bother if z's value is None cause it will cause errors
|
||||
if Noneify(network[t]) is not None:
|
||||
x = x.replace("$_" + str(t).upper(), str(network[t]))
|
||||
z = z + "\n" + x
|
||||
config_file = "ap_scan=1\n"
|
||||
should_replace = False
|
||||
for index, line in enumerate(template):
|
||||
if not should_replace:
|
||||
if line.strip().startswith('---'):
|
||||
should_replace = True
|
||||
else:
|
||||
if line.strip().startswith("}"):
|
||||
# This is the last line, so we just write it.
|
||||
config_file = ''.join([config_file, line])
|
||||
elif "$_" in line:
|
||||
cur_val = re.findall('\$_([A-Z0-9_]+)', line)
|
||||
if cur_val:
|
||||
if cur_val[0] == 'SCAN':
|
||||
#TODO should this be hardcoded?
|
||||
line = line.replace("$_SCAN", "0")
|
||||
config_file = ''.join([config_file, line])
|
||||
else:
|
||||
rep_val = network.get(cur_val[0].lower())
|
||||
if rep_val:
|
||||
line = line.replace("$_%s" % cur_val[0], rep_val)
|
||||
config_file = ''.join([config_file, line])
|
||||
else:
|
||||
print "Ignoring template line: '%s'" % line
|
||||
else:
|
||||
print "Weird parsing error occurred"
|
||||
else: # Just a regular entry.
|
||||
config_file = ''.join([config_file, line])
|
||||
|
||||
# Write the data to the files then chmod them so they can't be read
|
||||
# by normal users.
|
||||
@@ -244,7 +259,7 @@ def ParseEncryption(network):
|
||||
os.chown(wpath.networks + network["bssid"].replace(":", "").lower(), 0, 0)
|
||||
# We could do this above, but we'd like to read protect
|
||||
# them before we write, so that it can't be read.
|
||||
f.write(z)
|
||||
f.write(config_file)
|
||||
f.close()
|
||||
|
||||
def LoadEncryptionMethods():
|
||||
@@ -525,7 +540,7 @@ def get_language_list_gui():
|
||||
language['stop_showing_chooser'] = _('Stop Showing Autoconnect pop-up temporarily')
|
||||
language['display_type_dialog'] = _('Use dBm to measure signal strength')
|
||||
language['scripts'] = _('Scripts')
|
||||
language['invalid_address'] = _('Invalid address in $A entry.')
|
||||
#language['invalid_address'] = _('Invalid address in $A entry.')
|
||||
language['global_settings'] = _('Use these settings for all networks sharing this essid')
|
||||
language['encrypt_info_missing'] = _('Required encryption information is missing.')
|
||||
language['enable_encryption'] = _('This network requires encryption to be enabled.')
|
||||
@@ -610,6 +625,14 @@ def get_language_list_gui():
|
||||
language['wicd_curses'] = _("Wicd Curses Interface")
|
||||
language['dbus_fail'] = _("DBus failure! This is most likely caused by the wicd daemon stopping while wicd-curses is running. Please restart the daemon, and then restart wicd-curses.")
|
||||
|
||||
# Fix strings in wicd-curses
|
||||
for i in language.keys():
|
||||
try :
|
||||
language[i] = language[i].decode('utf8')
|
||||
except:
|
||||
print "\"%s\"" % language[i]
|
||||
raise
|
||||
|
||||
|
||||
return language
|
||||
|
||||
|
||||
Reference in New Issue
Block a user