Browse Source

t.rast.export: use CWD as crossplatform default directory (#1817)

* use platformindependent tmp-dir

* use label and description

* Use CWD
Stefan Blumentrath 3 years ago
parent
commit
2802ca4563
1 changed files with 11 additions and 2 deletions
  1. 11 2
      temporal/t.rast.export/t.rast.export.py

+ 11 - 2
temporal/t.rast.export/t.rast.export.py

@@ -37,9 +37,11 @@
 
 
 # %option G_OPT_M_DIR
 # %option G_OPT_M_DIR
 # % key: directory
 # % key: directory
-# % description: Path to the work directory, default is /tmp
+# % label: Path to the directory where output is written
+# % description: If not given, the default is the current working directory
 # % required: no
 # % required: no
-# % answer: /tmp
+# % multiple: no
+# % answer: ./
 # %end
 # %end
 
 
 # %option
 # %option
@@ -102,6 +104,7 @@
 # %option G_OPT_T_WHERE
 # %option G_OPT_T_WHERE
 # %end
 # %end
 
 
+import os
 import grass.script as grass
 import grass.script as grass
 
 
 
 
@@ -122,6 +125,12 @@ def main():
         key: options[key] for key in ("createopt", "metaopt", "nodata") if options[key]
         key: options[key] for key in ("createopt", "metaopt", "nodata") if options[key]
     }
     }
 
 
+    if not directory or not os.path.exists(directory):
+        grass.fatal(_("Directory {} not found".format(directory)))
+
+    if not os.access(directory, os.W_OK):
+        grass.fatal(_("Directory {} is not writable".format(directory)))
+
     if _type and _format in ["pack", "AAIGrid"]:
     if _type and _format in ["pack", "AAIGrid"]:
         grass.warning(
         grass.warning(
             _("Type options is not working with pack format, " "it will be skipped")
             _("Type options is not working with pack format, " "it will be skipped")