mirror of
https://github.com/gryf/wicd.git
synced 2025-12-19 12:28:08 +01:00
Merged r229 from mainline experimental.
This commit is contained in:
1090
data/wicd.glade
1090
data/wicd.glade
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,5 @@
|
|||||||
wpa
|
wpa
|
||||||
|
wpa-psk
|
||||||
wep-hex
|
wep-hex
|
||||||
wep-passphrase
|
wep-passphrase
|
||||||
wep-shared
|
wep-shared
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name = WPA 1/2
|
name = WPA 1/2 (Passphrase)
|
||||||
author = Adam Blackburn
|
author = Adam Blackburn
|
||||||
version = 1
|
version = 1
|
||||||
require key *Key
|
require key *Key
|
||||||
|
|||||||
15
encryption/templates/wpa-psk
Normal file
15
encryption/templates/wpa-psk
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
name = WPA 1/2 (Preshared Key)
|
||||||
|
author = Adam Blackburn
|
||||||
|
version = 1
|
||||||
|
require apsk *Preshared_Key
|
||||||
|
-----
|
||||||
|
ctrl_interface=/var/run/wpa_supplicant
|
||||||
|
network={
|
||||||
|
ssid="$_ESSID"
|
||||||
|
scan_ssid=$_SCAN
|
||||||
|
proto=WPA RSN
|
||||||
|
key_mgmt=WPA-PSK
|
||||||
|
pairwise=CCMP TKIP
|
||||||
|
group=CCMP TKIP
|
||||||
|
psk="$_APSK"
|
||||||
|
}
|
||||||
21
setup.py
21
setup.py
@@ -239,6 +239,23 @@ class configure(Command):
|
|||||||
item_in.close()
|
item_in.close()
|
||||||
shutil.copymode(original_name, final_name)
|
shutil.copymode(original_name, final_name)
|
||||||
|
|
||||||
|
class test(Command):
|
||||||
|
description = "run Wicd's unit tests"
|
||||||
|
|
||||||
|
user_options = []
|
||||||
|
|
||||||
|
def initialize_options(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
print "importing tests"
|
||||||
|
import tests
|
||||||
|
print 'running tests'
|
||||||
|
tests.run_tests()
|
||||||
|
|
||||||
class get_translations(Command):
|
class get_translations(Command):
|
||||||
description = "download the translations from the online translator"
|
description = "download the translations from the online translator"
|
||||||
|
|
||||||
@@ -349,7 +366,7 @@ try:
|
|||||||
data.append(( wpath.suspend, ['other/50-wicd-suspend.sh' ]))
|
data.append(( wpath.suspend, ['other/50-wicd-suspend.sh' ]))
|
||||||
if not wpath.no_install_pmutils:
|
if not wpath.no_install_pmutils:
|
||||||
data.append(( wpath.pmutils, ['other/55wicd' ]))
|
data.append(( wpath.pmutils, ['other/55wicd' ]))
|
||||||
print 'Creating pid path', os.path.basename(wpath.pidfile)
|
print 'Using pid path', os.path.basename(wpath.pidfile)
|
||||||
print 'Language support for',
|
print 'Language support for',
|
||||||
for language in os.listdir('translations/'):
|
for language in os.listdir('translations/'):
|
||||||
if not language.startswith('.'):
|
if not language.startswith('.'):
|
||||||
@@ -373,7 +390,7 @@ iwscan_ext = Extension(name = 'iwscan',
|
|||||||
libraries = ['iw'],
|
libraries = ['iw'],
|
||||||
sources = ['depends/python-iwscan/pyiwscan.c'])
|
sources = ['depends/python-iwscan/pyiwscan.c'])
|
||||||
|
|
||||||
setup(cmdclass={'configure' : configure, 'get_translations' : get_translations, 'uninstall' : uninstall},
|
setup(cmdclass={'configure' : configure, 'get_translations' : get_translations, 'uninstall' : uninstall, 'test' : test},
|
||||||
name="Wicd",
|
name="Wicd",
|
||||||
version=VERSION_NUM,
|
version=VERSION_NUM,
|
||||||
description="A wireless and wired network manager",
|
description="A wireless and wired network manager",
|
||||||
|
|||||||
11
tests/__init__.py
Normal file
11
tests/__init__.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
def run_tests():
|
||||||
|
import unittest
|
||||||
|
test_suite = unittest.TestSuite()
|
||||||
|
|
||||||
|
import testwnettools
|
||||||
|
test_suite.addTest(testwnettools.suite())
|
||||||
|
|
||||||
|
import testmisc
|
||||||
|
test_suite.addTest(testmisc.suite())
|
||||||
|
|
||||||
|
unittest.TextTestRunner(verbosity=2).run(test_suite)
|
||||||
145
tests/testmisc.py
Normal file
145
tests/testmisc.py
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
from wicd import misc
|
||||||
|
|
||||||
|
class TestMisc(unittest.TestCase):
|
||||||
|
def test_misc_run(self):
|
||||||
|
output = misc.Run(['echo', 'hi']).strip()
|
||||||
|
self.assertEquals('hi', output)
|
||||||
|
|
||||||
|
def test_valid_ip_1(self):
|
||||||
|
self.assertTrue(misc.IsValidIP('0.0.0.0'))
|
||||||
|
|
||||||
|
def test_valid_ip_2(self):
|
||||||
|
self.assertTrue(misc.IsValidIP('255.255.255.255'))
|
||||||
|
|
||||||
|
def test_valid_ip_3(self):
|
||||||
|
self.assertTrue(misc.IsValidIP('10.0.1.1'))
|
||||||
|
|
||||||
|
def test_invalid_ip_1(self):
|
||||||
|
self.assertFalse(misc.IsValidIP('-10.0.-1.-1'))
|
||||||
|
|
||||||
|
def test_invalid_ip_2(self):
|
||||||
|
self.assertFalse(misc.IsValidIP('256.0.0.1'))
|
||||||
|
|
||||||
|
def test_invalid_ip_3(self):
|
||||||
|
self.assertFalse(misc.IsValidIP('1000.0.0.1'))
|
||||||
|
|
||||||
|
def test_run_valid_regex(self):
|
||||||
|
import re
|
||||||
|
regex = re.compile('.*(ABC.EFG).*')
|
||||||
|
found = misc.RunRegex(regex, '01234ABCDEFG56789')
|
||||||
|
self.assertEquals(found, 'ABCDEFG')
|
||||||
|
|
||||||
|
def test_run_invalid_regex(self):
|
||||||
|
import re
|
||||||
|
regex = re.compile('.*(ABC.EFG).*')
|
||||||
|
found = misc.RunRegex(regex, '01234ABCEDFG56789')
|
||||||
|
self.assertEquals(found, None)
|
||||||
|
|
||||||
|
def test_to_boolean_false(self):
|
||||||
|
self.assertFalse(misc.to_bool('False'))
|
||||||
|
|
||||||
|
def test_to_boolean_0(self):
|
||||||
|
self.assertFalse(misc.to_bool('0'))
|
||||||
|
|
||||||
|
def test_to_boolean_true(self):
|
||||||
|
self.assertTrue(misc.to_bool('True'))
|
||||||
|
|
||||||
|
def test_to_boolean_true(self):
|
||||||
|
self.assertTrue(misc.to_bool('1'))
|
||||||
|
|
||||||
|
def test_noneify_1(self):
|
||||||
|
self.assertEquals(misc.Noneify('None'), None)
|
||||||
|
|
||||||
|
def test_noneify_2(self):
|
||||||
|
self.assertEquals(misc.Noneify(''), None)
|
||||||
|
|
||||||
|
def test_noneify_3(self):
|
||||||
|
self.assertEquals(misc.Noneify(None), None)
|
||||||
|
|
||||||
|
def test_noneify_4(self):
|
||||||
|
self.assertFalse(misc.Noneify('False'))
|
||||||
|
|
||||||
|
def test_noneify_5(self):
|
||||||
|
self.assertFalse(misc.Noneify('0'))
|
||||||
|
|
||||||
|
def test_noneify_6(self):
|
||||||
|
self.assertFalse(misc.Noneify(False))
|
||||||
|
|
||||||
|
def test_noneify_7(self):
|
||||||
|
self.assertTrue(misc.Noneify('True'))
|
||||||
|
|
||||||
|
def test_noneify_8(self):
|
||||||
|
self.assertTrue(misc.Noneify('1'))
|
||||||
|
|
||||||
|
def test_noneify_9(self):
|
||||||
|
self.assertTrue(misc.Noneify(True))
|
||||||
|
|
||||||
|
def test_noneify_10(self):
|
||||||
|
self.assertEquals(misc.Noneify('randomtext'), 'randomtext')
|
||||||
|
|
||||||
|
def test_noneify_11(self):
|
||||||
|
self.assertEquals(misc.Noneify(5), 5)
|
||||||
|
|
||||||
|
def test_none_to_string_1(self):
|
||||||
|
self.assertEquals(misc.noneToString(None), 'None')
|
||||||
|
|
||||||
|
def test_none_to_string_2(self):
|
||||||
|
self.assertEquals(misc.noneToString(''), 'None')
|
||||||
|
|
||||||
|
def test_none_to_string_3(self):
|
||||||
|
self.assertEquals(misc.noneToString(None), 'None')
|
||||||
|
|
||||||
|
####################################################################
|
||||||
|
# misc.to_unicode actually converts to utf-8, which is type str #
|
||||||
|
####################################################################
|
||||||
|
|
||||||
|
def test_to_unicode_1(self):
|
||||||
|
self.assertEquals(misc.to_unicode('邪悪'), '邪悪')
|
||||||
|
|
||||||
|
def test_to_unicode_2(self):
|
||||||
|
self.assertEquals(misc.to_unicode(u'邪悪'), '邪悪')
|
||||||
|
|
||||||
|
def test_to_unicode_3(self):
|
||||||
|
self.assertEquals(misc.to_unicode(u'abcdef'), 'abcdef')
|
||||||
|
|
||||||
|
def test_to_unicode_4(self):
|
||||||
|
self.assertEquals(type(misc.to_unicode('abcdef'.encode('latin-1'))), str)
|
||||||
|
|
||||||
|
def test_to_unicode_5(self):
|
||||||
|
self.assertEquals(misc.to_unicode("berkåk"), "berkåk")
|
||||||
|
|
||||||
|
def test_to_unicode_6(self):
|
||||||
|
self.assertEquals(misc.to_unicode('berk\xe5k'), "berkåk")
|
||||||
|
|
||||||
|
def test_none_to_blank_string_1(self):
|
||||||
|
self.assertEquals(misc.noneToBlankString(None), '')
|
||||||
|
|
||||||
|
def test_none_to_blank_string_2(self):
|
||||||
|
self.assertEquals(misc.noneToBlankString('None'), '')
|
||||||
|
|
||||||
|
def test_string_to_none_1(self):
|
||||||
|
self.assertEquals(misc.stringToNone(''), None)
|
||||||
|
|
||||||
|
def test_string_to_none_2(self):
|
||||||
|
self.assertEquals(misc.stringToNone('None'), None)
|
||||||
|
|
||||||
|
def test_string_to_none_3(self):
|
||||||
|
self.assertEquals(misc.stringToNone(None), None)
|
||||||
|
|
||||||
|
def test_string_to_none_4(self):
|
||||||
|
self.assertEquals(misc.stringToNone('abcdef'), 'abcdef')
|
||||||
|
|
||||||
|
def suite():
|
||||||
|
suite = unittest.TestSuite()
|
||||||
|
tests = []
|
||||||
|
[ tests.append(test) for test in dir(TestMisc) if test.startswith('test') ]
|
||||||
|
for test in tests:
|
||||||
|
suite.addTest(TestMisc(test))
|
||||||
|
return suite
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
66
tests/testwnettools.py
Normal file
66
tests/testwnettools.py
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
import unittest
|
||||||
|
from wicd import wnettools
|
||||||
|
|
||||||
|
class TestWnettools(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.interface = wnettools.BaseInterface('eth0')
|
||||||
|
|
||||||
|
def test_find_wireless_interface(self):
|
||||||
|
interfaces = wnettools.GetWirelessInterfaces()
|
||||||
|
# wlan0 may change depending on your system
|
||||||
|
self.assertTrue('wlan0' in interfaces)
|
||||||
|
|
||||||
|
def test_find_wired_interface(self):
|
||||||
|
interfaces = wnettools.GetWiredInterfaces()
|
||||||
|
# eth0 may change depending on your system
|
||||||
|
self.assertTrue('eth0' in interfaces)
|
||||||
|
|
||||||
|
def test_wext_is_valid_wpasupplicant_driver(self):
|
||||||
|
self.assertTrue(wnettools.IsValidWpaSuppDriver('wext'))
|
||||||
|
|
||||||
|
def test_needs_external_calls_not_implemented(self):
|
||||||
|
self.assertRaises(NotImplementedError, wnettools.NeedsExternalCalls)
|
||||||
|
|
||||||
|
def test_get_ip_not_implemented(self):
|
||||||
|
self.assertRaises(NotImplementedError, self.interface.GetIP)
|
||||||
|
|
||||||
|
def test_is_up_not_implemented(self):
|
||||||
|
self.assertRaises(NotImplementedError, self.interface.IsUp)
|
||||||
|
|
||||||
|
def test_enable_debug_mode(self):
|
||||||
|
self.interface.SetDebugMode(True)
|
||||||
|
self.assertTrue(self.interface.verbose)
|
||||||
|
|
||||||
|
def test_disable_debug_mode(self):
|
||||||
|
self.interface.SetDebugMode(False)
|
||||||
|
self.assertFalse(self.interface.verbose)
|
||||||
|
|
||||||
|
def test_interface_name_sanitation(self):
|
||||||
|
interface = wnettools.BaseInterface('blahblah; uptime > /tmp/blah | cat')
|
||||||
|
self.assertEquals(interface.iface, 'blahblahuptimetmpblahcat')
|
||||||
|
|
||||||
|
def test_freq_translation_low(self):
|
||||||
|
freq = '2.412 GHz'
|
||||||
|
interface = wnettools.BaseWirelessInterface('wlan0')
|
||||||
|
self.assertEquals(interface._FreqToChannel(freq), 1)
|
||||||
|
|
||||||
|
def test_freq_translation_high(self):
|
||||||
|
freq = '2.484 GHz'
|
||||||
|
interface = wnettools.BaseWirelessInterface('wlan0')
|
||||||
|
self.assertEquals(interface._FreqToChannel(freq), 14)
|
||||||
|
|
||||||
|
def test_generate_psk(self):
|
||||||
|
interface = wnettools.BaseWirelessInterface('wlan0')
|
||||||
|
psk = interface.GeneratePSK({'essid' : 'Network 1', 'key' : 'arandompassphrase'})
|
||||||
|
self.assertEquals(psk, 'd70463014514f4b4ebb8e3aebbdec13f4437ac3a9af084b3433f3710e658a7be')
|
||||||
|
|
||||||
|
def suite():
|
||||||
|
suite = unittest.TestSuite()
|
||||||
|
tests = []
|
||||||
|
[ tests.append(test) for test in dir(TestWnettools) if test.startswith('test') ]
|
||||||
|
for test in tests:
|
||||||
|
suite.addTest(TestWnettools(test))
|
||||||
|
return suite
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
29
wicd/misc.py
29
wicd/misc.py
@@ -302,13 +302,22 @@ def get_gettext():
|
|||||||
def to_unicode(x):
|
def to_unicode(x):
|
||||||
""" Attempts to convert a string to utf-8. """
|
""" Attempts to convert a string to utf-8. """
|
||||||
# If this is a unicode string, encode it and return
|
# If this is a unicode string, encode it and return
|
||||||
if type(x) == unicode:
|
if type(x) not in [unicode, str]:
|
||||||
|
return x
|
||||||
|
if isinstance(x, unicode):
|
||||||
return x.encode('utf-8')
|
return x.encode('utf-8')
|
||||||
encoding = locale.getpreferredencoding()
|
encoding = locale.getpreferredencoding()
|
||||||
try:
|
try:
|
||||||
ret = x.decode(encoding, 'replace').encode('utf-8')
|
ret = x.decode(encoding).encode('utf-8')
|
||||||
except:
|
except UnicodeError:
|
||||||
ret = x.decode('utf-8', 'replace').encode('utf-8')
|
try:
|
||||||
|
ret = x.decode('utf-8').encode('utf-8')
|
||||||
|
except UnicodeError:
|
||||||
|
try:
|
||||||
|
ret = x.decode('latin-1').encode('utf-8')
|
||||||
|
except UnicodeError:
|
||||||
|
ret = x.decode('utf-8', 'replace').encode('utf-8')
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def RenameProcess(new_name):
|
def RenameProcess(new_name):
|
||||||
@@ -509,8 +518,8 @@ def get_language_list_gui():
|
|||||||
language['bad_pass'] = _('Connection Failed: Could not authenticate (bad password?)')
|
language['bad_pass'] = _('Connection Failed: Could not authenticate (bad password?)')
|
||||||
language['done'] = _('Done connecting...')
|
language['done'] = _('Done connecting...')
|
||||||
language['scanning'] = _('Scanning')
|
language['scanning'] = _('Scanning')
|
||||||
language['cannot_start_daemon'] = _("Unable to connect to wicd daemon DBus interface." + \
|
language['cannot_start_daemon'] = _("Unable to connect to wicd daemon DBus interface. " + \
|
||||||
"This typically means there was a problem starting the daemon." + \
|
"This typically means there was a problem starting the daemon. " + \
|
||||||
"Check the wicd log for more info")
|
"Check the wicd log for more info")
|
||||||
language['lost_dbus'] = _("The wicd daemon has shut down, the UI will not function properly until it is restarted.")
|
language['lost_dbus'] = _("The wicd daemon has shut down, the UI will not function properly until it is restarted.")
|
||||||
|
|
||||||
@@ -555,14 +564,6 @@ def stringToNone(text):
|
|||||||
else:
|
else:
|
||||||
return str(text)
|
return str(text)
|
||||||
|
|
||||||
def stringToBoolean(text):
|
|
||||||
""" Turns a string representation of a bool to a boolean if needed. """
|
|
||||||
if text in ("True", "1"):
|
|
||||||
return True
|
|
||||||
if text in ("False", "0"):
|
|
||||||
return False
|
|
||||||
return bool(text)
|
|
||||||
|
|
||||||
def checkboxTextboxToggle(checkbox, textboxes):
|
def checkboxTextboxToggle(checkbox, textboxes):
|
||||||
for textbox in textboxes:
|
for textbox in textboxes:
|
||||||
textbox.set_sensitive(checkbox.get_active())
|
textbox.set_sensitive(checkbox.get_active())
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import gtk
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
import misc
|
import misc
|
||||||
from misc import noneToString, stringToNone, noneToBlankString, stringToBoolean
|
from misc import noneToString, stringToNone, noneToBlankString, to_bool
|
||||||
import wpath
|
import wpath
|
||||||
|
|
||||||
language = misc.get_language_list_gui()
|
language = misc.get_language_list_gui()
|
||||||
@@ -526,7 +526,7 @@ class WiredNetworkEntry(NetworkEntry):
|
|||||||
self.script_button.connect("button-press-event", self.edit_scripts)
|
self.script_button.connect("button-press-event", self.edit_scripts)
|
||||||
|
|
||||||
# Toggle the default profile checkbox to the correct state.
|
# Toggle the default profile checkbox to the correct state.
|
||||||
if stringToBoolean(wired.GetWiredProperty("default")):
|
if to_bool(wired.GetWiredProperty("default")):
|
||||||
self.chkbox_default_profile.set_active(True)
|
self.chkbox_default_profile.set_active(True)
|
||||||
else:
|
else:
|
||||||
self.chkbox_default_profile.set_active(False)
|
self.chkbox_default_profile.set_active(False)
|
||||||
@@ -666,7 +666,7 @@ class WiredNetworkEntry(NetworkEntry):
|
|||||||
self.advanced_dialog.prof_name = profile_name
|
self.advanced_dialog.prof_name = profile_name
|
||||||
|
|
||||||
is_default = wired.GetWiredProperty("default")
|
is_default = wired.GetWiredProperty("default")
|
||||||
self.chkbox_default_profile.set_active(stringToBoolean(is_default))
|
self.chkbox_default_profile.set_active(to_bool(is_default))
|
||||||
|
|
||||||
def format_entry(self, label):
|
def format_entry(self, label):
|
||||||
""" Help method for fetching/formatting wired properties. """
|
""" Help method for fetching/formatting wired properties. """
|
||||||
@@ -728,7 +728,7 @@ class WirelessNetworkEntry(NetworkEntry):
|
|||||||
self.vbox_top.pack_start(self.chkbox_autoconnect, False, False)
|
self.vbox_top.pack_start(self.chkbox_autoconnect, False, False)
|
||||||
self.vbox_top.pack_start(self.hbox_status, True, True)
|
self.vbox_top.pack_start(self.hbox_status, True, True)
|
||||||
|
|
||||||
if stringToBoolean(self.format_entry(networkID, "automatic")):
|
if to_bool(self.format_entry(networkID, "automatic")):
|
||||||
self.chkbox_autoconnect.set_active(True)
|
self.chkbox_autoconnect.set_active(True)
|
||||||
else:
|
else:
|
||||||
self.chkbox_autoconnect.set_active(False)
|
self.chkbox_autoconnect.set_active(False)
|
||||||
|
|||||||
@@ -364,7 +364,8 @@ class TrayIcon(object):
|
|||||||
if DBUS_AVAIL:
|
if DBUS_AVAIL:
|
||||||
self.toggle_wicd_gui()
|
self.toggle_wicd_gui()
|
||||||
else:
|
else:
|
||||||
gui.error(None, language["daemon_unavailable"])
|
# gui.error(None, language["daemon_unavailable"])
|
||||||
|
pass
|
||||||
|
|
||||||
def on_quit(self, widget=None):
|
def on_quit(self, widget=None):
|
||||||
""" Closes the tray icon. """
|
""" Closes the tray icon. """
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import misc
|
|||||||
RALINK_DRIVER = 'ralink legacy'
|
RALINK_DRIVER = 'ralink legacy'
|
||||||
|
|
||||||
|
|
||||||
blacklist_strict = punctuation.replace("-", "") + " "
|
blacklist_strict = '!"#$%&\'()*+,./:;<=>?@[\\]^`{|}~ '
|
||||||
blacklist_norm = ";`$!*|><&\\"
|
blacklist_norm = ";`$!*|><&\\"
|
||||||
blank_trans = maketrans("", "")
|
blank_trans = maketrans("", "")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user