[GRASS-dev] [GRASS GIS] #3537: Add functionalities –tmp-location and –no-clean

GRASS GIS trac at osgeo.org
Sat Mar 24 12:44:26 PDT 2018


#3537: Add functionalities –tmp-location and –no-clean
-----------------------------+------------------------------------------
  Reporter:  radeknovotny94  |      Owner:  grass-dev@…
      Type:  enhancement     |     Status:  new
  Priority:  normal          |  Milestone:  8.0.0
 Component:  Startup         |    Version:  svn-trunk
Resolution:                  |   Keywords:  tmp-location, no-clean, exec
       CPU:  All             |   Platform:  All
-----------------------------+------------------------------------------

Comment (by wenzeslaus):

 Thumbs up for creating a `find_tmp()` function, but you replaced:

 {{{
 #!python
 for ttmp in ("/tmp", "/var/tmp", "/usr/tmp"):
     tmp = ttmp
     tmpdir = os.path.join(tmp, "grass7-%(user)s-%(lock)s" % {
                                       'user': user, 'lock': gis_lock})
     try:
         os.mkdir(tmpdir, 0o700)
     except:
         tmp = None
     if tmp:
         break
 }}}

 by:

 {{{
 #!python
 def find_tmp():
     ...
     for ttmp in ("/tmp", "/var/tmp", "/usr/tmp"):
         tmp = ttmp
 ...
 tmp = find_tmp()
 tmpdir = os.path.join(tmp, "grass7-%(user)s-%(lock)s" % {'user': user,
                                                          'lock':
 gis_lock})
 try:
     os.mkdir(tmpdir, 0o700)
 ...
 }}}

 Note esp. the for loop and the test using try.

-- 
Ticket URL: <https://trac.osgeo.org/grass/ticket/3537#comment:1>
GRASS GIS <https://grass.osgeo.org>



More information about the grass-dev mailing list