/[papo]/gnue/common/src/GBaseApp.py
ViewVC logotype

Diff of /gnue/common/src/GBaseApp.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by charlie, Tue Aug 27 18:15:51 2002 UTC revision 1.4 by styxman, Fri Nov 15 15:32:54 2002 UTC
# Line 1  Line 1 
1  #  #
2  # This file is part of GNU Enterprise.  # This file is part of GNU Enterprise.
3  #  #
4  # GNU Enterprise is free software; you can redistribute it  # GNU Enterprise is free software; you can redistribute it
5  # and/or modify it under the terms of the GNU General Public  # and/or modify it under the terms of the GNU General Public
6  # License as published by the Free Software Foundation; either  # License as published by the Free Software Foundation; either
7  # version 2, or (at your option) any later version.  # version 2, or (at your option) any later version.
8  #  #
9  # GNU Enterprise is distributed in the hope that it will be  # GNU Enterprise is distributed in the hope that it will be
10  # useful, but WITHOUT ANY WARRANTY; without even the implied  # useful, but WITHOUT ANY WARRANTY; without even the implied
11  # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR  # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  # PURPOSE. See the GNU General Public License for more details.  # PURPOSE. See the GNU General Public License for more details.
13  #  #
14  # You should have received a copy of the GNU General Public  # You should have received a copy of the GNU General Public
15  # License along with program; see the file COPYING. If not,  # License along with program; see the file COPYING. If not,
16  # write to the Free Software Foundation, Inc., 59 Temple Place  # write to the Free Software Foundation, Inc., 59 Temple Place
17  # - Suite 330, Boston, MA 02111-1307, USA.  # - Suite 330, Boston, MA 02111-1307, USA.
18  #  #
19  # Copyright 2000-2002 Free Software Foundation  # Copyright 2000-2002 Free Software Foundation
# Line 28  Line 28 
28  # Typically, this class will not be called; rather, a tool will  # Typically, this class will not be called; rather, a tool will
29  # be a GClientApp or GServerApp.  # be a GClientApp or GServerApp.
30  #  #
 # HISTORY:  
 #  
31    
32  import GConfig  import GConfig
33  #  #
34  # i18n support  # I18N, L10N support
35  #  #
36  import getopt  import getopt
37  import sys  import sys
# Line 41  import string Line 39  import string
39  import os  import os
40  import ConfigParser  import ConfigParser
41  import gettext  import gettext
42  from gnue.common import lineWrap  from gnue.common.TextUtils import lineWrap
43    import locale
44    
45    locale.setlocale(locale.LC_ALL, '')
46  try:  try:
47    gettext.install('gnue',GConfig.getInstalledBase('install_prefix')+'/translations')    # gettext.install('gnue',GConfig.getInstalledBase('install_prefix')+'/translations')
48  except IOError:    # no need for LC_ALL on win2k and XP with this variant
49      lang = [locale.getdefaultlocale()[0]]
50      gettext.translation('gnue',GConfig.getInstalledBase('install_prefix')+'/translations',languages=lang).install()
51    except:
52  #  sys.stderr.write('Unable to load locale information falling back to default English language translations.\n')  #  sys.stderr.write('Unable to load locale information falling back to default English language translations.\n')
53    import __builtin__    import __builtin__
54    __builtin__.__dict__['_'] = lambda string:string    __builtin__.__dict__['_'] = lambda string:string
# Line 106  class GBaseApp: Line 109  class GBaseApp:
109           [ 'connections', None, 'connections', 1, None, "loc",           [ 'connections', None, 'connections', 1, None, "loc",
110             _('Specifies the location of the connection definition file. ') + \             _('Specifies the location of the connection definition file. ') + \
111             _('<loc> may specify a file name ') + \             _('<loc> may specify a file name ') + \
112             _('(/usr/local/gnue/etc/connections.conf), ') + \             '(/usr/local/gnue/etc/connections.conf),'  + \
113             _('or a URL location ') + \             _('or a URL location ') + \
114             _('(http://localhost/connections.conf). ')+ \             '(http://localhost/connections.conf).' + \
115             _('If this option is not specified, the environent variable ') + \             _('If this option is not specified, the environent variable ') + \
116             _('GNUE_CONNECTIONS is checked.') ],             _('GNUE_CONNECTIONS is checked.') ],
117           [ 'help', None, 'help', 0, None, None,           [ 'help', None, 'help', 0, None, None,
# Line 142  class GBaseApp: Line 145  class GBaseApp:
145      for optionset in [self._base_options, self.COMMAND_OPTIONS]:      for optionset in [self._base_options, self.COMMAND_OPTIONS]:
146        for option in optionset:        for option in optionset:
147          self.OPTIONS[option[0]] = option[4]          self.OPTIONS[option[0]] = option[4]
148          if option[1] != None:          if option[1] != None:
149            shortoptions = shortoptions + option[1]            shortoptions += option[1]
150            lookup["-" + option[1]] = option[0]            lookup["-" + option[1]] = option[0]
151          lookup["--" + option[2]] = option[0]          lookup["--" + option[2]] = option[0]
152          lo = option[2]          lo = option[2]
153          if option[3]:            if option[3]:
154            lo = lo + '='            lo += '='
155            shortoptions = shortoptions + ':'            shortoptions += ':'
156          longoptions.append(lo)          longoptions.append(lo)
157    
158      try:      try:
# Line 193  class GBaseApp: Line 196  class GBaseApp:
196      except ValueError:      except ValueError:
197        self.handleStartupError(_('The debug_level option ("-d") expects a numerical value.'))        self.handleStartupError(_('The debug_level option ("-d") expects a numerical value.'))
198    
199            
200        
201      GDebug.printMesg(1,"Python %s" % sys.version)      GDebug.printMesg(1,"Python %s" % sys.version)
202      GDebug.printMesg(1,"Run Options: %s" % opt)      GDebug.printMesg(1,"Run Options: %s" % opt)
203      GDebug.printMesg(1,"Run Arguments: %s" % self.ARGUMENTS)      GDebug.printMesg(1,"Run Arguments: %s" % self.ARGUMENTS)
# Line 213  class GBaseApp: Line 216  class GBaseApp:
216            _('%s while reading gnue.conf: ') % type[0] \            _('%s while reading gnue.conf: ') % type[0] \
217            + '\n   %s'         % msg)            + '\n   %s'         % msg)
218    
219        # Add custom import to python's namespace
220        try:
221          extrapaths = gConfig('ImportPath')
222        except:
223          extrapaths = ""
224        if extrapaths:
225          for path in string.split(extrapaths,','):
226            p = string.strip(path)
227            if not p in sys.path:
228              sys.path.append(p)
229    
230      # Get the connection definitions      # Get the connection definitions
231      if connections != None:      if connections != None:
232        GDebug.printMesg(1,"Reusing connections instance")        GDebug.printMesg(1,"Reusing connections instance")
# Line 237  class GBaseApp: Line 251  class GBaseApp:
251          self.handleStartupError(          self.handleStartupError(
252              _('Unable to load the connections definition file.\n') \              _('Unable to load the connections definition file.\n') \
253              + _('\n   The connections file is in an invalid format. ') \              + _('\n   The connections file is in an invalid format. ') \
254              + _('\n   %s') \              + '\n   %s' \
255                 % msg)                 % msg)
256        except IOError:        except IOError:
257          self.handleStartupError(          self.handleStartupError(
# Line 313  class GBaseApp: Line 327  class GBaseApp:
327      self.printVersion()      self.printVersion()
328      print _("Usage:  %s %s\n\n%s\n\nAvailable command line options:\n%s") % \      print _("Usage:  %s %s\n\n%s\n\nAvailable command line options:\n%s") % \
329         (self.COMMAND, self.USAGE, self.SUMMARY, dispOptions)         (self.COMMAND, self.USAGE, self.SUMMARY, dispOptions)
330      print _("%s\n" % self.REPORT_BUGS_TO)      print "%s\n" % self.REPORT_BUGS_TO
331    
332    
333    #    #

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26