[GRASS-dev] [GRASS GIS] #3211: Pygrass crash when trying to drop DB table

GRASS GIS trac at osgeo.org
Thu Mar 22 16:23:22 PDT 2018


#3211: Pygrass crash when trying to drop DB table
----------------------+---------------------------------
  Reporter:  lrntct   |      Owner:  grass-dev@…
      Type:  defect   |     Status:  new
  Priority:  normal   |  Milestone:  7.2.3
 Component:  PyGRASS  |    Version:  svn-releasebranch72
Resolution:           |   Keywords:
       CPU:  x86-64   |   Platform:  Linux
----------------------+---------------------------------

Comment (by lucadelu):

 I tested the example and it is quite strange because inside the pyGRASS
 code is returning error, but if I run the problematic command just after
 there is no error...


 {{{
 ## -- End pasted text --
 WARNING: Vector map <drop_table_test> already exists and will be
          overwritten
 > /home/lucadelu/compilati/grass_trunk/dist.x86_64-pc-linux-
 gnu/etc/python/grass/script/vector.py(49)vector_db()
 -> s = read_command('v.db.connect', quiet=True, flags='g', map=map,
 sep=';',
 (Pdb) c
 WARNING: Coor file of vector map <drop_table_test at user1> is larger than it
          should be (18 bytes excess)
 Building topology for vector map <drop_table_test at user1>...
 Registering primitives...
 ---------------------------------------------------------------------------
 CalledModuleError                         Traceback (most recent call
 last)
 <ipython-input-1-0ba8b438fe5f> in <module>()
      12                   table=vect_map.name + 'junc', key='cat')
      13     t_junc = l_junc.table()
 ---> 14     t_junc.create(cols_j, overwrite=True)

 /home/lucadelu/compilati/grass_trunk/dist.x86_64-pc-linux-
 gnu/etc/python/grass/pygrass/vector/table.pyc in create(self, cols, name,
 overwrite, cursor)
    1162         except OperationalError:  # OperationalError
    1163             if overwrite:
 -> 1164                 self.drop(force=True)
    1165                 cur.execute(sql.CREATE_TAB.format(tname=newname,
    1166                                                   coldef=coldef))

 /home/lucadelu/compilati/grass_trunk/dist.x86_64-pc-linux-
 gnu/etc/python/grass/pygrass/vector/table.pyc in drop(self, cursor, force)
    1029         cur = cursor if cursor else self.conn.cursor()
    1030         if self.exist(cursor=cur):
 -> 1031             used = db_table_in_vector(self.name)
    1032             if used is not None and len(used) > 0 and not force:
    1033                 print(_("Deleting table <%s> which is attached"

 /home/lucadelu/compilati/grass_trunk/dist.x86_64-pc-linux-
 gnu/etc/python/grass/script/db.pyc in db_table_in_vector(table, mapset)
     192     vects = list_strings('vect', mapset=mapset)
     193     for vect in vects:
 --> 194         for f in vector_db(vect, stderr=nuldev).values():
     195             if not f:
     196                 continue

 /home/lucadelu/compilati/grass_trunk/dist.x86_64-pc-linux-
 gnu/etc/python/grass/script/vector.pyc in vector_db(map, **args)
      47     """
      48     import pdb; pdb.set_trace()
 ---> 49     s = read_command('v.db.connect', quiet=True, flags='g',
 map=map, sep=';',
      50                      **args)
      51     pdb.set_trace()

 /home/lucadelu/compilati/grass_trunk/dist.x86_64-pc-linux-
 gnu/etc/python/grass/script/core.pyc in read_command(*args, **kwargs)
     474     if _capture_stderr and returncode:
     475         sys.stderr.write(stderr)
 --> 476     return handle_errors(returncode, stdout, args, kwargs)
     477
     478

 /home/lucadelu/compilati/grass_trunk/dist.x86_64-pc-linux-
 gnu/etc/python/grass/script/core.pyc in handle_errors(returncode, result,
 args, kwargs)
     330         args = make_command(*args, **kwargs)
     331         raise CalledModuleError(module=None, code=repr(args),
 --> 332                                 returncode=returncode)
     333
     334 def start_command(prog, flags=b"", overwrite=False, quiet=False,

 CalledModuleError: Module run None ['v.db.connect', '--q', '-g',
 'map=drop_table_test at user1', 'sep=;'] ended with error
 Process ended with non-zero return code 1. See errors in the (error)
 output.

 In [2]: from grass.script import read_command

 In [3]: s = read_command('v.db.connect', quiet=True, flags='g',
 map='drop_table_test@
    ...: user1', sep=';')
 WARNING: Coor file of vector map <drop_table_test at user1> is larger than it
          should be (18 bytes excess)

 In [4]: s
 Out[4]:
 '1/drop_table_test;drop_table_test;cat;/home/lucadelu/grassdata/nc_spm_08_grass7/user1/sqlite/sqlite.db;sqlite\n'
 }}}

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



More information about the grass-dev mailing list