[GRASS-SVN] r62311 - in grass/branches/releasebranch_7_0: . scripts/r.unpack scripts/v.unpack

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Oct 21 01:02:50 PDT 2014


Author: lucadelu
Date: 2014-10-21 01:02:50 -0700 (Tue, 21 Oct 2014)
New Revision: 62311

Modified:
   grass/branches/releasebranch_7_0/
   grass/branches/releasebranch_7_0/scripts/r.unpack/r.unpack.py
   grass/branches/releasebranch_7_0/scripts/v.unpack/v.unpack.py
Log:
r/v.unpack: check if the pack is the right type for that command (ticket #2455)


Property changes on: grass/branches/releasebranch_7_0
___________________________________________________________________
Modified: svn:mergeinfo
   - /grass/trunk:61280,62141,62144,62269,62271,62276,62288,62305
   + /grass/trunk:61280,62141,62144,62269,62271,62276,62288,62305,62310

Modified: grass/branches/releasebranch_7_0/scripts/r.unpack/r.unpack.py
===================================================================
--- grass/branches/releasebranch_7_0/scripts/r.unpack/r.unpack.py	2014-10-21 08:00:56 UTC (rev 62310)
+++ grass/branches/releasebranch_7_0/scripts/r.unpack/r.unpack.py	2014-10-21 08:02:50 UTC (rev 62311)
@@ -88,6 +88,14 @@
     tar.extractall()
     os.chdir(data_name)
 
+    if os.path.exists('cell'):
+        pass
+    elif os.path.exists('coor'):
+        grass.fatal(_("This GRASS GIS pack file contains vector data. Use "
+                      "v.unpack to unpack <%s>" % map_name))
+    else:
+        grass.fatal(_("Pack file unreadable"))
+
     # check projection compatibility in a rather crappy way
     diff_result_1 = diff_result_2 = None
     proj_info_file_1 = 'PROJ_INFO'

Modified: grass/branches/releasebranch_7_0/scripts/v.unpack/v.unpack.py
===================================================================
--- grass/branches/releasebranch_7_0/scripts/v.unpack/v.unpack.py	2014-10-21 08:00:56 UTC (rev 62310)
+++ grass/branches/releasebranch_7_0/scripts/v.unpack/v.unpack.py	2014-10-21 08:02:50 UTC (rev 62311)
@@ -4,7 +4,7 @@
 #
 # MODULE:       v.unpack
 # AUTHOR(S):    Luca Delucchi
-#               
+#
 # PURPOSE:      Unpack up a vector map packed with v.pack
 # COPYRIGHT:    (C) 2010-2013 by the GRASS Development Team
 #
@@ -95,18 +95,25 @@
 
     # extract data
     tar.extractall()
+    if os.path.exists(os.path.join(map_name, 'coor')):
+        pass
+    elif os.path.exists(os.path.join(map_name, 'cell')):
+        grass.fatal(_("This GRASS GIS pack file contains raster data. Use "
+                      "r.unpack to unpack <%s>" % map_name))
+    else:
+        grass.fatal(_("Pack file unreadable"))
 
     # check projection compatibility in a rather crappy way
     loc_proj = os.path.join(mset_dir, '..', 'PERMANENT', 'PROJ_INFO')
     loc_proj_units = os.path.join(mset_dir, '..', 'PERMANENT', 'PROJ_UNITS')
 
     diff_result_1 = diff_result_2 = None
-    if not grass.compare_key_value_text_files(filename_a=os.path.join(tmp_dir,'PROJ_INFO'),
+    if not grass.compare_key_value_text_files(filename_a=os.path.join(tmp_dir, 'PROJ_INFO'),
                                               filename_b=loc_proj, proj=True):
         diff_result_1 = diff_files(os.path.join(tmp_dir, 'PROJ_INFO'),
                                          loc_proj)
 
-    if not grass.compare_key_value_text_files(filename_a=os.path.join(tmp_dir,'PROJ_UNITS'),
+    if not grass.compare_key_value_text_files(filename_a=os.path.join(tmp_dir, 'PROJ_UNITS'),
                                               filename_b=loc_proj_units,
                                               units=True):
         diff_result_2 = diff_files(os.path.join(tmp_dir, 'PROJ_UNITS'),
@@ -176,16 +183,16 @@
                                       from_table=from_table):
                 grass.fatal(_("Unable to copy table <%s> as table <%s>") % (from_table, to_table))
 
-            grass.verbose(_("Connect table <%s> to vector map <%s> at layer <%s>") % \
-                              (to_table, map_name, layer))
+            grass.verbose(_("Connect table <%s> to vector map <%s> at layer <%s>") %
+                           (to_table, map_name, layer))
 
             # and connect the new tables with the right layer
             if 0 != grass.run_command('v.db.connect', flags='o', quiet=True,
                                       driver=dbconn['driver'], database=todb,
                                       map=map_name, key=values[2],
                                       layer=layer, table=to_table):
-                grass.fatal(_("Unable to connect table <%s> to vector map <%s>") % \
-                                (to_table, map_name))
+                grass.fatal(_("Unable to connect table <%s> to vector map <%s>") %
+                             (to_table, map_name))
 
     grass.message(_("Vector map <%s> succesfully unpacked") % map_name)
 



More information about the grass-commit mailing list