mirror of
https://github.com/gryf/wicd.git
synced 2025-12-20 04:48:00 +01:00
Merge r342 of experimental-nacl
This commit is contained in:
239
CHANGES
239
CHANGES
@@ -1,4 +1,243 @@
|
||||
------------------------------------------------------------
|
||||
revno: 404
|
||||
committer: Dan O'Reilly <oreilldf@gmail.com>
|
||||
branch nick: 1.6
|
||||
timestamp: Wed 2009-05-27 22:25:32 -0400
|
||||
message:
|
||||
Merge 1.6-dan
|
||||
------------------------------------------------------------
|
||||
revno: 401.1.3
|
||||
committer: Dan O'Reilly <oreilldf@gmail.com>
|
||||
branch nick: experimental
|
||||
timestamp: Sun 2009-05-24 17:11:14 -0400
|
||||
message:
|
||||
Try to recover if we attempt to load a non-existent backend.
|
||||
------------------------------------------------------------
|
||||
revno: 401.1.2
|
||||
committer: Dan O'Reilly <oreilldf@gmail.com>
|
||||
branch nick: experimental
|
||||
timestamp: Fri 2009-05-22 15:43:14 -0400
|
||||
message:
|
||||
Merge
|
||||
------------------------------------------------------------
|
||||
revno: 401.2.1
|
||||
committer: Dan O'Reilly <oreilldf@gmail.com>
|
||||
branch nick: experimental
|
||||
timestamp: Fri 2009-05-22 15:33:03 -0400
|
||||
message:
|
||||
- Make the GUI behave better when a disconnect button is pushed.
|
||||
- Move some of the libnotify logic to guiutil.py and add support for displaying some error messages in a libnotify pop-up.
|
||||
- Apply some patches provided by sunseraph. Tweak to the channel regex and checking for a valid AP bssid when monitoring a wireless connection. Set essid, bssid, and channel in separate calls to iwconfig.
|
||||
- Add caching for ifconfig and iwconfig results in wnettools.py. That way we're not needlessly calling the same command a bunch of times in a short period of time (2 seconds). This removes the need for us to pass around iwconfig/ifconfig output elsewhere, though I've left it in for now.
|
||||
- Remove unneeded BackendManager instance from networking.py
|
||||
------------------------------------------------------------
|
||||
revno: 401.1.1
|
||||
committer: Dan O'Reilly <oreilldf@gmail.com>
|
||||
branch nick: experimental
|
||||
timestamp: Fri 2009-05-22 15:40:35 -0400
|
||||
message:
|
||||
- Make the GUI behave better when a disconnect button is pushed.
|
||||
- Move some of the libnotify logic to guiutil.py and add support for displaying some error messages in a libnotify pop-up.
|
||||
- Apply some patches provided by sunseraph. Tweak to the channel regex and checking for a valid AP bssid when monitoring a wireless connection. Set essid, bssid, and channel in separate calls to iwconfig.
|
||||
- Add caching for ifconfig and iwconfig results in wnettools.py. That way we're not needlessly calling the same command a bunch of times in a short period of time (2 seconds). This removes the need for us to pass around iwconfig/ifconfig output elsewhere, though I've left it in for now.
|
||||
- Remove unneeded BackendManager instance from networking.py
|
||||
- Fix last used wired networking autoconnection method
|
||||
------------------------------------------------------------
|
||||
revno: 403
|
||||
committer: Adam Blackburn <compwiz18@gmail.com>
|
||||
branch nick: 1.6
|
||||
timestamp: Sat 2009-05-23 12:51:02 +0800
|
||||
message:
|
||||
Updated version numbers and CHANGES
|
||||
------------------------------------------------------------
|
||||
revno: 402
|
||||
committer: Andrew Psaltis <ampsaltis@gmail.com>
|
||||
branch nick: 1.6
|
||||
timestamp: Sat 2009-05-23 00:40:52 -0400
|
||||
message:
|
||||
Merged r340 of experimental-nacl.
|
||||
------------------------------------------------------------
|
||||
revno: 202.2.49
|
||||
committer: Andrew Psaltis <ampsaltis@gmail.com>
|
||||
branch nick: experimental-nacl
|
||||
timestamp: Sat 2009-05-23 00:36:54 -0400
|
||||
message:
|
||||
Merged r401 of mainline 1.6.
|
||||
------------------------------------------------------------
|
||||
revno: 202.2.48
|
||||
committer: Andrew Psaltis <ampsaltis@gmail.com>
|
||||
branch nick: experimental-nacl
|
||||
timestamp: Sat 2009-05-23 00:32:29 -0400
|
||||
message:
|
||||
Made M^ and C^ into Alt+ and Ctrl+ respectively in OptCols.
|
||||
Rearranged the OptCols for the preferences dialog to match those in the others.
|
||||
------------------------------------------------------------
|
||||
revno: 202.2.47
|
||||
committer: Andrew Psaltis <ampsaltis@gmail.com>
|
||||
branch nick: experimental-nacl
|
||||
timestamp: Sat 2009-05-23 00:23:11 -0400
|
||||
message:
|
||||
Removed some comments from wicd-curses.py.
|
||||
------------------------------------------------------------
|
||||
revno: 202.2.46
|
||||
committer: Andrew Psaltis <ampsaltis@gmail.com>
|
||||
branch nick: experimental-nacl
|
||||
timestamp: Sat 2009-05-23 00:02:58 -0400
|
||||
message:
|
||||
Really fixed bug 355693. :)
|
||||
------------------------------------------------------------
|
||||
revno: 401
|
||||
committer: Adam Blackburn <compwiz18@gmail.com>
|
||||
branch nick: 1.6
|
||||
timestamp: Fri 2009-05-22 11:29:12 +0800
|
||||
message:
|
||||
Buttons are now activated correctly when using the keyboard
|
||||
------------------------------------------------------------
|
||||
revno: 400
|
||||
committer: Adam Blackburn <compwiz18@gmail.com>
|
||||
branch nick: 1.6
|
||||
timestamp: Thu 2009-05-21 23:18:48 +0800
|
||||
message:
|
||||
merged 1.6-rworkman
|
||||
------------------------------------------------------------
|
||||
revno: 365.1.15
|
||||
committer: Robby Workman <rworkman@slackware.com>
|
||||
branch nick: 1.6-rworkman
|
||||
timestamp: Thu 2009-05-21 10:12:03 -0500
|
||||
message:
|
||||
Clarify intent of INSTALL with respect to pm-utils version.
|
||||
------------------------------------------------------------
|
||||
revno: 365.1.14
|
||||
committer: Robby Workman <rworkman@slackware.com>
|
||||
branch nick: 1.6-rworkman
|
||||
timestamp: Tue 2009-05-19 23:40:13 -0500
|
||||
message:
|
||||
Merged mainline back in; no other changes.
|
||||
------------------------------------------------------------
|
||||
revno: 399
|
||||
committer: Andrew Psaltis <ampsaltis@gmail.com>
|
||||
branch nick: 1.6
|
||||
timestamp: Tue 2009-05-19 21:25:09 -0400
|
||||
message:
|
||||
Merged r336 of experimental-nacl.
|
||||
------------------------------------------------------------
|
||||
revno: 202.2.45
|
||||
committer: Andrew Psaltis <ampsaltis@gmail.com>
|
||||
branch nick: experimental-nacl
|
||||
timestamp: Tue 2009-05-19 21:20:29 -0400
|
||||
message:
|
||||
Added wrap_exceptions to wicd-curses.py's run() function.
|
||||
------------------------------------------------------------
|
||||
revno: 202.2.44
|
||||
committer: Andrew Psaltis <ampsaltis@gmail.com>
|
||||
branch nick: experimental-nacl
|
||||
timestamp: Tue 2009-05-19 21:18:30 -0400
|
||||
message:
|
||||
Flipped the order of the dhcp clients in the prefs dialog and fixed a syntax
|
||||
error in wicd-curses.py.
|
||||
------------------------------------------------------------
|
||||
revno: 202.2.43
|
||||
committer: Andrew Psaltis <ampsaltis@gmail.com>
|
||||
branch nick: experimental-nacl
|
||||
timestamp: Tue 2009-05-19 21:06:38 -0400
|
||||
message:
|
||||
Merge r398 of mainline 1.6.
|
||||
------------------------------------------------------------
|
||||
revno: 202.2.42
|
||||
committer: Andrew Psaltis <ampsaltis@gmail.com>
|
||||
branch nick: experimental-nacl
|
||||
timestamp: Fri 2009-05-15 01:05:36 -0400
|
||||
message:
|
||||
Merge r395 of mainline 1.6.
|
||||
------------------------------------------------------------
|
||||
revno: 202.2.41
|
||||
committer: Andrew Psaltis <ampsaltis@gmail.com>
|
||||
branch nick: experimental-nacl
|
||||
timestamp: Fri 2009-05-15 01:05:04 -0400
|
||||
message:
|
||||
Added some deactivated options for enabling debug logs.
|
||||
------------------------------------------------------------
|
||||
revno: 398
|
||||
committer: Adam Blackburn <compwiz18@gmail.com>
|
||||
branch nick: 1.6
|
||||
timestamp: Wed 2009-05-20 07:12:58 +0800
|
||||
message:
|
||||
Merged 1.6-rworkman
|
||||
------------------------------------------------------------
|
||||
revno: 365.1.13
|
||||
committer: Robby Workman <rworkman@slackware.com>
|
||||
branch nick: 1.6-rworkman
|
||||
timestamp: Tue 2009-05-19 15:44:52 -0500
|
||||
message:
|
||||
Make sure the /sys/class/net/whatever is actually a directory in
|
||||
GetWiredInterfaces() (similar to the check in GetWireless)
|
||||
------------------------------------------------------------
|
||||
revno: 365.1.12
|
||||
committer: Robby Workman <rworkman@slackware.com>
|
||||
branch nick: 1.6-rworkman
|
||||
timestamp: Fri 2009-05-15 12:25:58 -0500
|
||||
message:
|
||||
Merged mainline. No other changes to this branch; no need to merge
|
||||
into mainline.
|
||||
------------------------------------------------------------
|
||||
revno: 365.1.11
|
||||
committer: Robby Workman <rworkman@slackware.com>
|
||||
branch nick: 1.6-rworkman
|
||||
timestamp: Fri 2009-05-08 14:27:46 -0500
|
||||
message:
|
||||
Merged mainline; no other changes.
|
||||
------------------------------------------------------------
|
||||
revno: 365.1.10
|
||||
committer: Robby Workman <rworkman@slackware.com>
|
||||
branch nick: 1.6-rworkman
|
||||
timestamp: Sat 2009-05-02 20:25:25 -0500
|
||||
message:
|
||||
Merged mainline back in to sync up this branch.
|
||||
No need to re-merge into mainline, as there are no other changes
|
||||
at this point.
|
||||
------------------------------------------------------------
|
||||
revno: 365.1.9
|
||||
committer: Robby Workman <rworkman@slackware.com>
|
||||
branch nick: 1.6-rworkman
|
||||
timestamp: Fri 2009-05-01 09:15:18 -0500
|
||||
message:
|
||||
Merged mainline.
|
||||
------------------------------------------------------------
|
||||
revno: 397
|
||||
committer: Adam Blackburn <compwiz18@gmail.com>
|
||||
branch nick: 1.6
|
||||
timestamp: Wed 2009-05-20 07:10:49 +0800
|
||||
message:
|
||||
merge
|
||||
------------------------------------------------------------
|
||||
revno: 395.1.2
|
||||
committer: Adam Blackburn <compwiz18@gmail.com>
|
||||
branch nick: 1.6
|
||||
timestamp: Wed 2009-05-20 07:01:31 +0800
|
||||
message:
|
||||
Changed DHCP client order to dhcpcd -> pump -> dhclient
|
||||
------------------------------------------------------------
|
||||
revno: 395.1.1
|
||||
committer: Adam Blackburn <compwiz18@gmail.com>
|
||||
branch nick: 1.6
|
||||
timestamp: Sat 2009-05-16 20:50:20 +0800
|
||||
message:
|
||||
Apply .desktop file patch from Debian (remove deprecated encoding line)
|
||||
------------------------------------------------------------
|
||||
revno: 396
|
||||
committer: Adam Blackburn <compwiz18@gmail.com>
|
||||
branch nick: 1.6
|
||||
timestamp: Wed 2009-05-20 07:09:42 +0800
|
||||
message:
|
||||
changed DHCP client order in preferences dialog
|
||||
------------------------------------------------------------
|
||||
revno: 395
|
||||
committer: Adam Blackburn <compwiz18@gmail.com>
|
||||
branch nick: 1.6
|
||||
timestamp: Thu 2009-05-14 21:55:59 +0800
|
||||
message:
|
||||
update CHANGES and NEWS
|
||||
------------------------------------------------------------
|
||||
revno: 394
|
||||
committer: Andrew Psaltis <ampsaltis@gmail.com>
|
||||
branch nick: 1.6
|
||||
|
||||
@@ -1042,7 +1042,7 @@ def run():
|
||||
# Update what the interface looks like as an idle function
|
||||
#gobject.idle_add(app.update_ui)
|
||||
# Update the connection status on the bottom every 1.5 s.
|
||||
gobject.timeout_add(1500,app.update_status)
|
||||
gobject.timeout_add(2000,app.update_status)
|
||||
# This will make sure that it is updated on the second.
|
||||
gobject.timeout_add(500,app.update_time)
|
||||
|
||||
|
||||
2
setup.py
2
setup.py
@@ -25,7 +25,7 @@ import subprocess
|
||||
|
||||
# Be sure to keep this updated!
|
||||
# VERSIONNUMBER
|
||||
VERSION_NUM = '1.6.0b1'
|
||||
VERSION_NUM = '1.6.0b3'
|
||||
# REVISION_NUM is automatically updated
|
||||
REVISION_NUM = 'unknown'
|
||||
CURSES_REVNO = 'uimod'
|
||||
|
||||
43
wicd/gui.py
43
wicd/gui.py
@@ -286,7 +286,11 @@ class appGui(object):
|
||||
|
||||
def disconnect_all(self, widget=None):
|
||||
""" Disconnects from any active network. """
|
||||
daemon.Disconnect()
|
||||
def handler(*args):
|
||||
gobject.idle_add(self.network_list.set_sensitive, True)
|
||||
|
||||
self.network_list.set_sensitive(False)
|
||||
daemon.Disconnect(reply_handler=handler, error_handler=handler)
|
||||
|
||||
def about_dialog(self, widget, event=None):
|
||||
""" Displays an about dialog. """
|
||||
@@ -649,19 +653,41 @@ class appGui(object):
|
||||
return False
|
||||
return True
|
||||
|
||||
def _wait_for_connect_thread_start(self):
|
||||
self.wTree.get_widget("progressbar").pulse()
|
||||
if not self._connect_thread_started:
|
||||
return True
|
||||
else:
|
||||
misc.timeout_add(2, self.update_statusbar)
|
||||
self.update_statusbar()
|
||||
return False
|
||||
|
||||
def connect(self, widget, nettype, networkid, networkentry):
|
||||
""" Initiates the connection process in the daemon. """
|
||||
def handler(*args):
|
||||
self._connect_thread_started = True
|
||||
|
||||
cancel_button = self.wTree.get_widget("cancel_button")
|
||||
cancel_button.set_sensitive(True)
|
||||
self.network_list.set_sensitive(False)
|
||||
if self.statusID:
|
||||
gobject.idle_add(self.status_bar.remove, 1, self.statusID)
|
||||
gobject.idle_add(self.set_status, language["disconnecting_active"])
|
||||
gobject.idle_add(self.status_area.show_all)
|
||||
self.wait_for_events()
|
||||
self._connect_thread_started = False
|
||||
if nettype == "wireless":
|
||||
if not self.check_encryption_valid(networkid,
|
||||
networkentry.advanced_dialog):
|
||||
self.edit_advanced(None, None, nettype, networkid, networkentry)
|
||||
return False
|
||||
wireless.ConnectWireless(networkid)
|
||||
wireless.ConnectWireless(networkid, reply_handler=handler,
|
||||
error_handler=handler)
|
||||
elif nettype == "wired":
|
||||
wired.ConnectWired()
|
||||
self.update_statusbar()
|
||||
wired.ConnectWired(reply_handler=handler, error_handler=handler)
|
||||
|
||||
gobject.source_remove(self.update_cb)
|
||||
misc.timeout_add(100, self._wait_for_connect_thread_start, milli=True)
|
||||
|
||||
def disconnect(self, widget, nettype, networkid, networkentry):
|
||||
""" Disconnects from the given network.
|
||||
@@ -674,13 +700,18 @@ class appGui(object):
|
||||
networkentry -- The NetworkEntry containing the disconnect button.
|
||||
|
||||
"""
|
||||
def handler(*args):
|
||||
gobject.idle_add(self.network_list.set_sensitive, True)
|
||||
|
||||
widget.hide()
|
||||
networkentry.connect_button.show()
|
||||
daemon.SetForcedDisconnect(True)
|
||||
self.network_list.set_sensitive(False)
|
||||
if nettype == "wired":
|
||||
wired.DisconnectWired()
|
||||
wired.DisconnectWired(reply_handler=handler, error_handler=handler)
|
||||
else:
|
||||
wireless.DisconnectWireless()
|
||||
wireless.DisconnectWireless(reply_handler=handler,
|
||||
error_handler=handler)
|
||||
|
||||
def wait_for_events(self, amt=0):
|
||||
""" Wait for any pending gtk events to finish before moving on.
|
||||
|
||||
@@ -17,11 +17,39 @@
|
||||
#
|
||||
|
||||
import gtk
|
||||
import os.path
|
||||
|
||||
import wpath
|
||||
|
||||
HAS_NOTIFY = True
|
||||
try:
|
||||
import pynotify
|
||||
if not pynotify.init("Wicd"):
|
||||
print 'Could not initalize pynotify'
|
||||
HAS_NOTIFY = False
|
||||
except ImportError:
|
||||
print "Importing pynotify failed, notifications disabled."
|
||||
HAS_NOTIFY = False
|
||||
|
||||
print "Has notifications support", HAS_NOTIFY
|
||||
|
||||
if wpath.no_use_notifications:
|
||||
print 'Notifications disabled during setup.py configure'
|
||||
|
||||
def can_use_notify():
|
||||
use_notify = os.path.exists(os.path.join(os.path.expanduser('~/.wicd'),
|
||||
'USE_NOTIFICATIONS')
|
||||
)
|
||||
return use_notify and HAS_NOTIFY and not wpath.no_use_notifications
|
||||
|
||||
def error(parent, message, block=True):
|
||||
""" Shows an error dialog. """
|
||||
def delete_event(dialog, id):
|
||||
dialog.destroy()
|
||||
if can_use_notify() and not block:
|
||||
notification = pynotify.Notification("ERROR", message, "error")
|
||||
notification.show()
|
||||
return
|
||||
dialog = gtk.MessageDialog(parent, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
|
||||
gtk.BUTTONS_OK)
|
||||
dialog.set_markup(message)
|
||||
|
||||
@@ -174,6 +174,9 @@ class ConnectionStatus(object):
|
||||
self.iwconfig = ''
|
||||
# Reset this, just in case.
|
||||
self.tried_reconnect = False
|
||||
bssid = wireless.GetApBssid()
|
||||
if not bssid:
|
||||
return False
|
||||
|
||||
wifi_signal = self._get_printable_sig_strength()
|
||||
if wifi_signal == 0:
|
||||
|
||||
@@ -154,7 +154,6 @@ class Controller(object):
|
||||
self.disconnect_script = None
|
||||
self.driver = None
|
||||
self.iface = None
|
||||
self.backend_manager = BackendManager()
|
||||
|
||||
def get_debug(self): return self._debug
|
||||
def set_debug(self, value):
|
||||
|
||||
@@ -55,7 +55,7 @@ def get_gettext():
|
||||
_ = lang.gettext
|
||||
return _
|
||||
|
||||
# Generated automatically on Mon, 04 May 2009 23:56:04 CDT
|
||||
# Generated automatically on Sun, 17 May 2009 19:17:27 CDT
|
||||
_ = get_gettext()
|
||||
language = {}
|
||||
language['resetting_ip_address'] = _('''Resetting IP address...''')
|
||||
@@ -215,3 +215,4 @@ language['disconnected'] = _('''Disconnected''')
|
||||
language['establishing_connection'] = _('''Establishing connection...''')
|
||||
language['association_failed'] = _('''Connection failed: Could not contact the wireless access point.''')
|
||||
language['access_denied'] = _('''Unable to contact the wicd dameon due to an access denied error from DBus. Please check your DBus configuration.''')
|
||||
language['disconnecting_active'] = _('''Disconnecting active connections...''')
|
||||
|
||||
@@ -43,16 +43,15 @@ import pango
|
||||
import atexit
|
||||
from dbus import DBusException
|
||||
|
||||
HAS_NOTIFY = True
|
||||
try:
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
|
||||
HAS_NOTIFY = True
|
||||
try:
|
||||
import pynotify
|
||||
if not pynotify.init("Wicd"):
|
||||
print 'could not initalize pynotify'
|
||||
HAS_NOTIFY = False
|
||||
except ImportError:
|
||||
print 'import failed'
|
||||
HAS_NOTIFY = False
|
||||
|
||||
# Wicd specific imports
|
||||
@@ -60,7 +59,7 @@ from wicd import wpath
|
||||
from wicd import misc
|
||||
from wicd import gui
|
||||
from wicd import dbusmanager
|
||||
from wicd.guiutil import error
|
||||
from wicd.guiutil import error, can_use_notify
|
||||
|
||||
from wicd.translations import language
|
||||
|
||||
@@ -75,11 +74,6 @@ if not hasattr(gtk, "StatusIcon"):
|
||||
print 'Unable to load tray icon: Missing both egg.trayicon and gtk.StatusIcon modules.'
|
||||
ICON_AVAIL = False
|
||||
|
||||
print "Has notifications support", HAS_NOTIFY
|
||||
|
||||
if wpath.no_use_notifications:
|
||||
print 'Notifications disabled during setup.py configure'
|
||||
|
||||
misc.RenameProcess("wicd-client")
|
||||
|
||||
if __name__ == '__main__':
|
||||
@@ -163,10 +157,6 @@ class TrayIcon(object):
|
||||
self.last_state = None
|
||||
self.should_notify = True
|
||||
|
||||
self.use_notify = os.path.exists(os.path.join(
|
||||
os.path.expanduser('~/.wicd'),
|
||||
'USE_NOTIFICATIONS'))
|
||||
|
||||
if DBUS_AVAIL:
|
||||
self.update_tray_icon()
|
||||
else:
|
||||
@@ -272,10 +262,8 @@ class TrayIcon(object):
|
||||
[state, info] = daemon.GetConnectionStatus()
|
||||
|
||||
# should this state change display a notification?
|
||||
self.should_notify = not wpath.no_use_notifications and \
|
||||
(self.last_state != state) and \
|
||||
HAS_NOTIFY and \
|
||||
self.use_notify
|
||||
self.should_notify = (can_use_notify() and
|
||||
self.last_state != state)
|
||||
|
||||
self.last_state = state
|
||||
|
||||
|
||||
@@ -203,6 +203,16 @@ class WicdDaemon(dbus.service.Object):
|
||||
def SetBackend(self, backend):
|
||||
""" Sets a new backend. """
|
||||
print "setting backend to %s" % backend
|
||||
backends = networking.BACKEND_MGR.get_available_backends()
|
||||
if backend not in backends:
|
||||
print "backend %s not available, trying to fallback to another" % backend
|
||||
try:
|
||||
backend = backends[0]
|
||||
except IndexError:
|
||||
print "ERROR: no backends available!"
|
||||
return
|
||||
else:
|
||||
print "Fell back to backend %s" % backend
|
||||
self.config.set("Settings", "backend", backend, write=True)
|
||||
if backend != self.GetCurrentBackend():
|
||||
self.suspended = True
|
||||
@@ -1300,6 +1310,7 @@ class WiredDaemon(dbus.service.Object):
|
||||
self.daemon = daemon
|
||||
self.wired = wired
|
||||
self._debug_mode = debug
|
||||
self._cur_wired_prof_name = ""
|
||||
self.WiredNetwork = {}
|
||||
self.config = ConfigManager(os.path.join(wpath.etc,
|
||||
"wired-settings.conf"),
|
||||
@@ -1413,6 +1424,8 @@ class WiredDaemon(dbus.service.Object):
|
||||
self.wired.disconnect_script = self.GetWiredProperty("disconnectscript")
|
||||
self.daemon.wireless_bus.wifi.Disconnect()
|
||||
self.daemon.SetForcedDisconnect(False)
|
||||
self.UnsetWiredLastUsed()
|
||||
self.config.set(self._cur_wired_prof_name, "lastused", True, write=True)
|
||||
self.wired.Connect(self.WiredNetwork, debug=self.debug_mode)
|
||||
self.daemon.UpdateState()
|
||||
|
||||
@@ -1511,8 +1524,10 @@ class WiredDaemon(dbus.service.Object):
|
||||
profile['use_global_dns'] = bool(profile.get('use_global_dns'))
|
||||
profile['use_static_dns'] = bool(profile.get('use_static_dns'))
|
||||
self.WiredNetwork = profile
|
||||
self._cur_wired_prof_name = profilename
|
||||
return "100: Loaded Profile"
|
||||
else:
|
||||
self._cur_wired_prof_name = ""
|
||||
self.WiredNetwork = {}
|
||||
return "500: Profile Not Found"
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ from misc import find_path
|
||||
_re_mode = (re.I | re.M | re.S)
|
||||
essid_pattern = re.compile('.*ESSID:"?(.*?)"?\s*\n', _re_mode)
|
||||
ap_mac_pattern = re.compile('.*Address: (.*?)\n', _re_mode)
|
||||
channel_pattern = re.compile('.*Channel:? ?(\d\d?)', _re_mode)
|
||||
channel_pattern = re.compile('.*Channel:?=? ?(\d\d?)', _re_mode)
|
||||
strength_pattern = re.compile('.*Quality:?=? ?(\d+)\s*/?\s*(\d*)', _re_mode)
|
||||
altstrength_pattern = re.compile('.*Signal level:?=? ?(\d+)\s*/?\s*(\d*)', _re_mode)
|
||||
signaldbm_pattern = re.compile('.*Signal level:?=? ?(-\d\d*)', _re_mode)
|
||||
@@ -84,6 +84,31 @@ def _sanitize_string_strict(string):
|
||||
else:
|
||||
return string
|
||||
|
||||
_cache = {}
|
||||
def timedcache(duration=5):
|
||||
""" A caching decorator for use with wnettools methods.
|
||||
|
||||
Caches the results of a function for a given number of
|
||||
seconds (defaults to 5).
|
||||
|
||||
"""
|
||||
def _timedcache(f):
|
||||
def __timedcache(self, *args, **kwargs):
|
||||
key = str(args) + str(kwargs) + str(f)
|
||||
if hasattr(self, 'iface'):
|
||||
key += self.iface
|
||||
if (key in _cache and
|
||||
(time.time() - _cache[key]['time']) < duration):
|
||||
return _cache[key]['value']
|
||||
else:
|
||||
value = f(self, *args, **kwargs)
|
||||
_cache[key] = { 'time' : time.time(), 'value' : value }
|
||||
return value
|
||||
|
||||
return __timedcache
|
||||
|
||||
return _timedcache
|
||||
|
||||
def GetDefaultGateway():
|
||||
""" Attempts to determine the default gateway by parsing route -n. """
|
||||
route_info = misc.Run("route -n")
|
||||
@@ -350,6 +375,14 @@ class BaseInterface(object):
|
||||
misc.Run(cmd)
|
||||
return True
|
||||
|
||||
@timedcache(2)
|
||||
@neediface("")
|
||||
def GetIfconfig(self):
|
||||
""" Runs ifconfig and returns the output. """
|
||||
cmd = "ifconfig %s" % self.iface
|
||||
if self.verbose: print cmd
|
||||
return misc.Run(cmd)
|
||||
|
||||
@neediface("")
|
||||
def SetAddress(self, ip=None, netmask=None, broadcast=None):
|
||||
""" Set the IP addresses of an interface.
|
||||
@@ -596,9 +629,7 @@ class BaseInterface(object):
|
||||
|
||||
"""
|
||||
if not ifconfig:
|
||||
cmd = 'ifconfig ' + self.iface
|
||||
if self.verbose: print cmd
|
||||
output = misc.Run(cmd)
|
||||
output = self.GetIfconfig()
|
||||
else:
|
||||
output = ifconfig
|
||||
return misc.RunRegex(ip_pattern, output)
|
||||
@@ -635,9 +666,7 @@ class BaseInterface(object):
|
||||
def _slow_is_up(self, ifconfig=None):
|
||||
""" Determine if an interface is up using ifconfig. """
|
||||
if not ifconfig:
|
||||
cmd = "ifconfig " + self.iface
|
||||
if self.verbose: print cmd
|
||||
output = misc.Run(cmd)
|
||||
output = self.GetIfconfig()
|
||||
else:
|
||||
output = ifconfig
|
||||
lines = output.split('\n')
|
||||
@@ -800,6 +829,7 @@ class BaseWirelessInterface(BaseInterface):
|
||||
|
||||
return radiostatus
|
||||
|
||||
@timedcache(2)
|
||||
@neediface(False)
|
||||
def GetIwconfig(self):
|
||||
""" Returns the output of iwconfig for this interface. """
|
||||
@@ -965,12 +995,17 @@ class BaseWirelessInterface(BaseInterface):
|
||||
|
||||
"""
|
||||
cmd = ['iwconfig', self.iface, 'essid', essid]
|
||||
if channel and str(channel).isdigit():
|
||||
cmd.extend(['channel', str(channel)])
|
||||
if bssid:
|
||||
cmd.extend(['ap', bssid])
|
||||
if self.verbose: print str(cmd)
|
||||
misc.Run(cmd)
|
||||
base = "iwconfig %s" % self.iface
|
||||
if channel and str(channel).isdigit():
|
||||
cmd = "%s channel %s" % (base, str(channel))
|
||||
if self.verbose: print cmd
|
||||
misc.Run(cmd)
|
||||
if bssid:
|
||||
cmd = "%s ap %s" % (base, bssid)
|
||||
if self.verbose: print cmd
|
||||
misc.Run(cmd)
|
||||
|
||||
def GeneratePSK(self, network):
|
||||
""" Generate a PSK using wpa_passphrase.
|
||||
@@ -1237,9 +1272,7 @@ class BaseWirelessInterface(BaseInterface):
|
||||
def GetBSSID(self, iwconfig=None):
|
||||
""" Get the MAC address for the interface. """
|
||||
if not iwconfig:
|
||||
cmd = 'iwconfig ' + self.iface
|
||||
if self.verbose: print cmd
|
||||
output = misc.Run(cmd)
|
||||
output = self.GetIwconfig()
|
||||
else:
|
||||
output = iwconfig
|
||||
|
||||
@@ -1250,9 +1283,7 @@ class BaseWirelessInterface(BaseInterface):
|
||||
def GetCurrentBitrate(self, iwconfig=None):
|
||||
""" Get the current bitrate for the interface. """
|
||||
if not iwconfig:
|
||||
cmd = 'iwconfig ' + self.iface
|
||||
if self.verbose: print cmd
|
||||
output = misc.Run(cmd)
|
||||
output = self.GetIwconfig()
|
||||
else:
|
||||
output = iwconfig
|
||||
|
||||
@@ -1263,9 +1294,7 @@ class BaseWirelessInterface(BaseInterface):
|
||||
def GetOperationalMode(self, iwconfig=None):
|
||||
""" Get the operational mode for the interface. """
|
||||
if not iwconfig:
|
||||
cmd = 'iwconfig ' + self.iface
|
||||
if self.verbose: print cmd
|
||||
output = misc.Run(cmd)
|
||||
output = self.GetIwconfig()
|
||||
else:
|
||||
output = iwconfig
|
||||
|
||||
@@ -1313,9 +1342,7 @@ class BaseWirelessInterface(BaseInterface):
|
||||
|
||||
"""
|
||||
if not iwconfig:
|
||||
cmd = 'iwconfig ' + self.iface
|
||||
if self.verbose: print cmd
|
||||
output = misc.Run(cmd)
|
||||
output = self.GetIwconfig()
|
||||
else:
|
||||
output = iwconfig
|
||||
return self._get_link_quality(output)
|
||||
@@ -1329,9 +1356,7 @@ class BaseWirelessInterface(BaseInterface):
|
||||
|
||||
"""
|
||||
if not iwconfig:
|
||||
cmd = 'iwconfig ' + self.iface
|
||||
if self.verbose: print cmd
|
||||
output = misc.Run(cmd)
|
||||
output = self.GetIwconfig()
|
||||
else:
|
||||
output = iwconfig
|
||||
signaldbm_pattern = re.compile('.*Signal level:?=? ?(-\d\d*)',
|
||||
@@ -1348,9 +1373,7 @@ class BaseWirelessInterface(BaseInterface):
|
||||
|
||||
"""
|
||||
if not iwconfig:
|
||||
cmd = 'iwconfig ' + self.iface
|
||||
if self.verbose: print cmd
|
||||
output = misc.Run(cmd)
|
||||
output = self.GetIwconfig()
|
||||
else:
|
||||
output = iwconfig
|
||||
network = misc.RunRegex(re.compile('.*ESSID:"(.*?)"',
|
||||
|
||||
Reference in New Issue
Block a user