From fa626d2ac455519e753fa76344c762be22c8f120 Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Fri, 19 Jun 2009 17:29:25 -0400 Subject: [PATCH] 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)")