[GRASS-SVN] r73179 - in grass/trunk/gui/wxpython: . startup
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Aug 24 19:01:07 PDT 2018
Author: wenzeslaus
Date: 2018-08-24 19:01:07 -0700 (Fri, 24 Aug 2018)
New Revision: 73179
Modified:
grass/trunk/gui/wxpython/gis_set.py
grass/trunk/gui/wxpython/startup/guiutils.py
Log:
wxGUI/startup: obtaining version number as a function
Modified: grass/trunk/gui/wxpython/gis_set.py
===================================================================
--- grass/trunk/gui/wxpython/gis_set.py 2018-08-25 01:38:01 UTC (rev 73178)
+++ grass/trunk/gui/wxpython/gis_set.py 2018-08-25 02:01:07 UTC (rev 73179)
@@ -108,18 +108,7 @@
# labels
# crashes when LOCATION doesn't exist
# get version & revision
- versionFile = open(os.path.join(globalvar.ETCDIR, "VERSIONNUMBER"))
- versionLine = versionFile.readline().rstrip('\n')
- versionFile.close()
- try:
- grassVersion, grassRevision = versionLine.split(' ', 1)
- if grassVersion.endswith('svn'):
- grassRevisionStr = ' (%s)' % grassRevision
- else:
- grassRevisionStr = ''
- except ValueError:
- grassVersion = versionLine
- grassRevisionStr = ''
+ grassVersion, grassRevisionStr = sgui.GetVersion()
self.gisdbase_box = wx.StaticBox(
parent=self.panel, id=wx.ID_ANY, label=" %s " %
Modified: grass/trunk/gui/wxpython/startup/guiutils.py
===================================================================
--- grass/trunk/gui/wxpython/startup/guiutils.py 2018-08-25 01:38:01 UTC (rev 73178)
+++ grass/trunk/gui/wxpython/startup/guiutils.py 2018-08-25 02:01:07 UTC (rev 73179)
@@ -20,6 +20,7 @@
import grass.script as gs
+from core import globalvar
from core.gcmd import DecodeString, RunCommand
from gui_core.dialogs import TextEntryDialog
from gui_core.widgets import GenericValidator
@@ -82,3 +83,28 @@
rc.close()
return grassrc
+
+
+def GetVersion():
+ """Gets version and revision
+
+ Returns tuple `(version, revision)`. For standard releases revision
+ is an empty string.
+
+ Revision string is currently wrapped in parentheses with added
+ leading space. This is an implementation detail and legacy and may
+ change anytime.
+ """
+ versionFile = open(os.path.join(globalvar.ETCDIR, "VERSIONNUMBER"))
+ versionLine = versionFile.readline().rstrip('\n')
+ versionFile.close()
+ try:
+ grassVersion, grassRevision = versionLine.split(' ', 1)
+ if grassVersion.endswith('svn'):
+ grassRevisionStr = ' (%s)' % grassRevision
+ else:
+ grassRevisionStr = ''
+ except ValueError:
+ grassVersion = versionLine
+ grassRevisionStr = ''
+ return (grassVersion, grassRevisionStr)
More information about the grass-commit
mailing list