瀏覽代碼

wxGUI: more fixes related to grass.version()

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@59289 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 11 年之前
父節點
當前提交
e49dbf0bd3
共有 3 個文件被更改,包括 25 次插入13 次删除
  1. 15 5
      gui/wxpython/gui_core/ghelp.py
  2. 9 7
      gui/wxpython/lmgr/frame.py
  3. 1 1
      gui/wxpython/mapdisp/frame.py

+ 15 - 5
gui/wxpython/gui_core/ghelp.py

@@ -9,7 +9,7 @@ Classes:
  - ghelp::HelpWindow
  - ghelp::HelpWindow
  - ghelp::HelpPanel
  - ghelp::HelpPanel
 
 
-(C) 2008-2012 by the GRASS Development Team
+(C) 2008-2014 by the GRASS Development Team
 
 
 This program is free software under the GNU General Public License
 This program is free software under the GNU General Public License
 (>=v2). Read the file COPYING that comes with GRASS for details.
 (>=v2). Read the file COPYING that comes with GRASS for details.
@@ -22,6 +22,7 @@ import codecs
 import platform
 import platform
 import re
 import re
 import textwrap
 import textwrap
+import sys
 
 
 import wx
 import wx
 from wx.html import HtmlWindow
 from wx.html import HtmlWindow
@@ -95,6 +96,8 @@ class AboutWindow(wx.Frame):
         """!Info page"""
         """!Info page"""
         # get version and web site
         # get version and web site
         vInfo = grass.version()
         vInfo = grass.version()
+        if not vInfo:
+            sys.stderr.write(_("Unable to get GRASS version\n"))
         
         
         infoTxt = ScrolledPanel(self.aboutNotebook)
         infoTxt = ScrolledPanel(self.aboutNotebook)
         infoTxt.SetBackgroundColour('WHITE')
         infoTxt.SetBackgroundColour('WHITE')
@@ -109,7 +112,7 @@ class AboutWindow(wx.Frame):
                       flag = wx.ALL | wx.ALIGN_CENTER, border = 20)
                       flag = wx.ALL | wx.ALIGN_CENTER, border = 20)
         
         
         info = wx.StaticText(parent = infoTxt, id = wx.ID_ANY,
         info = wx.StaticText(parent = infoTxt, id = wx.ID_ANY,
-                             label = 'GRASS GIS ' + vInfo['version'] + '\n')
+                             label = 'GRASS GIS ' + vInfo.get('version', _('unknown version')) + '\n')
         info.SetFont(wx.Font(13, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
         info.SetFont(wx.Font(13, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
         info.SetForegroundColour(wx.Colour(35, 142, 35))
         info.SetForegroundColour(wx.Colour(35, 142, 35))
         infoSizer.Add(item = info, proportion = 0,
         infoSizer.Add(item = info, proportion = 0,
@@ -137,7 +140,7 @@ class AboutWindow(wx.Frame):
                           flag = wx.ALIGN_RIGHT)
                           flag = wx.ALIGN_RIGHT)
         
         
         infoGridSizer.Add(item = wx.StaticText(parent = infoTxt, id = wx.ID_ANY,
         infoGridSizer.Add(item = wx.StaticText(parent = infoTxt, id = wx.ID_ANY,
-                                               label = vInfo['revision']),
+                                               label = vInfo.get('revision', '?')),
                           pos = (row, 1),
                           pos = (row, 1),
                           flag = wx.ALIGN_LEFT)
                           flag = wx.ALIGN_LEFT)
         
         
@@ -148,7 +151,7 @@ class AboutWindow(wx.Frame):
                           flag = wx.ALIGN_RIGHT)
                           flag = wx.ALIGN_RIGHT)
         
         
         infoGridSizer.Add(item = wx.StaticText(parent = infoTxt, id = wx.ID_ANY,
         infoGridSizer.Add(item = wx.StaticText(parent = infoTxt, id = wx.ID_ANY,
-                                               label = vInfo['build_date']),
+                                               label = vInfo.get('build_date', '?')),
                           pos = (row, 1),
                           pos = (row, 1),
                           flag = wx.ALIGN_LEFT)
                           flag = wx.ALIGN_LEFT)
         
         
@@ -798,5 +801,12 @@ def ShowAboutDialog(prgName, startYear):
     wx.AboutBox(info)
     wx.AboutBox(info)
 
 
 def _grassDevTeam(start):
 def _grassDevTeam(start):
-    end = grass.version()['date']
+    try:
+        end = grass.version()['date']
+    except KeyError:
+        sys.stderr.write(_("Unable to get GRASS version\n"))
+        
+        from datetime import date
+        end = date.today().year
+    
     return '%(c)s %(start)s-%(end)s by the GRASS Development Team' % {'c': unichr(169), 'start': start, 'end': end}
     return '%(c)s %(start)s-%(end)s by the GRASS Development Team' % {'c': unichr(169), 'start': start, 'end': end}

+ 9 - 7
gui/wxpython/lmgr/frame.py

@@ -92,7 +92,7 @@ class GMFrame(wx.Frame):
             try:
             try:
                 grassVersion = grass.version()['version']
                 grassVersion = grass.version()['version']
             except KeyError:
             except KeyError:
-                sys.stderr.write(_("Unable to get GRASS version"))
+                sys.stderr.write(_("Unable to get GRASS version\n"))
                 grassVersion = "?"
                 grassVersion = "?"
             self.baseTitle = _("GRASS GIS %s Layer Manager") % grassVersion
             self.baseTitle = _("GRASS GIS %s Layer Manager") % grassVersion
 
 
@@ -979,7 +979,9 @@ class GMFrame(wx.Frame):
     def OnSystemInfo(self, event):
     def OnSystemInfo(self, event):
         """!Print system information"""
         """!Print system information"""
         vInfo = grass.version()
         vInfo = grass.version()
-        
+        if not vInfo:
+            sys.stderr.write(_("Unable to get GRASS version\n"))
+
         # check also OSGeo4W on MS Windows
         # check also OSGeo4W on MS Windows
         if sys.platform == 'win32' and \
         if sys.platform == 'win32' and \
                 not os.path.exists(os.path.join(os.getenv("GISBASE"), "WinGRASS-README.url")):
                 not os.path.exists(os.path.join(os.getenv("GISBASE"), "WinGRASS-README.url")):
@@ -1001,11 +1003,11 @@ class GMFrame(wx.Frame):
                                 "SQLite: %s\n"
                                 "SQLite: %s\n"
                                 "Python: %s\n"
                                 "Python: %s\n"
                                 "wxPython: %s\n"
                                 "wxPython: %s\n"
-                                "%s: %s%s\n"% (_("GRASS version"), vInfo['version'],
-                                               _("GRASS SVN Revision"), vInfo['revision'],
-                                               _("Build Date"), vInfo['build_date'],
-                                               # _("GIS Library Revision"), vInfo['libgis_revision'], vInfo['libgis_date'].split(' ', 1)[0],
-                                               vInfo['gdal'], vInfo['proj4'], vInfo['geos'], vInfo['sqlite'],
+                                "%s: %s%s\n"% (_("GRASS version"), vInfo.get('version', _('unknown version')),
+                                               _("GRASS SVN Revision"), vInfo.get('revision', '?'),
+                                               _("Build Date"), vInfo.get('build_date', '?'),
+                                               # _("GIS Library Revision"), vInfo.get('libgis_revision'], vInfo.get('libgis_date'].split(' ', 1)[0],
+                                               vInfo.get('gdal', '?'), vInfo.get('proj4', '?'), vInfo.get('geos', '?'), vInfo.get('sqlite', '?'),
                                                platform.python_version(),
                                                platform.python_version(),
                                                wx.__version__,
                                                wx.__version__,
                                                _("Platform"), platform.platform().decode('utf8', 'replace'), osgeo4w),
                                                _("Platform"), platform.platform().decode('utf8', 'replace'), osgeo4w),

+ 1 - 1
gui/wxpython/mapdisp/frame.py

@@ -247,7 +247,7 @@ class MapFrame(SingleMapFrame):
         try:
         try:
             grassVersion = grass.version()['version']
             grassVersion = grass.version()['version']
         except KeyError:
         except KeyError:
-            sys.stderr.write(_("Unable to get GRASS version"))
+            sys.stderr.write(_("Unable to get GRASS version\n"))
             grassVersion = "?"
             grassVersion = "?"
         
         
         title = _("GRASS GIS %(version)s Map Display: %(id)s  - Location: %(loc)s@%(mapset)s") % \
         title = _("GRASS GIS %(version)s Map Display: %(id)s  - Location: %(loc)s@%(mapset)s") % \