From fa626d2ac455519e753fa76344c762be22c8f120 Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Fri, 19 Jun 2009 17:29:25 -0400 Subject: [PATCH 1/6] Made wicd-curses.py spit out an error if a dbus access denied error appears on startup. --- curses/wicd-curses.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/curses/wicd-curses.py b/curses/wicd-curses.py index 042a224..fdce9ce 100755 --- a/curses/wicd-curses.py +++ b/curses/wicd-curses.py @@ -38,7 +38,6 @@ at least get a network connection. Or those who don't like using X. ;-) import warnings warnings.filterwarnings("ignore","The popen2 module is deprecated. Use the subprocess module.") # UI stuff -# This library is the only reason why I wrote this program. import urwid # DBus communication stuff @@ -64,6 +63,7 @@ import netentry_curses from netentry_curses import WirelessSettingsDialog, WiredSettingsDialog,AdvancedSettingsDialog from optparse import OptionParser +from os import system # Stuff about getting the script configurer running #from grp import getgrgid @@ -72,7 +72,7 @@ from optparse import OptionParser #import logging #import logging.handler -CURSES_REVNO=wpath.curses_revision +CURSES_REV=wpath.curses_revision # Fix strings in wicd-curses from wicd.translations import language @@ -1047,7 +1047,17 @@ setup_dbus() ##### MAIN ENTRY POINT ######################################## if __name__ == '__main__': - parser = OptionParser(version="wicd-curses-%s (using wicd %s)" % (CURSES_REVNO,daemon.Hello())) + try: + parser = OptionParser(version="wicd-curses-%s (using wicd %s)" % (CURSES_REV,daemon.Hello())) + except Exception as ex: + if "Rejected send message" in ex.args[0]: + print "" + system("\ +echo ERROR: wicd-curses was denied access to the wicd daemon, make sure that \ +your user is in the group \\'$(tput bold)$(tput setaf 4)"+ wpath.wicd_group+"$(tput sgr0)\\'.") + sys.exit(1) + else: + raise parser.set_defaults(screen='raw',debug=False) parser.add_option("-r", "--raw-screen",action="store_const",const='raw' ,dest='screen',help="use urwid's raw screen controller (default)") From 94e02277f35ea98b32de7271d3bed5996c5f6fda Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Fri, 19 Jun 2009 18:48:39 -0400 Subject: [PATCH 2/6] Updated wicd-curses to use DBusException.get_dbus_name() instead of the exception arguments. --- curses/wicd-curses.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/curses/wicd-curses.py b/curses/wicd-curses.py index fdce9ce..b06202a 100755 --- a/curses/wicd-curses.py +++ b/curses/wicd-curses.py @@ -1049,11 +1049,11 @@ setup_dbus() if __name__ == '__main__': try: parser = OptionParser(version="wicd-curses-%s (using wicd %s)" % (CURSES_REV,daemon.Hello())) - except Exception as ex: - if "Rejected send message" in ex.args[0]: + except Exception as e: + if "DBus.Error.AccessDenied" in e.get_dbus_name(): print "" system("\ -echo ERROR: wicd-curses was denied access to the wicd daemon, make sure that \ +echo ERROR: wicd-curses was denied access to the wicd daemon, please check that \ your user is in the group \\'$(tput bold)$(tput setaf 4)"+ wpath.wicd_group+"$(tput sgr0)\\'.") sys.exit(1) else: From 1142a1d084e6cd2eda9921bb18ed5fd6b6652287 Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Fri, 19 Jun 2009 18:59:30 -0400 Subject: [PATCH 3/6] Fixed wicd-client to actually show the error dialog, by checking e.get_dbus_name() instead of just e. --- wicd/wicd-client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wicd/wicd-client.py b/wicd/wicd-client.py index 97f3095..c7b9114 100755 --- a/wicd/wicd-client.py +++ b/wicd/wicd-client.py @@ -86,9 +86,10 @@ def catchdbus(func): def wrapper(*args, **kwargs): try: return func(*args, **kwargs) - except DBusException, e: - if "DBus.Error.AccessDenied" in e: + except DBusException as e: + if e.get_dbus_name() != None and "DBus.Error.AccessDenied" in e.get_dbus_name(): error(None, language['access_denied']) + #raise raise DBusException(e) else: print "warning: ignoring exception %s" % e From 5eee87cf80b400f57bd4fa290bb8abda77f5c8e0 Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Fri, 19 Jun 2009 20:07:10 -0400 Subject: [PATCH 4/6] Use the ANSI escape sequences to print colors instead of fetching them using tput(1) in wicd-curses. --- curses/wicd-curses.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/curses/wicd-curses.py b/curses/wicd-curses.py index b06202a..691b402 100755 --- a/curses/wicd-curses.py +++ b/curses/wicd-curses.py @@ -1051,10 +1051,9 @@ if __name__ == '__main__': parser = OptionParser(version="wicd-curses-%s (using wicd %s)" % (CURSES_REV,daemon.Hello())) except Exception as e: if "DBus.Error.AccessDenied" in e.get_dbus_name(): - print "" - system("\ + print "\ echo ERROR: wicd-curses was denied access to the wicd daemon, please check that \ -your user is in the group \\'$(tput bold)$(tput setaf 4)"+ wpath.wicd_group+"$(tput sgr0)\\'.") +your user is in the group \'\033[1;34m"+ wpath.wicd_group+"\033[0m\'." sys.exit(1) else: raise From e10969637a60a2077fbaf62f0a56530a4028bbbf Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Fri, 19 Jun 2009 23:03:42 -0400 Subject: [PATCH 5/6] Made the wicd-curses "access denied" string translatable, and updated wicd-curses.py to use it. --- curses/wicd-curses.py | 4 +--- wicd/translations.py | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/curses/wicd-curses.py b/curses/wicd-curses.py index 691b402..659b880 100755 --- a/curses/wicd-curses.py +++ b/curses/wicd-curses.py @@ -1051,9 +1051,7 @@ if __name__ == '__main__': parser = OptionParser(version="wicd-curses-%s (using wicd %s)" % (CURSES_REV,daemon.Hello())) except Exception as e: if "DBus.Error.AccessDenied" in e.get_dbus_name(): - print "\ -echo ERROR: wicd-curses was denied access to the wicd daemon, please check that \ -your user is in the group \'\033[1;34m"+ wpath.wicd_group+"\033[0m\'." + print language['access_denied_wc'].replace('$A','\033[1;34m'+wpath.wicd_group+'\033[0m') sys.exit(1) else: raise diff --git a/wicd/translations.py b/wicd/translations.py index 77d232d..ef1206d 100644 --- a/wicd/translations.py +++ b/wicd/translations.py @@ -55,7 +55,7 @@ def get_gettext(): _ = lang.gettext return _ -# Generated automatically on Fri, 05 Jun 2009 03:13:27 CDT +# Generated automatically on Fri, 19 Jun 2009 21:59:18 CDT _ = get_gettext() language = {} language['resetting_ip_address'] = _('''Resetting IP address...''') @@ -216,3 +216,4 @@ 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['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 group "$A".''') From 9ec96c1254484ebc9eb2900d12f53f6325920a73 Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Sat, 20 Jun 2009 21:41:17 -0400 Subject: [PATCH 6/6] Restore python 2.5 compatibility in both clients. --- curses/wicd-curses.py | 2 +- wicd/wicd-client.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/curses/wicd-curses.py b/curses/wicd-curses.py index 659b880..84fbdc9 100755 --- a/curses/wicd-curses.py +++ b/curses/wicd-curses.py @@ -1049,7 +1049,7 @@ setup_dbus() if __name__ == '__main__': try: parser = OptionParser(version="wicd-curses-%s (using wicd %s)" % (CURSES_REV,daemon.Hello())) - except Exception as e: + except Exception, e: if "DBus.Error.AccessDenied" in e.get_dbus_name(): print language['access_denied_wc'].replace('$A','\033[1;34m'+wpath.wicd_group+'\033[0m') sys.exit(1) diff --git a/wicd/wicd-client.py b/wicd/wicd-client.py index c7b9114..6cc453b 100755 --- a/wicd/wicd-client.py +++ b/wicd/wicd-client.py @@ -86,7 +86,7 @@ def catchdbus(func): def wrapper(*args, **kwargs): try: return func(*args, **kwargs) - except DBusException as e: + except DBusException, e: if e.get_dbus_name() != None and "DBus.Error.AccessDenied" in e.get_dbus_name(): error(None, language['access_denied']) #raise