[GRASS-SVN] r73842 - grass/branches/releasebranch_7_4/lib/init

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Dec 25 14:34:14 PST 2018


Author: neteler
Date: 2018-12-25 14:34:14 -0800 (Tue, 25 Dec 2018)
New Revision: 73842

Modified:
   grass/branches/releasebranch_7_4/lib/init/grass.py
Log:
grass.py: minor comment and msg fixes; trailing white space removed (trunk, r73840); minor formatting sync to relbranch76

Modified: grass/branches/releasebranch_7_4/lib/init/grass.py
===================================================================
--- grass/branches/releasebranch_7_4/lib/init/grass.py	2018-12-25 22:32:59 UTC (rev 73841)
+++ grass/branches/releasebranch_7_4/lib/init/grass.py	2018-12-25 22:34:14 UTC (rev 73842)
@@ -495,6 +495,8 @@
                           line=line, error=e, file=filename))
             continue
         kv[k.strip()] = v.strip()
+    if not kv:
+        warning(_("Empty RC file ({file})").format(file=filename))
     f.close()
 
     return kv
@@ -719,6 +721,7 @@
         os.environ['HOME'] = os.path.join(os.getenv('HOMEDRIVE'),
                                           os.getenv('HOMEPATH'))
 
+
 def create_initial_gisrc(filename):
     # for convenience, define GISDBASE as pwd:
     s = r"""GISDBASE: %s
@@ -981,7 +984,7 @@
     if not os.path.exists(wxpath("gis_set.py")) and grass_gui != 'text':
         debug("No GUI available, switching to text mode")
         return False
-    
+
     # Check for text interface
     if grass_gui == 'text':
         # TODO: maybe this should be removed and solved from outside
@@ -998,6 +1001,7 @@
 
     return True
 
+
 def gui_startup(grass_gui):
     """Start GUI for startup (setting gisrc file)"""
     if grass_gui in ('wxpython', 'gtext'):
@@ -1106,7 +1110,7 @@
         os.environ['ISIS_LIB'] = isis + os.sep + "lib"
         os.environ['ISIS_3RDPARTY'] = isis + os.sep + "3rdParty" + os.sep + "lib"
         os.environ['QT_PLUGIN_PATH'] = isis + os.sep + "3rdParty" + os.sep + "plugins"
-        #os.environ['ISIS3DATA'] = isis + "$ISIS3DATA"
+        # os.environ['ISIS3DATA'] = isis + "$ISIS3DATA"
         libpath = os.getenv('LD_LIBRARY_PATH', '')
         isislibpath = os.getenv('ISIS_LIB')
         isis3rdparty = os.getenv('ISIS_3RDPARTY')
@@ -1122,7 +1126,7 @@
     # thus it always on Vista and XP will print an error.
     # See discussion for Windows not following its own documentation and
     # not accepting ISO codes as valid locale identifiers http://bugs.python.org/issue10466
-    language = 'None' # Such string sometimes is present in wx file
+    language = 'None'  # Such string sometimes is present in wx file
     encoding = None
 
     # Override value is stored in wxGUI preferences file.
@@ -1418,7 +1422,6 @@
     """
     # Start the chosen GUI but ignore text
     debug("GRASS GUI should be <%s>" % grass_gui)
-    
     # Check for gui interface
     if grass_gui == "wxpython":
         Popen([os.getenv('GRASS_PYTHON'), wxpath("wxgui.py")])
@@ -1439,7 +1442,8 @@
             os.kill(int(pid), signal.SIGTERM)
         except OSError as e:
             message(_("Unable to close GUI. {0}").format(e))
-        
+
+
 def clear_screen():
     """Clear terminal"""
     if windows:
@@ -1479,10 +1483,10 @@
 
 
 def show_info(shellname, grass_gui, default_gui):
-    """Write basic infor about GRASS GIS and GRASS session to stderr"""
+    """Write basic info about GRASS GIS and GRASS session to stderr"""
     sys.stderr.write(
 r"""
-%-41shttp://grass.osgeo.org
+%-41shttps://grass.osgeo.org
 %-41s%s (%s)
 %-41sg.manual -i
 %-41sg.version -c
@@ -1525,7 +1529,8 @@
     f.write("GRASS GIS %s > '\n" % grass_version)
     f.write("set BOGUS=``;unset BOGUS\n")
 
-    path = os.path.join(userhome, ".grass.cshrc") # left for backward compatibility
+    # csh shell rc file left for backward compatibility
+    path = os.path.join(userhome, ".grass.cshrc")
     if os.access(path, os.R_OK):
         f.write(readfile(path) + '\n')
     if os.access(grass_env_file, os.R_OK):
@@ -1544,14 +1549,11 @@
 
     path = os.getenv('PATH').split(':')
     f.write("set path = ( %s ) \n" % ' '.join(path))
-
     f.close()
     writefile(tcshrc, readfile(cshrc))
 
     process = Popen([gpath("etc", "run"), os.getenv('SHELL')])
-    
     os.environ['HOME'] = userhome
-    
     return process
 
 
@@ -1603,14 +1605,11 @@
                 f.write(line + '\n')
 
     f.write("export PATH=\"%s\"\n" % os.getenv('PATH'))
-    f.write("export HOME=\"%s\"\n" % userhome) # restore user home path
+    f.write("export HOME=\"%s\"\n" % userhome)  # restore user home path
+    f.close()
 
-    f.close()
-    
     process = Popen([gpath("etc", "run"), os.getenv('SHELL')])
-    
     os.environ['HOME'] = userhome
-    
     return process
 
 
@@ -1779,7 +1778,7 @@
     return params
 
 
-### MAIN script starts here
+# The main script starts here
 
 # Get the system name
 windows = sys.platform == 'win32'
@@ -1789,7 +1788,7 @@
 # TODO: it is OK to remove this?
 # at the beginning of this file were are happily getting GISBASE
 # from the environment and we don't care about inconsistencies it might cause
-### commented-out: broken winGRASS
+# The following was commented out because of breaking winGRASS
 # if 'GISBASE' in os.environ:
 #     sys.exit(_("ERROR: GRASS GIS is already running "
 #                "(environmental variable GISBASE found)"))
@@ -1845,7 +1844,8 @@
     # Set the username
     user = get_username()
 
-    # TODO: this might need to be moved before processing of parameters and getting batch job
+    # TODO: this might need to be moved before processing of parameters
+    # and getting batch job
     # Set language
     # This has to be called before any _() function call!
     # Subsequent functions are using _() calls and
@@ -2009,6 +2009,7 @@
 
         # close GUI if running
         close_gui()
+
         # here we are at the end of grass session
         clear_screen()
         # TODO: can we just register this atexit?



More information about the grass-commit mailing list