diff --git a/curses/README b/curses/README index 377b764..3e5df9d 100644 --- a/curses/README +++ b/curses/README @@ -44,8 +44,7 @@ What is wicd-curses? Why didn't you call it wicd-urwid? There is a hachoir-urwid package out there. I first called this "urwicd". However, due to the relative obscurity of the urwid package, and the fact that many more people know what "curses" - is, I named it wicd-curses. After all, it _does_ use curses (by default, - anyway). + is, I named it wicd-curses. Why don't you support lower-case keybindings for most of the commands? I was trying to prevent mass chaos from happening because of mashing keys. diff --git a/curses/netentry_curses.py b/curses/netentry_curses.py index c00c887..0beed28 100644 --- a/curses/netentry_curses.py +++ b/curses/netentry_curses.py @@ -26,9 +26,7 @@ from curses_misc import TextDialog,DynWrap,MaskingEdit,ComboBox,error import wicd.misc as misc from wicd.misc import noneToString, stringToNone, noneToBlankString, to_bool - - -language = misc.get_language_list_gui() +from wicd.translations import language daemon = None wired = None @@ -56,9 +54,9 @@ class AdvancedSettingsDialog(urwid.WidgetWrap): use_global_dns_t = language['use_global_dns'] dns_dom_t = ('editcp',language['dns_domain']+': ') search_dom_t = ('editcp',language['search_domain']+':') - dns1_t = ('editcp',language['dns']+ ' ' + language['1']+':'+' '*8) - dns2_t = ('editcp',language['dns']+ ' ' + language['2']+':'+' '*8) - dns3_t = ('editcp',language['dns']+ ' ' + language['3']+':'+' '*8) + dns1_t = ('editcp',language['dns']+ ' 1'+':'+' '*8) + dns2_t = ('editcp',language['dns']+ ' 2'+':'+' '*8) + dns3_t = ('editcp',language['dns']+ ' 3'+':'+' '*8) cancel_t = 'Cancel' ok_t = 'OK' @@ -192,11 +190,16 @@ class AdvancedSettingsDialog(urwid.WidgetWrap): self.overlay.mouse_event( dim, event, button, col, row, focus=True) - k = self.overlay.keypress(dim, k) - if k in ('up','page up'): - self._w.set_focus('body') - elif k in ('down','page down'): - self._w.set_focus('footer') + else: + k = self.overlay.keypress(dim, k) + if k in ('up','page up'): + self._w.set_focus('body') + # Until I figure out a better way to do this, then this will + # have to do. + self._w.body.get_focus()[0].get_focus()._invalidate() + #self._w.body.keypress(dim,'down') + elif k in ('down','page down'): + self._w.set_focus('footer') if "window resize" in keys: dim = ui.get_cols_rows() diff --git a/curses/prefs_curses.py b/curses/prefs_curses.py old mode 100755 new mode 100644 index 992bc84..20d45d2 --- a/curses/prefs_curses.py +++ b/curses/prefs_curses.py @@ -28,7 +28,7 @@ daemon = None wireless = None wired = None -language = misc.get_language_list_gui() +from wicd.translations import language class PrefsDialog(urwid.WidgetWrap): def __init__(self,body,pos,ui,dbus=None): diff --git a/curses/wicd-curses.py b/curses/wicd-curses.py old mode 100644 new mode 100755 index 0428085..323d7e8 --- a/curses/wicd-curses.py +++ b/curses/wicd-curses.py @@ -67,9 +67,10 @@ from optparse import OptionParser CURSES_REVNO=wpath.curses_revision -language = misc.get_language_list_gui() -# We need 'Connecting' without the '...' -language['connecting']=misc.get_language_list_tray()['connecting'] +# Fix strings in wicd-curses +from wicd.translations import language +for i in language.keys(): + language[i] = language[i].decode('utf8') ######################################## ##### SUPPORT CLASSES @@ -865,12 +866,13 @@ def main(): # Import the screen based on whatever the user picked. # The raw_display will have some features that may be useful to users # later - if options.rawscreen: + if options.screen == 'raw': import urwid.raw_display ui = urwid.raw_display.Screen() - else: + elif options.screen is 'curses': import urwid.curses_display ui = urwid.curses_display.Screen() + # Default Color scheme. # Other potential color schemes can be found at: # http://excess.org/urwid/wiki/RecommendedPalette @@ -952,8 +954,10 @@ setup_dbus() ######################################## if __name__ == '__main__': parser = OptionParser(version="wicd-curses-%s (using wicd %s)" % (CURSES_REVNO,daemon.Hello())) - parser.add_option("-r", "--raw-screen",action="store_true",dest='rawscreen', - help="use urwid's raw screen controller") + parser.set_defaults(screen='raw') + parser.add_option("-r", "--raw-screen",action="store_const",const='raw' + ,dest='screen',help="use urwid's raw screen controller (default)") + parser.add_option("-c", "--curses-screen",action="store_const",const='curses',dest='screen',help="use urwid's curses screen controller") (options,args) = parser.parse_args() main() # Make sure that the terminal does not try to overwrite the last line of diff --git a/images/wicd-blue.png b/images/wicd-blue.png deleted file mode 100644 index 460b80f..0000000 Binary files a/images/wicd-blue.png and /dev/null differ diff --git a/images/wicd-client.png b/images/wicd-client.png deleted file mode 100644 index 1487bdb..0000000 Binary files a/images/wicd-client.png and /dev/null differ diff --git a/images/wicd-green.png b/images/wicd-green.png deleted file mode 100644 index 67dde2b..0000000 Binary files a/images/wicd-green.png and /dev/null differ diff --git a/images/wicd-orange.png b/images/wicd-orange.png deleted file mode 100644 index a0c87ed..0000000 Binary files a/images/wicd-orange.png and /dev/null differ diff --git a/images/wicd-purple.png b/images/wicd-purple.png deleted file mode 100644 index bc78156..0000000 Binary files a/images/wicd-purple.png and /dev/null differ diff --git a/images/wicd-red.png b/images/wicd-red.png deleted file mode 100644 index 42eb9aa..0000000 Binary files a/images/wicd-red.png and /dev/null differ diff --git a/in/init=lunar=wicd.in b/in/init=lunar=wicd.in new file mode 100755 index 0000000..83698ff --- /dev/null +++ b/in/init=lunar=wicd.in @@ -0,0 +1,13 @@ +#!/bin/bash +# +# Startup script for wicd +# +# chkconfig: 345 99 01 +# +# description: wicd wireless/wired internet connection daemon +# +# processname: wicd +# pidfile: %PIDFILE% +# + +. /lib/lsb/init_functions $1 diff --git a/in/init=suse=wicd.in b/in/init=suse=wicd.in index 6a5812a..2dec20d 100755 --- a/in/init=suse=wicd.in +++ b/in/init=suse=wicd.in @@ -3,6 +3,7 @@ ### BEGIN INIT INFO # Provides: wicd-daemon # Required-Start: dbus +# Required-Stop: # Default-Start: 3 4 5 # Default-Stop: # Description: wicd, a wired and wireless connection manager. diff --git a/in/man=wicd-curses.8.in b/in/man=wicd-curses.8.in index 9e0e549..99cfd68 100644 --- a/in/man=wicd-curses.8.in +++ b/in/man=wicd-curses.8.in @@ -1,5 +1,5 @@ .\" First revision was r203 -.TH WICD-CURSES "8" "January 2009" "wicd-curses-%CURSES_REVNO%" +.TH WICD-CURSES "8" "February 2009" "wicd-curses-%CURSES_REVNO%" .SH NAME .B wicd-curses \- curses-based wicd(8) controller @@ -12,7 +12,14 @@ This man page only documents the current status of wicd-curses. This may/may no .SH "ARGUMENTS" .TP .BR "\-r" , " \-\-raw\-screen" -Use Urwid's raw console display, instead of the (faster) curses-based one. This may be useful if you are experiencing unicode problems. +Use Urwid's raw console display. This is the default, and has several +advantages over the faster curses display, inculding fully functional unicode +and internationalization support. +.TP +.BR "\-c" , " \-\-curses\-screen" +Use Urwid's curses display. This may be faster than the default raw +display, but it lacks proper unicode support. This is fine to use if your +language of choice only uses Latin characters. .SH CONTROLS All of these are case sensitive. .TP diff --git a/in/other=WHEREAREMYFILES.in b/in/other=WHEREAREMYFILES.in index cec81a3..ce51f7c 100644 --- a/in/other=WHEREAREMYFILES.in +++ b/in/other=WHEREAREMYFILES.in @@ -1,13 +1,18 @@ WHERE ARE MY FILES?! -If you are reading this, you are probably wondering why your Wicd configuration -files are not here. What follows is a summary of the folders that Wicd uses. +If you are reading this in %VARLIB%, then you may ignore (but please don't +delete) this file. The only reason it is here is that it is definitely +constant between package updates. + +If you are reading this from your home directory, you are probably wondering +why your Wicd configuration files are not in ~/.wicd. What follows is a +summary of the folders that Wicd uses. For a more detailed (and complete) description what is in each directory, consult the man pages for wicd(8) and wicd-curses(8). ~/.wicd - User-dependent configuration files, only used by wicd-curses + User-dependent configuration files %ETC% Global configuration files diff --git a/in/scripts=wicd-client.in b/in/scripts=wicd-client.in index 776581f..871b930 100755 --- a/in/scripts=wicd-client.in +++ b/in/scripts=wicd-client.in @@ -7,21 +7,22 @@ if [ ! -d "$HOME/.wicd" ]; then mkdir -p "$HOME/.wicd" fi # Make sure the user knows WHEREAREMYFILES ;-) -if [ -e "%DOCDIR%WHEREAREMYFILES" ] && [ ! -L "$HOME/.wicd/WHEREAREMYFILES" ]; then - ln -s "%DOCDIR%WHEREAREMYFILES" "$HOME/.wicd/WHEREAREMYFILES" +if [ -e "%VARLIB%WHEREAREMYFILES" ] && [ ! -L "$HOME/.wicd/WHEREAREMYFILES" ]; then + ln -s "%VARLIB%WHEREAREMYFILES" "$HOME/.wicd/WHEREAREMYFILES" fi -if [ "$DISPLAY" = "" ] && [ -x "%BIN%wicd-curses" ]; then - if [ ! -f "$HOME/.wicd/CLIENT_CURSES_WARNING" ]; then - printf "NOTICE: You do not have an X server active on this console, \n" - printf "so ${BOLD}${BLUE}wicd-curses${NC} will be started instead. \n" - printf "Please see the wicd-client and/or wicd-curses manual pages \n" - printf "for more information about this error and resulting message. \n" - printf "\n" - printf "This message will not be displayed again. \n" - printf "Press enter to continue... \n" +if [ "$DISPLAY" = "" ]; then + if [ -x "%BIN%wicd-curses" ]; then + if [ ! -f "$HOME/.wicd/CLIENT_CURSES_WARNING" ]; then + printf "NOTICE: You do not have an X server active on this console, \n" + printf "so ${BOLD}${BLUE}wicd-curses${NC} will be started instead. \n" + printf "Please see the wicd-client and/or wicd-curses manual pages \n" + printf "for more information about this error and resulting message. \n" + printf "\n" + printf "This message will not be displayed again. \n" + printf "Press enter to continue... \n" - read _junk - cat >> "$HOME/.wicd/CLIENT_CURSES_WARNING" << EOF + read _junk + cat >> "$HOME/.wicd/CLIENT_CURSES_WARNING" << EOF The wicd-client script checks for the existence of this file to determine whether it should warn the user before launching wicd-curses instead, in the event of the gui client being launched outside of the X Window environment. @@ -29,8 +30,16 @@ the event of the gui client being launched outside of the X Window environment. If you delete this file, then wicd-client will print the warning if it is launched outside of X (and then recreate this file again). EOF - fi - exec %BIN%wicd-curses -fi + fi + exec %BIN%wicd-curses + + else + printf "NOTICE: You do not have an X server active on this console, \n" + printf "but you do not appear to have ${BOLD}${BLUE}wicd-curses${NC}\n" + printf "installed on this system. We'd normally be running it here.\n" + printf "Please see the wicd-client manual page for more information.\n" -exec python -O %LIB%wicd-client.py $@ + fi +else + exec python -O %LIB%wicd-client.py $@ +fi diff --git a/in/scripts=wicd-curses.in b/in/scripts=wicd-curses.in index 9b56c42..19ff689 100755 --- a/in/scripts=wicd-curses.in +++ b/in/scripts=wicd-curses.in @@ -1,2 +1,9 @@ #!/bin/bash +if [ ! -d "$HOME/.wicd" ]; then + mkdir -p "$HOME/.wicd" +fi +if [ -e "%VARLIB%WHEREAREMYFILES" ] && [ ! -L "$HOME/.wicd/WHEREAREMYFILES" ]; then + ln -s "%VARLIB%WHEREAREMYFILES" "$HOME/.wicd/WHEREAREMYFILES" +fi + exec python -O %LIB%wicd-curses.py $@ diff --git a/in/wicd=wpath.py.in b/in/wicd=wpath.py.in index fa4a753..a4f17ef 100755 --- a/in/wicd=wpath.py.in +++ b/in/wicd=wpath.py.in @@ -26,9 +26,14 @@ curses_revision = '%CURSES_REVNO%' lib = '%LIB%' share = '%SHARE%' etc = '%ETC%' +scripts = '%SCRIPTS%' +disconnectscripts = '%SCRIPTS%disconnect' +preconnectscripts = '%SCRIPTS%preconnect' +postconnectscripts = '%SCRIPTS%postconnect' images = '%IMAGES%' encryption = '%ENCRYPTION%' bin = '%BIN%' +varlib = '%VARLIB%' networks = '%NETWORKS%' log = '%LOG%' resume = '%RESUME%' diff --git a/setup.py b/setup.py index 92ffc2c..b96de8d 100755 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ import subprocess VERSION_NUM = '1.6.0a1' # REVISION_NUM is automatically updated REVISION_NUM = 'unknown' -CURSES_REVNO = 'r277' +CURSES_REVNO = 'r279' try: if not os.path.exists('vcsinfo.py'): @@ -42,6 +42,7 @@ except Exception, e: print 'failed to find revision number:' print e + class configure(Command): description = "configure the paths that Wicd will be installed to" @@ -51,6 +52,7 @@ class configure(Command): ('lib=', None, 'set the lib directory'), ('share=', None, 'set the share directory'), ('etc=', None, 'set the etc directory'), + ('scripts=', None, 'set the global scripts directory'), ('images=', None, 'set the image directory'), ('encryption=', None, 'set the encryption template directory'), ('bin=', None, 'set the bin directory'), @@ -66,6 +68,7 @@ class configure(Command): ('icons=', None, "set the base directory for the .desktop file's icons"), ('translations=', None, 'set the directory translations are stored in'), ('autostart=', None, 'set the directory that will be autostarted on desktop login'), + ('varlib=',None , 'set the path for wicd\'s variable state data'), ('init=', None, 'set the directory for the init file'), ('docdir=', None, 'set the directory for the documentation'), ('mandir=', None, 'set the directory for the man pages'), @@ -91,18 +94,19 @@ class configure(Command): ('no-install-ncurses', None, 'do not install the ncurses client') ] - def initialize_options(self): self.lib = '/usr/lib/wicd/' self.share = '/usr/share/wicd/' self.etc = '/etc/wicd/' + self.scripts = self.etc + "scripts/" self.icons = '/usr/share/icons/hicolor/' self.images = '/usr/share/pixmaps/wicd/' self.encryption = self.etc + 'encryption/templates/' self.bin = '/usr/bin/' self.sbin = '/usr/sbin/' self.backends = self.lib + 'backends' - self.networks = '/var/lib/wicd/configurations/' + self.varlib = '/var/lib/wicd/' + self.networks = self.varlib + 'configurations/' self.log = '/var/log/wicd/' self.resume = '/etc/acpi/resume.d/' self.suspend = '/etc/acpi/suspend.d/' @@ -158,9 +162,11 @@ class configure(Command): self.initfile = 'init/pld/wicd' elif os.path.exists('/usr/bin/crux'): self.init = '/etc/rc.d/' + elif os.path.exists('/etc/lunar.release'): + self.init='/etc/init.d/' + self.initfile = 'init/lunar/wicd' else: self.init = 'FAIL' - self.initfile = 'FAIL' self.no_install_init = True self.distro_detect_failed = True print 'WARNING: Unable to detect the distribution in use. ' + \ @@ -175,10 +181,12 @@ class configure(Command): # If we don't get anything from *-config, or it didn't run properly, # or the path is not a proper absolute path, raise an error try: - pmtemp = subprocess.Popen(["pkg-config","--variable=pm_sleephooks","pm-utils"], stdout=subprocess.PIPE) + pmtemp = subprocess.Popen(["pkg-config", "--variable=pm_sleephooks", + "pm-utils"], stdout=subprocess.PIPE) returncode = pmtemp.wait() # let it finish, and get the exit code pmutils_candidate = pmtemp.stdout.readline().strip() # read stdout - if len(pmutils_candidate) == 0 or returncode != 0 or not os.path.isabs(pmutils_candidate): + if len(pmutils_candidate) == 0 or returncode != 0 or \ + not os.path.isabs(pmutils_candidate): raise ValueError else: self.pmutils = pmutils_candidate @@ -189,7 +197,8 @@ class configure(Command): kdetemp = subprocess.Popen(["kde-config","--prefix"], stdout=subprocess.PIPE) returncode = kdetemp.wait() # let it finish, and get the exit code kdedir_candidate = kdetemp.stdout.readline().strip() # read stdout - if len(kdedir_candidate) == 0 or returncode != 0 or not os.path.isabs(kdedir_candidate): + if len(kdedir_candidate) == 0 or returncode != 0 or \ + not os.path.isabs(kdedir_candidate): raise ValueError else: self.kdedir = kdedir_candidate + '/share/autostart' @@ -199,10 +208,11 @@ class configure(Command): kde4temp = subprocess.Popen(["kde4-config","--prefix"], stdout=subprocess.PIPE) returncode = kde4temp.wait() # let it finish, and get the exit code kde4dir_candidate = kde4temp.stdout.readline().strip() # read stdout - if len(kde4dir_candidate) == 0 or returncode != 0 or not os.path.isabs(kde4dir_candidate): + if len(kde4dir_candidate) == 0 or returncode != 0 or \ + not os.path.isabs(kde4dir_candidate): raise ValueError else: - self.kdedir = kde4dir_candidate + '/share/autostart' + self.kdedir = kde4dir_candidate + '/share/autostart' except (OSError, ValueError): # If neither kde-config nor kde4-config are not present or # return an error, then we can assume that kde isn't installed @@ -216,15 +226,12 @@ class configure(Command): self.initfilename = os.path.basename(self.initfile) self.wicdgroup = 'users' - def finalize_options(self): - if self.distro_detect_failed == True: - if not self.no_install_init: - if self.init == 'FAIL' or self.initfile == 'FAIL': - print 'ERROR: Failed to detect distro. Configure cannot continue. ' + \ - 'Please specify --init and --initfile to continue with configuration.' - - + if self.distro_detect_failed and not self.no_install_init and \ + 'FAIL' in [self.init, self.initfile]: + print 'ERROR: Failed to detect distro. Configure cannot continue. ' + \ + 'Please specify --init and --initfile to continue with configuration.' + # loop through the argument definitions in user_options for argument in self.user_options: # argument name is the first item in the user_options list @@ -247,12 +254,15 @@ class configure(Command): values = list() for argument in self.user_options: if argument[0].endswith('='): - print argument[0][:-1],'is', - print getattr(self, argument[0][:-1]) - values.append((argument[0][:-1], getattr(self, argument[0][:-1].replace('-','_')))) + cur_arg = argument[0][:-1] + cur_arg_value = getattr(self, cur_arg) + print "%s is %s" % (cur_arg, cur_arg_value) + values.append((cur_arg, getattr(self, cur_arg.replace('-','_')))) else: - print "Found switch",argument,getattr(self, argument[0].replace('-','_')) - values.append((argument[0], bool(getattr(self, argument[0].replace('-','_'))))) + cur_arg = argument[0] + cur_arg_value = getattr(self, cur_arg.replace('-', '_')) + print "Found switch %s %s" % (argument, cur_arg_value) + values.append((cur_arg, bool(cur_arg_value))) print 'Replacing values in template files...' for item in os.listdir('in'): @@ -265,7 +275,8 @@ class configure(Command): item_out = open(final_name, 'w') for line in item_in.readlines(): for item, value in values: - line = line.replace('%' + str(item.upper().replace('-','_')) + '%', str(value)) + line = line.replace('%' + str(item.upper().replace('-','_')) + \ + '%', str(value)) # other things to replace that aren't arguments line = line.replace('%VERSION%', str(VERSION_NUM)) @@ -353,7 +364,8 @@ class get_translations(Command): shutil.move(pofile, lang_identifier+'.po') print 'Got',lang_identifier os.makedirs('translations/'+lang_identifier+'/LC_MESSAGES') - os.system('msgfmt --output-file=translations/'+lang_identifier+'/LC_MESSAGES/wicd.mo '+lang_identifier+'.po') + os.system('msgfmt --output-file=translations/' + lang_identifier + + '/LC_MESSAGES/wicd.mo ' + lang_identifier + '.po') os.remove(lang_identifier+'.po') @@ -373,7 +385,7 @@ class uninstall(Command): try: import wpath -except: +except ImportError: print '''Error importing wpath.py. You can safely ignore this message. It is probably because you haven't run python setup.py configure yet or you are running it for the first time.''' @@ -400,22 +412,29 @@ try: (wpath.icons + '22x22/apps/', ['icons/22px/wicd-client.png']), (wpath.icons + '16x16/apps/', ['icons/16px/wicd-client.png']), (wpath.images, [('images/' + b) for b in os.listdir('images') if not b.startswith('.')]), - (wpath.encryption, [('encryption/templates/' + b) for b in os.listdir('encryption/templates') if not b.startswith('.')]), + (wpath.encryption, [('encryption/templates/' + b) for b in + os.listdir('encryption/templates') if not b.startswith('.')]), (wpath.networks, []), (wpath.bin, ['scripts/wicd-client', ]), (wpath.sbin, ['scripts/wicd', ]), (wpath.share, ['data/wicd.glade', ]), - (wpath.lib, ['wicd/wicd-client.py', 'wicd/monitor.py', 'wicd/wicd-daemon.py', 'wicd/configscript.py', 'wicd/suspend.py', 'wicd/autoconnect.py']), #'wicd/wicd-gui.py', + (wpath.lib, ['wicd/wicd-client.py', 'wicd/monitor.py', + 'wicd/wicd-daemon.py', 'wicd/configscript.py', + 'wicd/suspend.py', 'wicd/autoconnect.py']), (wpath.backends, ['wicd/backends/be-external.py', 'wicd/backends/be-ioctl.py']), (wpath.autostart, ['other/wicd-tray.desktop', ]), + (wpath.scripts, []), + (wpath.disconnectscripts, []), + (wpath.preconnectscripts, []), + (wpath.postconnectscripts, []), ] if not wpath.no_install_ncurses: - data.append(( wpath.lib, ['curses/curses_misc.py'])) - data.append(( wpath.lib, ['curses/prefs_curses.py'])) - data.append(( wpath.lib, ['curses/wicd-curses.py'])) - data.append(( wpath.lib, ['curses/netentry_curses.py'])) - data.append(( wpath.lib, ['curses/configscript_curses.py'])) - data.append(( wpath.bin, ['scripts/wicd-curses'])) + data.append((wpath.lib, ['curses/curses_misc.py'])) + data.append((wpath.lib, ['curses/prefs_curses.py'])) + data.append((wpath.lib, ['curses/wicd-curses.py'])) + data.append((wpath.lib, ['curses/netentry_curses.py'])) + data.append((wpath.lib, ['curses/configscript_curses.py'])) + data.append((wpath.bin, ['scripts/wicd-curses'])) if not wpath.no_install_man: data.append(( wpath.mandir + 'man8/', ['man/wicd-curses.8'])) piddir = os.path.dirname(wpath.pidfile) @@ -423,22 +442,24 @@ try: piddir += '/' data.append (( piddir, [] )) if not wpath.no_install_docs: - data.append(( wpath.docdir, [ 'INSTALL', 'LICENSE', 'AUTHORS', 'README', 'CHANGES','other/WHEREAREMYFILES' ])) + data.append((wpath.docdir, ['INSTALL', 'LICENSE', 'AUTHORS', + 'README', 'CHANGES', ])) + data.append((wpath.varlib, ['other/WHEREAREMYFILES'])) if not wpath.no_install_kde: - data.append(( wpath.kdedir, [ 'other/wicd-tray.desktop' ])) + data.append((wpath.kdedir, ['other/wicd-tray.desktop'])) if not wpath.no_install_init: - data.append(( wpath.init, [ wpath.initfile ])) + data.append((wpath.init, [ wpath.initfile ])) if not wpath.no_install_man: - data.append(( wpath.mandir + 'man8/', [ 'man/wicd.8' ])) - data.append(( wpath.mandir + 'man5/', [ 'man/wicd-manager-settings.conf.5' ])) - data.append(( wpath.mandir + 'man5/', [ 'man/wicd-wired-settings.conf.5' ])) - data.append(( wpath.mandir + 'man5/', [ 'man/wicd-wireless-settings.conf.5' ])) - data.append(( wpath.mandir + 'man1/', [ 'man/wicd-client.1' ])) + data.append((wpath.mandir + 'man8/', [ 'man/wicd.8' ])) + data.append((wpath.mandir + 'man5/', [ 'man/wicd-manager-settings.conf.5' ])) + data.append((wpath.mandir + 'man5/', [ 'man/wicd-wired-settings.conf.5' ])) + data.append((wpath.mandir + 'man5/', [ 'man/wicd-wireless-settings.conf.5' ])) + data.append((wpath.mandir + 'man1/', [ 'man/wicd-client.1' ])) if not wpath.no_install_acpi: - data.append(( wpath.resume, ['other/80-wicd-connect.sh' ])) - data.append(( wpath.suspend, ['other/50-wicd-suspend.sh' ])) + data.append((wpath.resume, ['other/80-wicd-connect.sh' ])) + data.append((wpath.suspend, ['other/50-wicd-suspend.sh' ])) if not wpath.no_install_pmutils: - data.append(( wpath.pmutils, ['other/55wicd' ])) + data.append((wpath.pmutils, ['other/55wicd' ])) print 'Using pid path', os.path.basename(wpath.pidfile) print 'Language support for', for language in os.listdir('translations/'): @@ -448,22 +469,24 @@ try: if codes[0].lower() == codes[1].lower(): short_language = codes[0].lower() print short_language, - data.append((wpath.translations + short_language + '/LC_MESSAGES/', ['translations/' + language + '/LC_MESSAGES/wicd.mo'])) - print + data.append((wpath.translations + short_language + '/LC_MESSAGES/', + ['translations/' + language + '/LC_MESSAGES/wicd.mo'])) except Exception, e: print str(e) print '''Error setting up data array. This is normal if python setup.py configure has not yet been run.''' -wpactrl_ext = Extension(name = 'wpactrl', sources = ['depends/python-wpactrl/wpa_ctrl.c', 'depends/python-wpactrl/wpactrl.c'], - extra_compile_args = ["-fno-strict-aliasing"]) +wpactrl_ext = Extension(name = 'wpactrl', + sources = ['depends/python-wpactrl/wpa_ctrl.c', + 'depends/python-wpactrl/wpactrl.c'], + extra_compile_args = ["-fno-strict-aliasing"]) -iwscan_ext = Extension(name = 'iwscan', - libraries = ['iw'], - sources = ['depends/python-iwscan/pyiwscan.c']) +iwscan_ext = Extension(name = 'iwscan', libraries = ['iw'], + sources = ['depends/python-iwscan/pyiwscan.c']) -setup(cmdclass={'configure' : configure, 'get_translations' : get_translations, 'uninstall' : uninstall, 'test' : test, 'cleargenerated' : cleargenerated}, +setup(cmdclass={'configure' : configure, 'get_translations' : get_translations, + 'uninstall' : uninstall, 'test' : test, 'cleargenerated' : cleargenerated}, name="Wicd", version=VERSION_NUM, description="A wireless and wired network manager", @@ -472,20 +495,17 @@ Wicd supports wired and wireless networks, and capable of creating and tracking profiles for both. It has a template-based wireless encryption system, which allows the user to easily add encryption methods used. It ships with some common -encryption types, such as WPA and WEP. Wicd will automatically +encryption types, such as WPA and WEP. Wicdl will automatically connect at startup to any preferred network within range. """, author="Adam Blackburn, Dan O'Reilly", - author_email="compwiz18@users.sourceforge.net, imdano@users.sourceforge.net", + author_email="compwiz18@gmail.com, oreilldf@gmail.com", url="http://wicd.net", license="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html", - ## scripts=['configscript.py', 'autoconnect.py', 'gui.py', 'wicd.py', 'daemon.py', 'suspend.py', 'monitor.py'], - py_modules=['wicd.networking', 'wicd.misc', 'wicd.gui', 'wicd.wnettools', 'wicd.wpath', - 'wicd.prefs', 'wicd.netentry', 'wicd.dbusmanager', 'wicd.logfile', 'wicd.backend', - 'wicd.configmanager', 'wicd.guiutil'], + py_modules=['wicd.networking','wicd.misc','wicd.gui','wicd.wnettools', + 'wicd.wpath','wicd.prefs','wicd.netentry','wicd.dbusmanager', + 'wicd.logfile','wicd.backend','wicd.configmanager', + 'wicd.guiutil','wicd.translations'], ext_modules=[iwscan_ext, wpactrl_ext], data_files=data ) -##print "Running post-install configuration..." -##os.system("other/postinst") -##print 'Done.' diff --git a/wicd/gui.py b/wicd/gui.py index e3bc14f..6832337 100644 --- a/wicd/gui.py +++ b/wicd/gui.py @@ -43,12 +43,12 @@ from wicd.misc import noneToString from wicd.netentry import WiredNetworkEntry, WirelessNetworkEntry from wicd.prefs import PreferencesDialog from wicd.guiutil import error, GreyLabel, LabelEntry, SmallLabel +from wicd.translations import language if __name__ == '__main__': wpath.chdir(__file__) proxy_obj = daemon = wireless = wired = bus = None -language = misc.get_language_list_gui() DBUS_AVAIL = False def setup_dbus(force=True): diff --git a/wicd/misc.py b/wicd/misc.py index b06839d..080f37d 100644 --- a/wicd/misc.py +++ b/wicd/misc.py @@ -19,7 +19,6 @@ import os import locale -import gettext import sys import re import gobject @@ -58,7 +57,7 @@ ROUTE = 2 GKSUDO = 1 KDESU = 2 KTSUSS = 3 -__sudo_dict = { +_sudo_dict = { AUTO : "", GKSUDO : "gksudo", KDESU : "kdesu", @@ -172,9 +171,20 @@ def WriteLine(my_file, text): """ write a line to a file """ my_file.write(text + "\n") -def ExecuteScript(script): +def ExecuteScripts(scripts_dir, verbose=False): + """ Execute every executable file in a given directory. """ + for obj in os.listdir(scripts_dir): + obj = os.path.abspath(os.path.join(scripts_dir, obj)) + if os.path.isfile(obj) and os.access(obj, os.X_OK): + ExecuteScript(os.path.abspath(obj), verbose=verbose) + +def ExecuteScript(script, verbose=False): """ Execute a command and send its output to the bit bucket. """ - call("%s > /dev/null 2>&1" % script, shell=True) + if verbose: + print "Executing %s" % script + ret = call("%s > /dev/null 2>&1" % script, shell=True) + if verbose: + "%s returned %s" % (script, ret) def ReadFile(filename): """ read in a file and return it's contents as a string """ @@ -348,32 +358,6 @@ def noneToString(text): else: return str(text) -def get_gettext(): - """ Set up gettext for translations. """ - # Borrowed from an excellent post on how to do this at - # http://www.learningpython.com/2006/12/03/translating-your-pythonpygtk-application/ - local_path = wpath.translations - langs = [] - osLanguage = os.environ.get('LANGUAGE', None) - if osLanguage: - langs += osLanguage.split(":") - osLanguage = None - osLanguage = os.environ.get('LC_MESSAGES', None) - if osLanguage: - langs += osLanguage.split(":") - try: - lc, encoding = locale.getdefaultlocale() - except ValueError, e: - print str(e) - print "Default locale unavailable, falling back to en_US" - if (lc): - langs += [lc] - langs += ["en_US"] - lang = gettext.translation('wicd', local_path, languages=langs, - fallback=True) - _ = lang.gettext - return _ - def to_unicode(x): """ Attempts to convert a string to utf-8. """ # If this is a unicode string, encode it and return @@ -447,7 +431,7 @@ def get_sudo_cmd(msg, prog_num=0): def choose_sudo_prog(prog_num=0): """ Try to intelligently decide which graphical sudo program to use. """ if prog_num: - return find_path(__sudo_dict[prog_num]) + return find_path(_sudo_dict[prog_num]) desktop_env = detect_desktop_environment() env_path = os.environ['PATH'].split(":") paths = [] @@ -483,196 +467,6 @@ def find_path(cmd): return os.path.join(path, cmd) return None -def get_language_list_gui(): - """ Returns a dict of translatable strings used by the GUI. - - Translations are done at http://wicd.net/translator. Please - translate if you can. - - """ - _ = get_gettext() - language = {} - language['connect'] = _("Connect") - language['ip'] = _("IP") - language['netmask'] = _("Netmask") - language['gateway'] = _('Gateway') - language['dns'] = _('DNS') - language['use_static_ip'] = _('Use Static IPs') - language['use_static_dns'] = _('Use Static DNS') - language['use_encryption'] = _('Use Encryption') - language['advanced_settings'] = _('Advanced Settings') - language['properties'] = _('Properties') - language['wired_network'] = _('Wired Network') - language['wired_network_instructions'] = _('To connect to a wired network,' - ' you must create a network profile. To create a network profile, type a' - ' name that describes this network, and press Add.') - language['automatic_connect'] = _('Automatically connect to this network') - language['secured'] = _('Secured') - language['unsecured'] = _('Unsecured') - language['channel'] = _('Channel') - language['preferences'] = _('Preferences') - language['wpa_supplicant_driver'] = _('WPA Supplicant Driver') - language['wireless_interface'] = _('Wireless Interface') - language['wired_interface'] = _('Wired Interface') - language['hidden_network'] = _('Hidden Network') - language['hidden_network_essid'] = _('Hidden Network ESSID') - language['connected_to_wireless'] = _('Connected to $A at $B (IP: $C)') - language['connected_to_wired'] = _('Connected to wired network (IP: $A)') - language['not_connected'] = _('Not connected') - language['no_wireless_networks_found'] = _('No wireless networks found.') - language['killswitch_enabled'] = _('Wireless Kill Switch Enabled') - language['key'] = _('Key') - language['username'] = _('Username') - language['password'] = _('Password') - language['anonymous_identity'] = _('Anonymous Identity') - language['identity'] = _('Identity') - language['authentication'] = _('Authentication') - language['path_to_pac_file'] = _('Path to PAC File') - language['select_a_network'] = _('Choose from the networks below:') - language['connecting'] = _('Connecting...') - language['wired_always_on'] = _('Always show wired interface') - language['auto_reconnect'] = _('Automatically reconnect on connection loss') - language['create_adhoc_network'] = _('Create an Ad-Hoc Network') - language['essid'] = _('ESSID') - language['use_wep_encryption'] = _('Use Encryption (WEP only)') - language['before_script'] = _('Run script before connect') - language['after_script'] = _('Run script after connect') - language['disconnect_script'] = _('Run disconnect script') - language['script_settings'] = _('Scripts') - language['use_ics'] = _('Activate Internet Connection Sharing') - language['madwifi_for_adhoc'] = _('Check if using madwifi/atheros drivers') - language['default_wired'] = _('Use as default profile (overwrites any previous default)') - language['use_debug_mode'] = _('Enable debug mode') - language['use_global_dns'] = _('Use global DNS servers') - language['use_default_profile'] = _('Use default profile on wired autoconnect') - language['show_wired_list'] = _('Prompt for profile on wired autoconnect') - language['use_last_used_profile'] = _('Use last used profile on wired autoconnect') - language['choose_wired_profile'] = _('Select or create a wired profile to connect with') - language['wired_network_found'] = _('Wired connection detected') - language['stop_showing_chooser'] = _('Stop Showing Autoconnect pop-up temporarily') - language['display_type_dialog'] = _('Use dBm to measure signal strength') - language['scripts'] = _('Scripts') - #language['invalid_address'] = _('Invalid address in $A entry.') - language['global_settings'] = _('Use these settings for all networks sharing this essid') - language['encrypt_info_missing'] = _('Required encryption information is missing.') - language['enable_encryption'] = _('This network requires encryption to be enabled.') - language['wicd_auto_config'] = _('Automatic (recommended)') - language["gen_settings"] = _("General Settings") - language["ext_programs"] = _("External Programs") - language["dhcp_client"] = _("DHCP Client") - language["wired_detect"] = _("Wired Link Detection") - language["route_flush"] = _("Route Table Flushing") - language["backend"] = _("Backend") - language["backend_alert"] = _("Changes to your backend won't occur until the daemon is restarted.") - language['dns_domain'] = _("DNS domain") - language['search_domain'] = _("Search domain") - language['global_dns_not_enabled'] = _("Global DNS has not been enabled in general preferences.") - language['scripts_need_pass'] = _('You must enter your password to configure scripts') - language['no_sudo_prog'] = _("Could not find a graphical sudo program. The script editor could not be launched." + - " You'll have to edit scripts directly your configuration file.") - - language['0'] = _('0') - language['1'] = _('1') - language['2'] = _('2') - language['3'] = _('3') - language['4'] = _('4') - language['5'] = _('5') - language['6'] = _('6') - language['7'] = _('7') - language['8'] = _('8') - language['9'] = _('9') - - language['interface_down'] = _('Putting interface down...') - language['resetting_ip_address'] = _('Resetting IP address...') - language['interface_up'] = _('Putting interface up...') - language['setting_encryption_info'] = _('Setting encryption info') - language['removing_old_connection'] = _('Removing old connection...') - language['generating_psk'] = _('Generating PSK...') - language['generating_wpa_config'] = _('Generating WPA configuration file...') - language['flushing_routing_table'] = _('Flushing the routing table...') - language['configuring_interface'] = _('Configuring wireless interface...') - language['validating_authentication'] = _('Validating authentication...') - language['setting_broadcast_address'] = _('Setting broadcast address...') - language['setting_static_dns'] = _('Setting static DNS servers...') - language['setting_static_ip'] = _('Setting static IP addresses...') - language['running_dhcp'] = _('Obtaining IP address...') - language['dhcp_failed'] = _('Connection Failed: Unable to Get IP Address') - language['no_dhcp_offers'] = _('Connection Failed: No DHCP offers received.') - language['aborted'] = _('Connection Cancelled') - language['bad_pass'] = _('Connection Failed: Could not authenticate (bad password?)') - language['done'] = _('Done connecting...') - language['scanning'] = _('Scanning') - language['scanning_stand_by'] = _('Scanning networks... stand by...') - language['cannot_start_daemon'] = _("Unable to connect to wicd daemon DBus interface. " + \ - "This typically means there was a problem starting the daemon. " + \ - "Check the wicd log for more info") - language['lost_dbus'] = _("The wicd daemon has shut down, the UI will not function properly until it is restarted.") - language['configuring_wireless'] = _("Configuring preferences for wireless network \"$A\" ($B)") - language['configuring_wired'] = _("Configuring preferences for wired profile \"$A\"") - language['scan'] = _('Scan') - language['always_switch_to_wired'] = _("Always switch to wired connection when available") - language['wired_autoconnect_settings'] = _("Wired Autoconnect Settings") - language['always_use_wext'] = _("You should almost always use wext as the WPA supplicant driver") - language['debugging'] = _("Debugging") - language['wpa_supplicant'] = _("WPA Supplicant") - language['automatic_reconnection'] = _("Automatic Reconnection") - language['global_dns_servers'] = _("Global DNS servers") - language['network_interfaces'] = _("Network Interfaces") - language['connecting_to_daemon'] = _("Connecting to daemon...") - language['cannot_connect_to_daemon'] = _("Can't connect to the daemon, trying to start it automatically...") - language['could_not_connect'] = _("Could not connect to wicd's D-Bus interface. Check the wicd log for error messages.") - language["exception"] = _("EXCEPTION! Please report this to the maintainer and file a bug report with the backtrace below:") - language["brought_to_you"] = _("Brought to you by:") - 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_2"] = _('Once here, you can adjust (or add) the "beforescript", "afterscript", and "disconnectscript" variables as needed, to change the preconnect, postconnect, and disconnect scripts respectively. Alternatively, you can configure the wireless networks by ESSID, by looking for the "[]" field in the config file.') - language["add_new_profile"] = _("Add a new profile") - language["add_new_wired_profile"] = _("Add a new wired profile") - language["no_delete_last_profile"] = _("wicd-curses does not support deleting the last wired profile. Try renaming it ('F2')") - language["rename_wired_profile"] = _("Rename wired profile") - language["select_hidden_essid"] = _("Select Hidden Network ESSID") - language["esc_to_cancel"] = _("Press ESC to cancel") - language["press_to_quit"] = _("Press F8 or Q to quit.") - - language['terminated'] = _("Terminated by user") - language['wicd_curses'] = _("Wicd Curses Interface") - language['dbus_fail'] = _("DBus failure! This is most likely caused by the wicd daemon stopping while wicd-curses is running. Please restart the daemon, and then restart wicd-curses.") - - # Fix strings in wicd-curses - for i in language.keys(): - try : - language[i] = language[i].decode('utf8') - except: - print "\"%s\"" % language[i] - raise - - - return language - -def get_language_list_tray(): - """ Returns a dict of translatable strings used by the tray icon. - - Translations are done at http://wicd.net/translator. Please - translate if you can. - - """ - _ = get_gettext() - language = {} - language['connected_to_wireless'] = _('Connected to $A at $B (IP: $C)') - language['connected_to_wired'] = _('Connected to wired network (IP: $A)') - language['not_connected'] = _('Not connected') - language['killswitch_enabled'] = _('Wireless Kill Switch Enabled') - language['connecting'] = _('Connecting') - language['wired'] = _('Wired Network') - language['scanning'] = _('Scanning') - language['no_wireless_networks_found'] = _('No wireless networks found.') - language['daemon_unavailable'] = _("The wicd daemon is unavailable, so your request cannot be completed") - language['cannot_start_daemon'] = _("Unable to connect to wicd daemon DBus interface." + \ - "This typically means there was a problem starting the daemon." + \ - "Check the wicd log for more info") - language['no_daemon_tooltip'] = _("Wicd daemon unreachable") - language['lost_dbus'] = _("The wicd daemon has shut down, the UI will not function properly until it is restarted.") - return language - def noneToBlankString(text): """ Converts NoneType or "None" to a blank string. """ if text in (None, "None"): diff --git a/wicd/netentry.py b/wicd/netentry.py index 27135b6..a6e1919 100644 --- a/wicd/netentry.py +++ b/wicd/netentry.py @@ -24,7 +24,7 @@ import dbusmanager from misc import noneToString, stringToNone, noneToBlankString, to_bool from guiutil import error, SmallLabel, LabelEntry, GreyLabel, LeftAlignedLabel, string_input -language = misc.get_language_list_gui() +from translations import language # These get set when a NetworkEntry is instantiated. daemon = None @@ -57,9 +57,9 @@ class AdvancedSettingsDialog(gtk.Dialog): self.txt_gateway = LabelEntry(language['gateway']) self.txt_search_dom = LabelEntry(language['search_domain']) self.txt_domain = LabelEntry(language['dns_domain']) - self.txt_dns_1 = LabelEntry(language['dns'] + ' ' + language['1']) - self.txt_dns_2 = LabelEntry(language['dns'] + ' ' + language['2']) - self.txt_dns_3 = LabelEntry(language['dns'] + ' ' + language['3']) + self.txt_dns_1 = LabelEntry(language['dns'] + ' 1') + self.txt_dns_2 = LabelEntry(language['dns'] + ' 2') + self.txt_dns_3 = LabelEntry(language['dns'] + ' 3') self.chkbox_static_ip = gtk.CheckButton(language['use_static_ip']) self.chkbox_static_dns = gtk.CheckButton(language['use_static_dns']) self.chkbox_global_dns = gtk.CheckButton(language['use_global_dns']) diff --git a/wicd/networking.py b/wicd/networking.py index efb62c5..8593496 100644 --- a/wicd/networking.py +++ b/wicd/networking.py @@ -131,7 +131,7 @@ def expand_script_macros(script, msg, bssid, essid): print "Expanded '%s' to '%s'" % (script, expanded) return expanded - + class Controller(object): """ Parent class for the different interface types. """ def __init__(self, debug=False): @@ -201,10 +201,12 @@ class Controller(object): def Disconnect(self, *args, **kargs): """ Disconnect from the network. """ iface = self.iface - if self.disconnect_script != None: + misc.ExecuteScripts(wpath.disconnectscripts, self.debug) + if self.disconnect_script: print 'Running disconnect script' misc.ExecuteScript(expand_script_macros(self.disconnect_script, - 'disconnection', *args)) + 'disconnection', *args), + self.debug) iface.ReleaseDHCP() iface.SetAddress('0.0.0.0') iface.FlushRoutes() @@ -333,7 +335,6 @@ class ConnectThread(threading.Thread): finally: self.lock.release() - def GetStatus(self): """ Get the threads current status message in a thread-safe way. @@ -367,6 +368,10 @@ class ConnectThread(threading.Thread): self.SetStatus('interface_down') iface.Down() + @abortable + def run_global_scripts_if_needed(self, script_dir): + misc.ExecuteScripts(script_dir, verbose=self.debug) + @abortable def run_script_if_needed(self, script, msg, bssid='wired', essid='wired'): """ Execute a given script if needed. @@ -378,7 +383,8 @@ class ConnectThread(threading.Thread): """ if script: print 'Executing %s script' % (msg) - misc.ExecuteScript(expand_script_macros(script, msg, bssid, essid)) + misc.ExecuteScript(expand_script_macros(script, msg, bssid, essid), + self.debug) @abortable def flush_routes(self, iface): @@ -760,6 +766,7 @@ class WirelessConnectThread(ConnectThread): self.is_connecting = True # Run pre-connection script. + self.run_global_scripts_if_needed(wpath.preconnectscripts) self.run_script_if_needed(self.before_script, 'pre-connection', self.network['bssid'], self.network['essid']) @@ -802,6 +809,7 @@ class WirelessConnectThread(ConnectThread): self.set_dns_addresses() # Run post-connection script. + self.run_global_scripts_if_needed(wpath.postconnectscripts) self.run_script_if_needed(self.after_script, 'post-connection', self.network['bssid'], self.network['essid']) @@ -970,6 +978,7 @@ class WiredConnectThread(ConnectThread): self.is_connecting = True # Run pre-connection script. + self.run_global_scripts_if_needed(wpath.preconnectscripts) self.run_script_if_needed(self.before_script, 'pre-connection', 'wired', 'wired') @@ -988,6 +997,7 @@ class WiredConnectThread(ConnectThread): self.set_dns_addresses() # Run post-connection script. + self.run_global_scripts_if_needed(wpath.postconnectscripts) self.run_script_if_needed(self.after_script, 'post-connection', 'wired', 'wired') diff --git a/wicd/prefs.py b/wicd/prefs.py index 2adfc6d..d25267b 100644 --- a/wicd/prefs.py +++ b/wicd/prefs.py @@ -39,7 +39,7 @@ daemon = None wireless = None wired = None -language = misc.get_language_list_gui() +from translations import language def setup_dbus(): global daemon, wireless, wired diff --git a/wicd/translations.py b/wicd/translations.py new file mode 100644 index 0000000..397236c --- /dev/null +++ b/wicd/translations.py @@ -0,0 +1,225 @@ +#!/usr/bin/env python +# -* coding: utf-8 -*- + +# +# Copyright (C) 2007 - 2009 Adam Blackburn +# Copyright (C) 2007 - 2009 Dan O'Reilly +# Copyright (C) 2009 Andrew Psaltis +# +# 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 +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +import locale +import os +import wpath +import gettext + + +def get_gettext(): + """ Set up gettext for translations. """ + # Borrowed from an excellent post on how to do this at + # http://www.learningpython.com/2006/12/03/translating-your-pythonpygtk-application/ + local_path = wpath.translations + langs = [] + osLanguage = os.environ.get('LANGUAGE', None) + if osLanguage: + langs += osLanguage.split(":") + osLanguage = None + osLanguage = os.environ.get('LC_MESSAGES', None) + if osLanguage: + langs += osLanguage.split(":") + try: + # This avoids a bug: locale.getdefaultlocale() prefers + # LC_CTYPE over LANG/LANGUAGE + lc, encoding = locale.getdefaultlocale(envvars=('LC_MESSAGES', + 'LC_ALL', 'LANG', + 'LANGUAGE')) + except ValueError, e: + print str(e) + print "Default locale unavailable, falling back to en_US" + if (lc): + langs += [lc] + langs += ["en_US"] + lang = gettext.translation('wicd', local_path, languages=langs, + fallback=True) + _ = lang.gettext + return _ + +_ = get_gettext() +language = {} +language['connect'] = _('Connect') +language['ip'] = _('IP') +language['netmask'] = _('Netmask') +language['gateway'] = _('Gateway') +language['dns'] = _('DNS') +language['use_static_ip'] = _('Use Static IPs') +language['use_static_dns'] = _('Use Static DNS') +language['use_encryption'] = _('Use Encryption') +language['advanced_settings'] = _('Advanced Settings') +language['properties'] = _('Properties') +language['wired_network'] = _('Wired Network') +language['wired_network_instructions'] = _('To connect to a wired network,' +' you must create a network profile. To create a network profile, type a' +' name that describes this network, and press Add.') +language['automatic_connect'] = _('Automatically connect to this network') +language['secured'] = _('Secured') +language['unsecured'] = _('Unsecured') +language['channel'] = _('Channel') +language['preferences'] = _('Preferences') +language['wpa_supplicant_driver'] = _('WPA Supplicant Driver') +language['wireless_interface'] = _('Wireless Interface') +language['wired_interface'] = _('Wired Interface') +language['hidden_network'] = _('Hidden Network') +language['hidden_network_essid'] = _('Hidden Network ESSID') +language['connected_to_wireless'] = _('Connected to $A at $B (IP: $C)') +language['connected_to_wired'] = _('Connected to wired network (IP: $A)') +language['not_connected'] = _('Not connected') +language['no_wireless_networks_found'] = _('No wireless networks found.') +language['killswitch_enabled'] = _('Wireless Kill Switch Enabled') +language['key'] = _('Key') +language['username'] = _('Username') +language['password'] = _('Password') +language['anonymous_identity'] = _('Anonymous Identity') +language['identity'] = _('Identity') +language['authentication'] = _('Authentication') +language['path_to_pac_file'] = _('Path to PAC File') +language['select_a_network'] = _('Choose from the networks below:') +#language['connecting...'] = _('Connecting...') +language['wired_always_on'] = _('Always show wired interface') +language['auto_reconnect'] = _('Automatically reconnect on connection loss') +language['create_adhoc_network'] = _('Create an Ad-Hoc Network') +language['essid'] = _('ESSID') +language['use_wep_encryption'] = _('Use Encryption (WEP only)') +language['before_script'] = _('Run script before connect') +language['after_script'] = _('Run script after connect') +language['disconnect_script'] = _('Run disconnect script') +language['script_settings'] = _('Scripts') +language['use_ics'] = _('Activate Internet Connection Sharing') +language['madwifi_for_adhoc'] = _('Check if using madwifi/atheros drivers') +language['default_wired'] = _('Use as default profile (overwrites any previous default)') +language['use_debug_mode'] = _('Enable debug mode') +language['use_global_dns'] = _('Use global DNS servers') +language['use_default_profile'] = _('Use default profile on wired autoconnect') +language['show_wired_list'] = _('Prompt for profile on wired autoconnect') +language['use_last_used_profile'] = _('Use last used profile on wired autoconnect') +language['choose_wired_profile'] = _('Select or create a wired profile to connect with') +language['wired_network_found'] = _('Wired connection detected') +language['stop_showing_chooser'] = _('Stop Showing Autoconnect pop-up temporarily') +language['display_type_dialog'] = _('Use dBm to measure signal strength') +language['scripts'] = _('Scripts') +language['invalid_address'] = _('Invalid address in $A entry.') +language['global_settings'] = _('Use these settings for all networks sharing this essid') +language['encrypt_info_missing'] = _('Required encryption information is missing.') +language['enable_encryption'] = _('This network requires encryption to be enabled.') +language['wicd_auto_config'] = _('Automatic (recommended)') +language["gen_settings"] = _('General Settings') +language["ext_programs"] = _('External Programs') +language["dhcp_client"] = _('DHCP Client') +language["wired_detect"] = _('Wired Link Detection') +language["route_flush"] = _('Route Table Flushing') +language["backend"] = _('Backend') +language["backend_alert"] = _('Changes to your backend won\'t occur until the daemon is restarted.') +language['dns_domain'] = _('DNS domain') +language['search_domain'] = _('Search domain') +language['global_dns_not_enabled'] = _('Global DNS has not been enabled in general preferences.') +language['scripts_need_pass'] = _('You must enter your password to configure scripts') +language['no_sudo_prog'] = _('Could not find a graphical sudo program. The script editor could not be launched.' + + ' You\'ll have to edit scripts directly your configuration file.') + +language['interface_down'] = _('Putting interface down...') +language['resetting_ip_address'] = _('Resetting IP address...') +language['interface_up'] = _('Putting interface up...') +language['setting_encryption_info'] = _('Setting encryption info') +language['removing_old_connection'] = _('Removing old connection...') +language['generating_psk'] = _('Generating PSK...') +language['generating_wpa_config'] = _('Generating WPA configuration file...') +language['flushing_routing_table'] = _('Flushing the routing table...') +language['configuring_interface'] = _('Configuring wireless interface...') +language['validating_authentication'] = _('Validating authentication...') +language['setting_broadcast_address'] = _('Setting broadcast address...') +language['setting_static_dns'] = _('Setting static DNS servers...') +language['setting_static_ip'] = _('Setting static IP addresses...') +language['running_dhcp'] = _('Obtaining IP address...') +language['dhcp_failed'] = _('Connection Failed: Unable to Get IP Address') +language['no_dhcp_offers'] = _('Connection Failed: No DHCP offers received.') +language['aborted'] = _('Connection Cancelled') +language['bad_pass'] = _('Connection Failed: Could not authenticate (bad password?)') +language['done'] = _('Done connecting...') +language['scanning'] = _('Scanning') +language['scanning_stand_by'] = _('Scanning networks... stand by...') +language['cannot_start_daemon'] = _('Unable to connect to wicd daemon DBus interface. " + \ + "This typically means there was a problem starting the daemon. " + \ + "Check the wicd log for more info') +language['lost_dbus'] = _('The wicd daemon has shut down, the UI will not function properly until it is restarted.') +language['configuring_wireless'] = _('Configuring preferences for wireless network "$A" ($B)') +language['configuring_wired'] = _('Configuring preferences for wired profile "$A"') +language['scan'] = _('Scan') +language['always_switch_to_wired'] = _('Always switch to wired connection when available') +language['wired_autoconnect_settings'] = _('Wired Autoconnect Settings') +language['always_use_wext'] = _('You should almost always use wext as the WPA supplicant driver') +language['debugging'] = _('Debugging') +language['wpa_supplicant'] = _('WPA Supplicant') +language['automatic_reconnection'] = _('Automatic Reconnection') +language['global_dns_servers'] = _('Global DNS servers') +language['network_interfaces'] = _('Network Interfaces') +language['connecting_to_daemon'] = _('Connecting to daemon...') +language['cannot_connect_to_daemon'] = _('Can\'t connect to the daemon, trying to start it automatically...') +language['could_not_connect'] = _('Could not connect to wicd\'s D-Bus interface. Check the wicd log for error messages.') +language["exception"] = _('EXCEPTION! Please report this to the maintainer and file a bug report with the backtrace below:') +language["brought_to_you"] = _('Brought to you by:') +language["add_new_profile"] = _('Add a new profile') +language["add_new_wired_profile"] = _('Add a new wired profile') +language["no_delete_last_profile"] = _('wicd-curses does not support deleting the last wired profile. Try renaming it (\'F2\')') +language["rename_wired_profile"] = _('Rename wired profile') +language["select_hidden_essid"] = _('Select Hidden Network ESSID') +language["esc_to_cancel"] = _('Press ESC to cancel') +language["press_to_quit"] = _('Press F8 or Q to quit.') + +language['terminated'] = _('Terminated by user') +language['wicd_curses'] = _('Wicd Curses Interface') +language['dbus_fail'] = _('DBus failure! This is most likely caused by the wicd daemon stopping while wicd-curses is running. Please restart the daemon, and then restart wicd-curses.') + +# These are in the tray list, but not in the non-tray list +language['connecting'] = _('Connecting') +language['daemon_unavailable'] = _('The wicd daemon is unavailable, so your request cannot be completed') +language['no_daemon_tooltip'] = _('Wicd daemon unreachable') + +# Translations added on Wed Mar 4 03:36:24 UTC 2009 +language['make_wired_profile'] = _('To connect to a wired network, you must create a network profile. To create a network profile, type a name that describes this network, and press Add.') +language['access_cards'] = _('Wicd needs to access your computer\'s network cards.') +#language['CHANGE_ME'] = _('Create Ad-Hoc network') +#language['CHANGE_ME'] = _('Wired Autoconnect Setting:') +language['bad_pass'] = _('Connection Failed: Bad password') +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_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_3'] = _('You can also configure the wireless networks by looking for the "[]" field in the config file.') +language['wired_networks'] = _('Wired Networks') +language['wireless_networks'] = _('Wireless Networks') +language['about'] = _('About Wicd') +language['more_help'] = _('For more detailed help, consult the wicd-curses(8) man page.') +language['case_sensitive'] = _('All controls are case sensitive') +language['help_help'] = _('Display this help dialog') +language['connect_help'] = _('Connect to selected network') +language['disconn_help'] = _('Disconnect from all networks') +language['about_help'] = _('Stop a network connection in progress') +language['refresh_help'] = _('Refresh network list') +language['prefs_help'] = _('Preferences dialog') +language['scan_help'] = _('Scan for hidden networks') +language['scripts_help'] = _('Select scripts') +language['adhoc_help'] = _('Set up Ad-hoc network') +language['config_help'] = _('Configure Selected Network') +#language[''] = _('Press H or ? for help') # Defunct in curses-uimod +language['raw_screen_arg'] = _('use urwid\'s raw screen controller') +language['ok'] = _('OK') +language['cancel'] = _('Cancel') + + diff --git a/wicd/wicd-client.py b/wicd/wicd-client.py index e69c5fd..f82dd08 100755 --- a/wicd/wicd-client.py +++ b/wicd/wicd-client.py @@ -53,6 +53,8 @@ from wicd import gui from wicd import dbusmanager from wicd.guiutil import error +from wicd.translations import language + ICON_AVAIL = True USE_EGG = False # Import egg.trayicon if we're using an older gtk version @@ -72,9 +74,6 @@ if __name__ == '__main__': daemon = wireless = wired = lost_dbus_id = None DBUS_AVAIL = False -language = misc.get_language_list_tray() - - def catchdbus(func): def wrapper(*args, **kwargs): try: @@ -179,7 +178,7 @@ class TrayIcon(object): def set_connecting_state(self, info): """ Sets the icon info for a connecting state. """ if info[0] == 'wired' and len(info) == 1: - cur_network = language['wired'] + cur_network = language['wired_network'] else: cur_network = info[1] self.tr.set_tooltip(language['connecting'] + " to " +