mirror of
https://github.com/gryf/wicd.git
synced 2026-01-04 12:54:12 +01:00
Merged with r328 of experimental-nacl.
This commit is contained in:
@@ -79,17 +79,11 @@ for i in language.keys():
|
|||||||
########################################
|
########################################
|
||||||
##### SUPPORT CLASSES
|
##### SUPPORT CLASSES
|
||||||
########################################
|
########################################
|
||||||
# A hack to get any errors that pop out of the program to appear ***AFTER*** the
|
# Yay for decorators!
|
||||||
# program exits.
|
def wrap_exceptions(func):
|
||||||
# I also may have been a bit overkill about using this too, I guess I'll find
|
def wrapper(*args, **kargs):
|
||||||
# that out soon enough.
|
|
||||||
# I learned about this from this example:
|
|
||||||
# http://blog.lutzky.net/2007/09/16/exception-handling-decorators-and-python/
|
|
||||||
class wrap_exceptions:
|
|
||||||
def __call__(self, f):
|
|
||||||
def wrap_exceptions(*args, **kargs):
|
|
||||||
try:
|
try:
|
||||||
return f(*args, **kargs)
|
return func(*args, **kargs)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
#gobject.source_remove(redraw_tag)
|
#gobject.source_remove(redraw_tag)
|
||||||
loop.quit()
|
loop.quit()
|
||||||
@@ -117,7 +111,11 @@ class wrap_exceptions:
|
|||||||
#sleep(2)
|
#sleep(2)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
return wrap_exceptions
|
wrapper.__name__ = func.__name__
|
||||||
|
wrapper.__module__ = func.__module__
|
||||||
|
wrapper.__dict__ = func.__dict__
|
||||||
|
wrapper.__doc__ = func.__doc__
|
||||||
|
return wrapper
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
##### SUPPORT FUNCTIONS
|
##### SUPPORT FUNCTIONS
|
||||||
@@ -125,7 +123,7 @@ class wrap_exceptions:
|
|||||||
|
|
||||||
# Look familiar? These two functions are clones of functions found in wicd's
|
# Look familiar? These two functions are clones of functions found in wicd's
|
||||||
# gui.py file, except that now set_status is a function passed to them.
|
# gui.py file, except that now set_status is a function passed to them.
|
||||||
@wrap_exceptions()
|
@wrap_exceptions
|
||||||
def check_for_wired(wired_ip,set_status):
|
def check_for_wired(wired_ip,set_status):
|
||||||
""" Determine if wired is active, and if yes, set the status. """
|
""" Determine if wired is active, and if yes, set the status. """
|
||||||
if wired_ip and wired.CheckPluggedIn():
|
if wired_ip and wired.CheckPluggedIn():
|
||||||
@@ -134,7 +132,7 @@ def check_for_wired(wired_ip,set_status):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@wrap_exceptions()
|
@wrap_exceptions
|
||||||
def check_for_wireless(iwconfig, wireless_ip, set_status):
|
def check_for_wireless(iwconfig, wireless_ip, set_status):
|
||||||
""" Determine if wireless is active, and if yes, set the status. """
|
""" Determine if wireless is active, and if yes, set the status. """
|
||||||
if not wireless_ip:
|
if not wireless_ip:
|
||||||
@@ -586,6 +584,7 @@ class appGUI():
|
|||||||
self.connecting = False
|
self.connecting = False
|
||||||
self.screen_locked = False
|
self.screen_locked = False
|
||||||
self.do_diag_lock = False
|
self.do_diag_lock = False
|
||||||
|
self.scanning = False
|
||||||
|
|
||||||
self.pref = None
|
self.pref = None
|
||||||
|
|
||||||
@@ -593,6 +592,11 @@ class appGUI():
|
|||||||
|
|
||||||
#self.dialog = PrefOverlay(self.frame,self.size)
|
#self.dialog = PrefOverlay(self.frame,self.size)
|
||||||
|
|
||||||
|
def doScan(self, sync=False):
|
||||||
|
self.scanning = True
|
||||||
|
wireless.Scan(False)
|
||||||
|
|
||||||
|
|
||||||
def init_other_optcols(self):
|
def init_other_optcols(self):
|
||||||
# The "tabbed" preferences dialog
|
# The "tabbed" preferences dialog
|
||||||
self.prefCols = OptCols( [('meta enter','OK'),
|
self.prefCols = OptCols( [('meta enter','OK'),
|
||||||
@@ -631,7 +635,7 @@ class appGUI():
|
|||||||
# That dialog will sit there for a while if I don't get rid of it
|
# That dialog will sit there for a while if I don't get rid of it
|
||||||
self.update_ui()
|
self.update_ui()
|
||||||
wireless.SetHiddenNetworkESSID(misc.noneToString(hidden))
|
wireless.SetHiddenNetworkESSID(misc.noneToString(hidden))
|
||||||
wireless.Scan(True)
|
wireless.Scan(False)
|
||||||
wireless.SetHiddenNetworkESSID("")
|
wireless.SetHiddenNetworkESSID("")
|
||||||
|
|
||||||
def update_focusloc(self):
|
def update_focusloc(self):
|
||||||
@@ -653,7 +657,7 @@ class appGUI():
|
|||||||
|
|
||||||
# Be clunky until I get to a later stage of development.
|
# Be clunky until I get to a later stage of development.
|
||||||
# Update the list of networks. Usually called by DBus.
|
# Update the list of networks. Usually called by DBus.
|
||||||
@wrap_exceptions()
|
@wrap_exceptions
|
||||||
def update_netlist(self,state=None, x=None, force_check=False,firstrun=False):
|
def update_netlist(self,state=None, x=None, force_check=False,firstrun=False):
|
||||||
# Don't even try to do this if we are running a dialog
|
# Don't even try to do this if we are running a dialog
|
||||||
if self.diag:
|
if self.diag:
|
||||||
@@ -678,7 +682,7 @@ class appGUI():
|
|||||||
else:
|
else:
|
||||||
self.wlessLB.body = urwid.SimpleListWalker(wlessL)
|
self.wlessLB.body = urwid.SimpleListWalker(wlessL)
|
||||||
else:
|
else:
|
||||||
self.wlessLB = self.no_wlan
|
self.wlesslb = self.no_wlan
|
||||||
if daemon.GetAlwaysShowWiredInterface() or wired.CheckPluggedIn():
|
if daemon.GetAlwaysShowWiredInterface() or wired.CheckPluggedIn():
|
||||||
#if daemon.GetAlwaysShowWiredInterface():
|
#if daemon.GetAlwaysShowWiredInterface():
|
||||||
#if firstrun:
|
#if firstrun:
|
||||||
@@ -694,7 +698,7 @@ class appGUI():
|
|||||||
if self.focusloc[0] == self.WIRED_IDX:
|
if self.focusloc[0] == self.WIRED_IDX:
|
||||||
self.thePile.get_focus().get_body().set_focus(self.focusloc[1])
|
self.thePile.get_focus().get_body().set_focus(self.focusloc[1])
|
||||||
else:
|
else:
|
||||||
if self.wlessLB is not self.no_wlan:
|
if self.wlessLB != self.no_wlan:
|
||||||
self.thePile.get_focus().set_focus(self.focusloc[1])
|
self.thePile.get_focus().set_focus(self.focusloc[1])
|
||||||
else:
|
else:
|
||||||
self.thePile.set_focus(self.wiredCB)
|
self.thePile.set_focus(self.wiredCB)
|
||||||
@@ -715,7 +719,7 @@ class appGUI():
|
|||||||
|
|
||||||
# Update the footer/status bar
|
# Update the footer/status bar
|
||||||
conn_status = False
|
conn_status = False
|
||||||
@wrap_exceptions()
|
@wrap_exceptions
|
||||||
def update_status(self):
|
def update_status(self):
|
||||||
wired_connecting = wired.CheckIfWiredConnecting()
|
wired_connecting = wired.CheckIfWiredConnecting()
|
||||||
wireless_connecting = wireless.CheckIfWirelessConnecting()
|
wireless_connecting = wireless.CheckIfWirelessConnecting()
|
||||||
@@ -803,26 +807,28 @@ class appGUI():
|
|||||||
# Make sure the screen is still working by providing a pretty counter.
|
# Make sure the screen is still working by providing a pretty counter.
|
||||||
# Not necessary in the end, but I will be using footer1 for stuff in
|
# Not necessary in the end, but I will be using footer1 for stuff in
|
||||||
# the long run, so I might as well put something there.
|
# the long run, so I might as well put something there.
|
||||||
#@wrap_exceptions()
|
#@wrap_exceptions
|
||||||
def update_time(self):
|
def update_time(self):
|
||||||
self.time_label.set_text(strftime('%H:%M:%S'))
|
self.time_label.set_text(strftime('%H:%M:%S'))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# Yeah, I'm copying code. Anything wrong with that?
|
# Yeah, I'm copying code. Anything wrong with that?
|
||||||
#@wrap_exceptions()
|
#@wrap_exceptions
|
||||||
def dbus_scan_finished(self):
|
def dbus_scan_finished(self):
|
||||||
# I'm pretty sure that I'll need this later.
|
# I'm pretty sure that I'll need this later.
|
||||||
#if not self.connecting:
|
#if not self.connecting:
|
||||||
# gobject.idle_add(self.refresh_networks, None, False, None)
|
# gobject.idle_add(self.refresh_networks, None, False, None)
|
||||||
self.unlock_screen()
|
self.unlock_screen()
|
||||||
|
self.scanning = False
|
||||||
|
|
||||||
# Same, same, same, same, same, same
|
# Same, same, same, same, same, same
|
||||||
#@wrap_exceptions()
|
#@wrap_exceptions
|
||||||
def dbus_scan_started(self):
|
def dbus_scan_started(self):
|
||||||
|
self.scanning = True
|
||||||
self.lock_screen()
|
self.lock_screen()
|
||||||
|
|
||||||
def restore_primary(self):
|
def restore_primary(self):
|
||||||
if self.do_diag_lock:
|
if self.do_diag_lock or self.scanning:
|
||||||
self.frame.set_body(self.screen_locker)
|
self.frame.set_body(self.screen_locker)
|
||||||
self.do_diag_lock = False
|
self.do_diag_lock = False
|
||||||
else:
|
else:
|
||||||
@@ -839,23 +845,24 @@ class appGUI():
|
|||||||
#return False
|
#return False
|
||||||
if "f5" in keys or 'R' in keys:
|
if "f5" in keys or 'R' in keys:
|
||||||
self.lock_screen()
|
self.lock_screen()
|
||||||
wireless.Scan(True)
|
self.doScan()
|
||||||
if "D" in keys:
|
if "D" in keys:
|
||||||
# Disconnect from all networks.
|
# Disconnect from all networks.
|
||||||
daemon.Disconnect()
|
daemon.Disconnect()
|
||||||
self.update_netlist()
|
self.update_netlist()
|
||||||
if 'right' in keys:
|
if 'right' in keys:
|
||||||
focus = self.thePile.get_focus()
|
if not self.scanning:
|
||||||
self.frame.set_footer(urwid.Pile([self.confCols,self.footer2]))
|
focus = self.thePile.get_focus()
|
||||||
if focus == self.wiredCB:
|
self.frame.set_footer(urwid.Pile([self.confCols,self.footer2]))
|
||||||
self.diag = WiredSettingsDialog(self.wiredCB.get_body().get_selected_profile())
|
if focus == self.wiredCB:
|
||||||
self.frame.set_body(self.diag)
|
self.diag = WiredSettingsDialog(self.wiredCB.get_body().get_selected_profile())
|
||||||
else:
|
self.frame.set_body(self.diag)
|
||||||
# wireless list only other option
|
else:
|
||||||
wid,pos = self.thePile.get_focus().get_focus()
|
# wireless list only other option
|
||||||
self.diag = WirelessSettingsDialog(pos,self.frame)
|
wid,pos = self.thePile.get_focus().get_focus()
|
||||||
self.diag.ready_widgets(ui,self.frame)
|
self.diag = WirelessSettingsDialog(pos,self.frame)
|
||||||
self.frame.set_body(self.diag)
|
self.diag.ready_widgets(ui,self.frame)
|
||||||
|
self.frame.set_body(self.diag)
|
||||||
# Guess what! I actually need to put this here, else I'll have
|
# Guess what! I actually need to put this here, else I'll have
|
||||||
# tons of references to self.frame lying around. ^_^
|
# tons of references to self.frame lying around. ^_^
|
||||||
if "enter" in keys:
|
if "enter" in keys:
|
||||||
@@ -945,7 +952,7 @@ class appGUI():
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# Redraw the screen
|
# Redraw the screen
|
||||||
@wrap_exceptions()
|
@wrap_exceptions
|
||||||
def update_ui(self):
|
def update_ui(self):
|
||||||
#self.update_status()
|
#self.update_status()
|
||||||
canvas = self.frame.render( (self.size),True )
|
canvas = self.frame.render( (self.size),True )
|
||||||
@@ -988,7 +995,7 @@ def main():
|
|||||||
if options.screen == 'raw':
|
if options.screen == 'raw':
|
||||||
import urwid.raw_display
|
import urwid.raw_display
|
||||||
ui = urwid.raw_display.Screen()
|
ui = urwid.raw_display.Screen()
|
||||||
elif options.screen is 'curses':
|
elif options.screen == 'curses':
|
||||||
import urwid.curses_display
|
import urwid.curses_display
|
||||||
ui = urwid.curses_display.Screen()
|
ui = urwid.curses_display.Screen()
|
||||||
|
|
||||||
|
|||||||
93
setup.py
93
setup.py
@@ -2,6 +2,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2007 - 2009 Adam Blackburn
|
# Copyright (C) 2007 - 2009 Adam Blackburn
|
||||||
# Copyright (C) 2007 - 2009 Dan O'Reilly
|
# Copyright (C) 2007 - 2009 Dan O'Reilly
|
||||||
|
# Copyright (C) 2009 Andrew Psaltis
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License Version 2 as
|
# it under the terms of the GNU General Public License Version 2 as
|
||||||
@@ -84,6 +85,7 @@ class configure(Command):
|
|||||||
('initfile=', None, 'set the init file to use'),
|
('initfile=', None, 'set the init file to use'),
|
||||||
('initfilename=', None, "set the name of the init file (don't use)"),
|
('initfilename=', None, "set the name of the init file (don't use)"),
|
||||||
('wicdgroup=', None, "set the name of the group used for wicd"),
|
('wicdgroup=', None, "set the name of the group used for wicd"),
|
||||||
|
('distro=', None, 'set the distribution for which wicd will be installed'),
|
||||||
|
|
||||||
# Configure switches
|
# Configure switches
|
||||||
('no-install-init', None, "do not install the init file"),
|
('no-install-init', None, "do not install the init file"),
|
||||||
@@ -120,6 +122,7 @@ class configure(Command):
|
|||||||
self.docdir = '/usr/share/doc/wicd/'
|
self.docdir = '/usr/share/doc/wicd/'
|
||||||
self.mandir = '/usr/share/man/'
|
self.mandir = '/usr/share/man/'
|
||||||
self.kdedir = '/usr/share/autostart/'
|
self.kdedir = '/usr/share/autostart/'
|
||||||
|
self.distro = 'auto'
|
||||||
|
|
||||||
self.no_install_init = False
|
self.no_install_init = False
|
||||||
self.no_install_man = False
|
self.no_install_man = False
|
||||||
@@ -131,49 +134,38 @@ class configure(Command):
|
|||||||
self.no_use_notifications = False
|
self.no_use_notifications = False
|
||||||
|
|
||||||
# Determine the default init file location on several different distros
|
# Determine the default init file location on several different distros
|
||||||
|
|
||||||
self.distro_detect_failed = False
|
self.distro_detect_failed = False
|
||||||
|
|
||||||
self.initfile = 'init/default/wicd'
|
self.initfile = 'init/default/wicd'
|
||||||
|
# ddistro is the detected distro
|
||||||
if os.path.exists('/etc/redhat-release'):
|
if os.path.exists('/etc/redhat-release'):
|
||||||
self.init = '/etc/rc.d/init.d/'
|
self.ddistro = 'redhat'
|
||||||
self.initfile = 'init/redhat/wicd'
|
|
||||||
elif os.path.exists('/etc/SuSE-release'):
|
elif os.path.exists('/etc/SuSE-release'):
|
||||||
self.init = '/etc/init.d/'
|
self.ddistro = 'suse'
|
||||||
self.initfile = 'init/suse/wicd'
|
|
||||||
elif os.path.exists('/etc/fedora-release'):
|
elif os.path.exists('/etc/fedora-release'):
|
||||||
self.init = '/etc/rc.d/init.d/'
|
self.ddistro = 'redhat'
|
||||||
self.initfile = 'init/redhat/wicd'
|
|
||||||
elif os.path.exists('/etc/gentoo-release'):
|
elif os.path.exists('/etc/gentoo-release'):
|
||||||
self.init = '/etc/init.d/'
|
self.ddistro = 'gentoo'
|
||||||
self.initfile = 'init/gentoo/wicd'
|
|
||||||
elif os.path.exists('/etc/debian_version'):
|
elif os.path.exists('/etc/debian_version'):
|
||||||
self.init = '/etc/init.d/'
|
self.ddistro = 'debian'
|
||||||
self.initfile = 'init/debian/wicd'
|
|
||||||
elif os.path.exists('/etc/arch-release'):
|
elif os.path.exists('/etc/arch-release'):
|
||||||
self.init = '/etc/rc.d/'
|
self.ddistro = 'arch'
|
||||||
self.initfile = 'init/arch/wicd'
|
|
||||||
elif os.path.exists('/etc/slackware-version') or \
|
elif os.path.exists('/etc/slackware-version') or \
|
||||||
os.path.exists('/etc/slamd64-version'):
|
os.path.exists('/etc/slamd64-version') or \
|
||||||
self.init = '/etc/rc.d/'
|
os.path.exists('/etc/bluewhite64-version'):
|
||||||
self.initfile = 'init/slackware/rc.wicd'
|
self.ddistro = 'slackware'
|
||||||
self.docdir = '/usr/doc/wicd-%s' % VERSION_NUM
|
|
||||||
self.mandir = '/usr/man/'
|
|
||||||
self.no_install_acpi = True
|
|
||||||
elif os.path.exists('/etc/pld-release'):
|
elif os.path.exists('/etc/pld-release'):
|
||||||
self.init = '/etc/rc.d/init.d/'
|
self.ddistro = 'pld'
|
||||||
self.initfile = 'init/pld/wicd'
|
|
||||||
elif os.path.exists('/usr/bin/crux'):
|
elif os.path.exists('/usr/bin/crux'):
|
||||||
self.init = '/etc/rc.d/'
|
self.ddistro = 'crux'
|
||||||
elif os.path.exists('/etc/lunar.release'):
|
elif os.path.exists('/etc/lunar.release'):
|
||||||
self.init='/etc/init.d/'
|
self.distro = 'lunar'
|
||||||
self.initfile = 'init/lunar/wicd'
|
|
||||||
else:
|
else:
|
||||||
self.init = 'FAIL'
|
self.ddistro = 'FAIL'
|
||||||
self.no_install_init = True
|
#self.no_install_init = True
|
||||||
self.distro_detect_failed = True
|
#self.distro_detect_failed = True
|
||||||
print 'WARNING: Unable to detect the distribution in use. ' + \
|
print 'WARNING: Unable to detect the distribution in use. ' + \
|
||||||
'If you have specified --init and --initfile, configure will continue. ' + \
|
'If you have specified --distro or --init and --initfile, configure will continue. ' + \
|
||||||
'Please report this warning, along with the name of your ' + \
|
'Please report this warning, along with the name of your ' + \
|
||||||
'distribution, to the wicd developers.'
|
'distribution, to the wicd developers.'
|
||||||
|
|
||||||
@@ -229,7 +221,52 @@ class configure(Command):
|
|||||||
self.initfilename = os.path.basename(self.initfile)
|
self.initfilename = os.path.basename(self.initfile)
|
||||||
self.wicdgroup = 'users'
|
self.wicdgroup = 'users'
|
||||||
|
|
||||||
|
def distro_check(self):
|
||||||
|
print "Distro is: "+self.distro
|
||||||
|
if self.distro in ['sles','suse']:
|
||||||
|
self.init = '/etc/init.d/'
|
||||||
|
self.initfile = 'init/suse/wicd'
|
||||||
|
elif self.distro in ['redhat','centos','fedora']:
|
||||||
|
self.init = '/etc/rc.d/init.d/'
|
||||||
|
self.initfile = 'init/redhat/wicd'
|
||||||
|
elif self.distro in ['slackware','slamd64','bluewhite64']:
|
||||||
|
self.init = '/etc/rc.d/'
|
||||||
|
self.initfile = 'init/slackware/rc.wicd'
|
||||||
|
self.docdir = '/usr/doc/wicd-%s' % VERSION_NUM
|
||||||
|
self.mandir = '/usr/man/'
|
||||||
|
self.no_install_acpi = True
|
||||||
|
elif self.distro in ['debian']:
|
||||||
|
self.init = '/etc/init.d/'
|
||||||
|
self.initfile = 'init/debian/wicd'
|
||||||
|
elif self.distro in ['arch']:
|
||||||
|
self.init = '/etc/rc.d/'
|
||||||
|
self.initfile = 'init/arch/wicd'
|
||||||
|
elif self.distro in ['gentoo']:
|
||||||
|
self.init = '/etc/init.d/'
|
||||||
|
self.initfile = 'init/gentoo/wicd'
|
||||||
|
elif self.distro in ['pld']:
|
||||||
|
self.init = '/etc/rc.d/init.d/'
|
||||||
|
self.initfile = 'init/pld/wicd'
|
||||||
|
elif self.distro in ['crux']:
|
||||||
|
self.init = '/etc/rc.d/'
|
||||||
|
elif self.distro in ['lunar']:
|
||||||
|
self.init='/etc/init.d/'
|
||||||
|
self.initfile = 'init/lunar/wicd'
|
||||||
|
else :
|
||||||
|
if self.distro == 'auto':
|
||||||
|
print "NOTICE: Automatic distro detection found: "+self.ddistro+", retrying with that..."
|
||||||
|
self.distro = self.ddistro
|
||||||
|
self.distro_check()
|
||||||
|
else:
|
||||||
|
print "WARNING: Distro detection failed!"
|
||||||
|
self.init='init/default/wicd'
|
||||||
|
self.no_install_init = True
|
||||||
|
self.distro_detect_failed = True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
|
self.distro_check()
|
||||||
if self.distro_detect_failed and not self.no_install_init and \
|
if self.distro_detect_failed and not self.no_install_init and \
|
||||||
'FAIL' in [self.init, self.initfile]:
|
'FAIL' in [self.init, self.initfile]:
|
||||||
print 'ERROR: Failed to detect distro. Configure cannot continue. ' + \
|
print 'ERROR: Failed to detect distro. Configure cannot continue. ' + \
|
||||||
|
|||||||
Reference in New Issue
Block a user