mirror of
https://github.com/gryf/wicd.git
synced 2025-12-20 21:08:06 +01:00
Redid the decorator to look like the other exception-catching decorators in wicd.
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:
|
||||||
@@ -659,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:
|
||||||
@@ -721,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()
|
||||||
@@ -809,13 +807,13 @@ 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:
|
||||||
@@ -824,7 +822,7 @@ class appGUI():
|
|||||||
self.scanning = False
|
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.scanning = True
|
||||||
self.lock_screen()
|
self.lock_screen()
|
||||||
@@ -954,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 )
|
||||||
|
|||||||
Reference in New Issue
Block a user