1
0
mirror of https://github.com/gryf/wicd.git synced 2026-01-05 13:24:13 +01:00

Changed misc.Run to use subprocess.Popen instead of os.popen. Also altered Run to optionally return a pipe to the command run, instead of just the output.

The output of dhclient is now parsed by wicd and used to determine why the connection failed.
All the wpa_supplicant conf files will now generate a ctrl_interface, so that they can be accessed by wpa_cli.  wpa_cli now is used by wicd to attempt to determine is wpa_supplicant authentication was successful.  This is still experimental, and might have to be tweaked to work properly.
If wicd.py is started and the daemon isn't present, it will autolaunch it by calling launchdaemon.sh, instead of asking the user to start the daemon manually.
Cleaned up some comments, formatting, etc.
Probably a couple of other little bug fixes I'm forgetting.
This commit is contained in:
imdano
2008-01-06 13:55:23 +00:00
parent 4e0dfc8e22
commit d64850dfd3
16 changed files with 354 additions and 155 deletions

27
wicd.py
View File

@@ -42,6 +42,7 @@ import gobject
import dbus
import dbus.service
import getopt
import time
# Import egg.trayicon if we're using an older gtk version
if not (gtk.gtk_version[0] >= 2 and gtk.gtk_version[1] >= 10):
@@ -80,8 +81,15 @@ try:
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
print 'Success.'
except Exception:
print 'Daemon not running...'
print 'Can\'t connect to the daemon, trying to start it automatically...'
misc.PromptToStartDaemon()
time.sleep(1)
try:
print 'Attempting to connect tray to daemon...'
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon')
print 'Success.'
except:
print 'Failed to start daemon. Aborting.'
sys.exit(1)
daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon')
@@ -108,12 +116,12 @@ class TrayIcon():
self.tr = self.EggTrayIconGUI(use_tray)
else:
self.tr = self.StatusTrayIconGUI(use_tray)
self.icon_info = self.TrayConnectionInfo(self.tr)
self.icon_info = self.TrayConnectionInfo(self.tr, use_tray)
class TrayConnectionInfo():
"""Class for updating the tray icon status"""
def __init__(self, tr):
def __init__(self, tr, use_tray=True):
"""Initialize variables needed for the icon status methods."""
self.last_strength = -2
self.still_wired = False
@@ -121,6 +129,7 @@ class TrayIcon():
self.tried_reconnect = False
self.connection_lost_counter = 0
self.tr = tr
self.use_tray = use_tray
self.update_tray_icon()
def wired_profile_chooser(self):
@@ -130,6 +139,7 @@ class TrayIcon():
def update_tray_icon(self):
"""Updates the tray icon and current connection status"""
if self.use_tray == False: return False
# If we're currently connecting, we can shortcut all other checks
if daemon.CheckIfConnecting():
@@ -205,7 +215,9 @@ class TrayIcon():
class TrayIconGUI():
"""Base Tray Icon class
Implements methods and variables used by both egg/StatusIcon tray icons.
Implements methods and variables used by both egg/StatusIcon
tray icons.
"""
def __init__(self, use_tray):
menu = """
@@ -396,20 +408,18 @@ def main(argv):
if opt in ('-h', '--help'):
usage()
sys.exit()
if opt in ('-n', '--no-tray'):
elif opt in ('-n', '--no-tray'):
use_tray = False
# Redirect stderr and stdout for logging purposes
#sys.stderr = log
#sys.stdout = log
print 'Done initalizing, starting...'
# Set up the tray icon GUI and backend
tray_icon = TrayIcon(use_tray)
# Check to see if wired profile chooser was called before icon
# was launched (typically happens on startup or daemon restart)
# was launched (typically happens on startup or daemon restart).
if daemon.GetNeedWiredProfileChooser():
daemon.SetNeedWiredProfileChooser(False)
tray_icon.icon_info.wired_profile_chooser()
@@ -419,6 +429,7 @@ def main(argv):
bus.add_signal_receiver(tray_icon.icon_info.update_tray_icon,
'StatusChanged', 'org.wicd.daemon')
print 'Done.'
mainloop = gobject.MainLoop()
mainloop.run()