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

merged latest 1.6

This commit is contained in:
Adam Blackburn
2009-08-09 18:07:22 -05:00
18 changed files with 302 additions and 155 deletions

View File

@@ -288,7 +288,7 @@ class WirelessInterface(Interface, BaseWirelessInterface):
try:
results = self.scan_iface.Scan()
except iwscan.error, e:
print "ERROR: %s"
print "ERROR: %s" % e
return []
return filter(None, [self._parse_ap(cell) for cell in results])

View File

@@ -111,12 +111,12 @@ class ConfigManager(RawConfigParser):
except (ValueError, TypeError, AttributeError):
ret = Noneify(ret)
# This is a workaround for a python-dbus issue on 64-bit systems.
if isinstance(ret, (int)):
if isinstance(ret, (int, long)):
try:
Int32(ret)
except OverflowError:
ret = long(ret)
return ret
ret = str(ret)
return to_unicode(ret)
def get(self, *args, **kargs):
""" Calls the get_option method """

View File

@@ -182,6 +182,8 @@ def WriteLine(my_file, text):
def ExecuteScripts(scripts_dir, verbose=False, extra_parameters=()):
""" Execute every executable file in a given directory. """
if not os.path.exists(scripts_dir):
return
for obj in os.listdir(scripts_dir):
obj = os.path.abspath(os.path.join(scripts_dir, obj))
if os.path.isfile(obj) and os.access(obj, os.X_OK):

View File

@@ -655,17 +655,16 @@ class WiredNetworkEntry(NetworkEntry):
def add_profile(self, widget):
""" Add a profile to the profile list. """
print "adding profile"
response = string_input("Enter a profile name", "The profile name " +
"will not be used by the computer. It " +
"allows you to " +
"easily distinguish between different network " +
"profiles.", "Profile name:")
"profiles.", "Profile name:").strip()
# if response is "" or None
if not response:
return
error(None, "Invalid profile name", block=True)
return False
profile_name = response
profile_list = wired.GetWiredProfileList()

View File

@@ -729,7 +729,7 @@ class Wireless(Controller):
wiface = self.wiface
print 'Creating ad-hoc network'
print 'Stopping dhcp client and wpa_supplicant'
BACKEND.ReleaseDHCP()
wiface.ReleaseDHCP()
wiface.StopWPA()
print 'Putting wireless interface down'
wiface.Down()
@@ -880,7 +880,8 @@ class WirelessConnectThread(ConnectThread):
if self.network.get('enctype'):
self.SetStatus('validating_authentication')
if not wiface.ValidateAuthentication(time.time()):
if not self.connect_result:
print "connect result is %s" % self.connect_result
if not self.connect_result or self.connect_result == 'Failed':
self.abort_connection('bad_pass')
# Set up gateway, IP address, and DNS servers.

View File

@@ -100,7 +100,7 @@ class PreferencesDialog(object):
sudo_list = [self.sudoautoradio, self.gksudoradio, self.kdesuradio,
self.ktsussradio]
self._setup_external_app_radios(sudo_list, daemon.GetSudoApp,
daemon.SetAudoApp)
daemon.SetSudoApp)
auto_conn_meth = daemon.GetWiredAutoConnectMethod()
if auto_conn_meth == 1:

View File

@@ -44,18 +44,17 @@ def get_gettext():
lc, encoding = locale.getdefaultlocale(envvars=('LC_MESSAGES',
'LC_ALL', 'LANG',
'LANGUAGE'))
langs += [lc]
except ValueError, e:
print str(e)
print "Default locale unavailable, falling back to en_US"
if (lc):
langs += [lc]
langs += ["en_US"]
lang = gettext.translation('wicd', local_path, languages=langs,
fallback=True)
_ = lang.gettext
return _
# Generated automatically on Sat, 20 Jun 2009 21:58:21 CDT
# Generated automatically on Sun, 05 Jul 2009 13:51:18 CDT
_ = get_gettext()
language = {}
language['resetting_ip_address'] = _('''Resetting IP address...''')
@@ -214,7 +213,7 @@ language['connection_established'] = _('''Connection established''')
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 daemon due to an access denied error from DBus. Please check your DBus configuration.''')
language['access_denied'] = _('''Unable to contact the Wicd daemon due to an access denied error from DBus. Please check that your user is in the $A group.''')
language['disconnecting_active'] = _('''Disconnecting active connections...''')
language['access_denied_wc'] = _('''ERROR: wicd-curses was denied access to the wicd daemon: please check that your user is in the "$A" group.''')
language['post_disconnect_script'] = _('''Run post-disconnect script''')

View File

@@ -88,7 +88,7 @@ def catchdbus(func):
return func(*args, **kwargs)
except DBusException, e:
if e.get_dbus_name() != None and "DBus.Error.AccessDenied" in e.get_dbus_name():
error(None, language['access_denied'])
error(None, language['access_denied'].replace("$A","<b>"+wpath.wicd_group+"</b>"))
#raise
raise DBusException(e)
else:
@@ -121,13 +121,15 @@ class TrayIcon(object):
Base Class for implementing a tray icon to display network status.
"""
def __init__(self, animate):
def __init__(self, animate, displaytray=True):
if USE_EGG:
self.tr = self.EggTrayIconGUI()
else:
self.tr = self.StatusTrayIconGUI()
self.icon_info = self.TrayConnectionInfo(self.tr, animate)
self.tr.icon_info = self.icon_info
print 'displaytray %s' % displaytray
self.tr.visible(displaytray)
def is_embedded(self):
if USE_EGG:
@@ -666,6 +668,18 @@ class TrayIcon(object):
"""
self.tooltip.set_tip(self.eb, val)
def visible(self, val):
""" Set if the icon is visible or not.
If val is True, makes the icon visible, if val is False,
hides the tray icon.
"""
if val:
self.tray.show_all()
else:
self.tray.hide_all()
if hasattr(gtk, "StatusIcon"):
class StatusTrayIconGUI(gtk.StatusIcon, TrayIconGUI):
@@ -696,6 +710,14 @@ class TrayIcon(object):
self.current_icon_path = path
gtk.StatusIcon.set_from_file(self, path)
def visible(self, val):
""" Set if the icon is visible or not.
If val is True, makes the icon visible, if val is False,
hides the tray icon.
"""
self.set_visible(val)
def usage():
""" Print usage information. """
@@ -707,6 +729,7 @@ Arguments:
\t-n\t--no-tray\tRun wicd without the tray icon.
\t-h\t--help\t\tPrint this help information.
\t-a\t--no-animate\tRun the tray without network traffic tray animations.
\t-o\t--only-notifications\tDon't display anything except notifications.
""" % wpath.version
def setup_dbus(force=True):
@@ -764,8 +787,9 @@ def main(argv):
"""
try:
opts, args = getopt.getopt(sys.argv[1:], 'nha', ['help', 'no-tray',
'no-animate'])
opts, args = getopt.getopt(sys.argv[1:], 'nhao', ['help', 'no-tray',
'no-animate',
'only-notifications'])
except getopt.GetoptError:
# Print help information and exit
usage()
@@ -773,6 +797,7 @@ def main(argv):
use_tray = True
animate = True
display_app = True
for opt, a in opts:
if opt in ('-h', '--help'):
usage()
@@ -781,6 +806,10 @@ def main(argv):
use_tray = False
elif opt in ('-a', '--no-animate'):
animate = False
elif opt in ('-o', '--only-notifications'):
print "only displaying notifications"
use_tray = False
display_app = False
else:
usage()
sys.exit(2)
@@ -789,14 +818,14 @@ def main(argv):
setup_dbus()
atexit.register(on_exit)
if not use_tray or not ICON_AVAIL:
if display_app and not use_tray or not ICON_AVAIL:
the_gui = gui.appGui(standalone=True)
mainloop = gobject.MainLoop()
mainloop.run()
sys.exit(0)
# Set up the tray icon GUI and backend
tray_icon = TrayIcon(animate)
tray_icon = TrayIcon(animate, displaytray=display_app)
# Check to see if wired profile chooser was called before icon
# was launched (typically happens on startup or daemon restart).

View File

@@ -84,7 +84,7 @@ class WicdDaemon(dbus.service.Object):
self._debug_mode = bool(self.config.get("Settings", "debug_mode"))
self.wifi = networking.Wireless(debug=self._debug_mode)
self.wired = networking.Wired(debug=self._debug_mode)
self.wired_bus= WiredDaemon(bus_name, self, wired=self.wired)
self.wired_bus = WiredDaemon(bus_name, self, wired=self.wired)
self.wireless_bus = WirelessDaemon(bus_name, self, wifi=self.wifi)
self.forced_disconnect = False
self.need_profile_chooser = False
@@ -518,7 +518,7 @@ class WicdDaemon(dbus.service.Object):
# 1 = default profile
# 2 = show list
# 3 = last used profile
self.config.set("Settings","wired_connect_mode", int(method),
self.config.set("Settings", "wired_connect_mode", int(method),
write=True)
self.wired_connect_mode = int(method)
self.wired_bus.connect_mode = int(method)
@@ -856,7 +856,7 @@ class WicdDaemon(dbus.service.Object):
"""
b_wired = self.wired_bus
b_wifi = self.wireless_bus
app_conf= self.config
app_conf = self.config
# Load the backend.
be_def = 'external'
self.SetBackend(app_conf.get("Settings", "backend", default=be_def))
@@ -880,7 +880,7 @@ class WicdDaemon(dbus.service.Object):
dns1 = app_conf.get("Settings", "global_dns_1", default='None')
dns2 = app_conf.get("Settings", "global_dns_2", default='None')
dns3 = app_conf.get("Settings", "global_dns_3", default='None')
dns_dom =app_conf.get("Settings", "global_dns_dom", default='None')
dns_dom = app_conf.get("Settings", "global_dns_dom", default='None')
search_dom = app_conf.get("Settings", "global_search_dom", default='None')
self.SetGlobalDNS(dns1, dns2, dns3, dns_dom, search_dom)
self.SetAutoReconnect(app_conf.get("Settings", "auto_reconnect",
@@ -1055,14 +1055,14 @@ class WirelessDaemon(dbus.service.Object):
return value
@dbus.service.method('org.wicd.daemon.wireless')
def SetWirelessProperty(self, networkid, property, value):
def SetWirelessProperty(self, netid, prop, value):
""" Sets property to value in network specified. """
# We don't write script settings here.
if (property.strip()).endswith("script"):
if (prop.strip()).endswith("script"):
print "Setting script properties through the daemon is not" \
+ " permitted."
return False
self.LastScan[networkid][property] = misc.Noneify(value)
self.LastScan[netid][prop] = misc.to_unicode(misc.Noneify(value))
@dbus.service.method('org.wicd.daemon.wireless')
def DetectWirelessInterface(self):
@@ -1201,6 +1201,8 @@ class WirelessDaemon(dbus.service.Object):
if cur_network["hidden"]:
if cur_network.get("essid") in ["", "Hidden", "<hidden>", None]:
cur_network["essid"] = "<hidden>"
else:
cur_network['essid'] = self.config.get(section, 'essid')
return "100: Loaded Profile"
@dbus.service.method('org.wicd.daemon.wireless')
@@ -1373,7 +1375,7 @@ class WiredDaemon(dbus.service.Object):
print "Setting script properties through the daemon" \
+ " is not permitted."
return False
self.WiredNetwork[property] = misc.Noneify(value)
self.WiredNetwork[property] = misc.to_unicode(misc.Noneify(value))
return True
else:
print 'SetWiredProperty: WiredNetwork does not exist'
@@ -1448,7 +1450,7 @@ class WiredDaemon(dbus.service.Object):
if self.config.has_section(profilename):
return False
for option in ["ip", "broadcast", "netmask","gateway", "search_domain",
for option in ["ip", "broadcast", "netmask", "gateway", "search_domain",
"dns_domain", "dns1", "dns2", "dns3", "beforescript",
"afterscript", "predisconnectscript",
"postdisconnectscript"]:
@@ -1506,8 +1508,10 @@ class WiredDaemon(dbus.service.Object):
if not self.config.has_option(prof, script):
self.config.set(prof, script, None)
if profilename == "":
profilename = profilename.strip()
if not profilename:
self.config.write()
print "Warning: Bad wired profile name given, ignoring."
return "500: Bad Profile name"
if self.debug_mode:
print "saving wired profile %s" % profilename

View File

@@ -171,7 +171,8 @@ def neediface(default_response):
"""
def wrapper(func):
def newfunc(self, *args, **kwargs):
if not self.iface:
if not self.iface or \
not os.path.exists('/sys/class/net/%s' % self.iface):
return default_response
return func(self, *args, **kwargs)
newfunc.__dict__ = func.__dict__