浏览代码

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

* use platformindependent tmp-dir

* use label and description

* Use CWD
Stefan Blumentrath 3 年之前
父节点
当前提交
2802ca4563
共有 1 个文件被更改,包括 11 次插入2 次删除
  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
 # % 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
-# % answer: /tmp
+# % multiple: no
+# % answer: ./
 # %end
 
 # %option
@@ -102,6 +104,7 @@
 # %option G_OPT_T_WHERE
 # %end
 
+import os
 import grass.script as grass
 
 
@@ -122,6 +125,12 @@ def main():
         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"]:
         grass.warning(
             _("Type options is not working with pack format, " "it will be skipped")