mirror of
https://github.com/gryf/wicd.git
synced 2025-12-20 04:48:00 +01:00
merged lp:~nacl/wicd/1.6-access-denied to display an error message if access to the daemon via DBus is denied
This commit is contained in:
@@ -38,7 +38,6 @@ at least get a network connection. Or those who don't like using X. ;-)
|
|||||||
import warnings
|
import warnings
|
||||||
warnings.filterwarnings("ignore","The popen2 module is deprecated. Use the subprocess module.")
|
warnings.filterwarnings("ignore","The popen2 module is deprecated. Use the subprocess module.")
|
||||||
# UI stuff
|
# UI stuff
|
||||||
# This library is the only reason why I wrote this program.
|
|
||||||
import urwid
|
import urwid
|
||||||
|
|
||||||
# DBus communication stuff
|
# DBus communication stuff
|
||||||
@@ -64,6 +63,7 @@ import netentry_curses
|
|||||||
from netentry_curses import WirelessSettingsDialog, WiredSettingsDialog,AdvancedSettingsDialog
|
from netentry_curses import WirelessSettingsDialog, WiredSettingsDialog,AdvancedSettingsDialog
|
||||||
|
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
from os import system
|
||||||
|
|
||||||
# Stuff about getting the script configurer running
|
# Stuff about getting the script configurer running
|
||||||
#from grp import getgrgid
|
#from grp import getgrgid
|
||||||
@@ -72,7 +72,7 @@ from optparse import OptionParser
|
|||||||
#import logging
|
#import logging
|
||||||
#import logging.handler
|
#import logging.handler
|
||||||
|
|
||||||
CURSES_REVNO=wpath.curses_revision
|
CURSES_REV=wpath.curses_revision
|
||||||
|
|
||||||
# Fix strings in wicd-curses
|
# Fix strings in wicd-curses
|
||||||
from wicd.translations import language
|
from wicd.translations import language
|
||||||
@@ -1047,7 +1047,14 @@ setup_dbus()
|
|||||||
##### MAIN ENTRY POINT
|
##### MAIN ENTRY POINT
|
||||||
########################################
|
########################################
|
||||||
if __name__ == '__main__':
|
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, 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)
|
||||||
|
else:
|
||||||
|
raise
|
||||||
parser.set_defaults(screen='raw',debug=False)
|
parser.set_defaults(screen='raw',debug=False)
|
||||||
parser.add_option("-r", "--raw-screen",action="store_const",const='raw'
|
parser.add_option("-r", "--raw-screen",action="store_const",const='raw'
|
||||||
,dest='screen',help="use urwid's raw screen controller (default)")
|
,dest='screen',help="use urwid's raw screen controller (default)")
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ def get_gettext():
|
|||||||
_ = lang.gettext
|
_ = lang.gettext
|
||||||
return _
|
return _
|
||||||
|
|
||||||
# Generated automatically on Fri, 05 Jun 2009 03:13:27 CDT
|
# Generated automatically on Sat, 20 Jun 2009 21:40:39 CDT
|
||||||
_ = get_gettext()
|
_ = get_gettext()
|
||||||
language = {}
|
language = {}
|
||||||
language['resetting_ip_address'] = _('''Resetting IP address...''')
|
language['resetting_ip_address'] = _('''Resetting IP address...''')
|
||||||
@@ -74,8 +74,7 @@ language['wired_networks'] = _('''Wired Networks''')
|
|||||||
language['backend_alert'] = _('''Changes to your backend won't occur until the daemon is restarted.''')
|
language['backend_alert'] = _('''Changes to your backend won't occur until the daemon is restarted.''')
|
||||||
language['about_help'] = _('''Stop a network connection in progress''')
|
language['about_help'] = _('''Stop a network connection in progress''')
|
||||||
language['connecting'] = _('''Connecting''')
|
language['connecting'] = _('''Connecting''')
|
||||||
language['pre_disconnect_script'] = _('''Run pre-disconnect script''')
|
language['disconnect_script'] = _('''Run disconnect script''')
|
||||||
language['post_disconnect_script'] = _('''Run post-disconnect script''')
|
|
||||||
language['cannot_edit_scripts_1'] = _('''To avoid various complications, wicd-curses does not support directly editing the scripts directly. However, you can edit them manually. First, (as root)", open the "$A" config file, and look for the section labeled by the $B in question. In this case, this is:''')
|
language['cannot_edit_scripts_1'] = _('''To avoid various complications, wicd-curses does not support directly editing the scripts directly. However, you can edit them manually. First, (as root)", open the "$A" config file, and look for the section labeled by the $B in question. In this case, this is:''')
|
||||||
language['cannot_edit_scripts_3'] = _('''You can also configure the wireless networks by looking for the "[<ESSID>]" field in the config file.''')
|
language['cannot_edit_scripts_3'] = _('''You can also configure the wireless networks by looking for the "[<ESSID>]" field in the config file.''')
|
||||||
language['cannot_edit_scripts_2'] = _('''Once there, you can adjust (or add) the "beforescript", "afterscript", and "disconnectscript" variables as needed, to change the preconnect, postconnect, and disconnect scripts respectively. Note that you will be specifying the full path to the scripts - not the actual script contents. You will need to add/edit the script contents separately. Refer to the wicd manual page for more information.''')
|
language['cannot_edit_scripts_2'] = _('''Once there, you can adjust (or add) the "beforescript", "afterscript", and "disconnectscript" variables as needed, to change the preconnect, postconnect, and disconnect scripts respectively. Note that you will be specifying the full path to the scripts - not the actual script contents. You will need to add/edit the script contents separately. Refer to the wicd manual page for more information.''')
|
||||||
@@ -217,3 +216,4 @@ language['establishing_connection'] = _('''Establishing connection...''')
|
|||||||
language['association_failed'] = _('''Connection failed: Could not contact the wireless access point.''')
|
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 your DBus configuration.''')
|
||||||
language['disconnecting_active'] = _('''Disconnecting active connections...''')
|
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.''')
|
||||||
|
|||||||
@@ -87,8 +87,9 @@ def catchdbus(func):
|
|||||||
try:
|
try:
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
except DBusException, e:
|
except DBusException, e:
|
||||||
if "DBus.Error.AccessDenied" in 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'])
|
||||||
|
#raise
|
||||||
raise DBusException(e)
|
raise DBusException(e)
|
||||||
else:
|
else:
|
||||||
print "warning: ignoring exception %s" % e
|
print "warning: ignoring exception %s" % e
|
||||||
|
|||||||
Reference in New Issue
Block a user