From 5d70b0a99f28e6cbbd774b93dee22c56ffd4c870 Mon Sep 17 00:00:00 2001 From: Saurabh Singh Date: Wed, 7 Jan 2026 21:39:02 +0530 Subject: [PATCH 1/2] v.to.lines: Handle missing layer 1 table gracefully --- scripts/v.to.lines/v.to.lines.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/scripts/v.to.lines/v.to.lines.py b/scripts/v.to.lines/v.to.lines.py index d6bdc58f2a8..dae697af5ab 100644 --- a/scripts/v.to.lines/v.to.lines.py +++ b/scripts/v.to.lines/v.to.lines.py @@ -62,7 +62,15 @@ def main(): if gs.verbosity() > 2: quiet = False - in_info = gs.vector_info(input) + try: + in_info = gs.vector_info(input) + except CalledModuleError: + gs.fatal( + _( + "Unable to get vector map info for <{name}>. " + "The input vector map may not have a valid structure or attribute table." + ).format(name=input) + ) # check for wild mixture of vector types if in_info["points"] > 0 and in_info["boundaries"] > 0: gs.fatal( @@ -88,7 +96,15 @@ def main(): gs.run_command("v.db.addtable", map=out_temp, quiet=True) input = out_temp - in_info = gs.vector_info(input) + try: + in_info = gs.vector_info(input) + except CalledModuleError: + gs.fatal( + _( + "Unable to get vector map info for <{name}> after point processing. " + "The processed vector may not have a valid structure." + ).format(name=input) + ) # process areas if in_info["areas"] == 0 and in_info["boundaries"] == 0: From f14c09ed1c46d43197e112e46d48791159300c73 Mon Sep 17 00:00:00 2001 From: Saurabh Singh Date: Thu, 8 Jan 2026 15:51:18 +0530 Subject: [PATCH 2/2] v.to.lines: Fix table dropping to use correct layer --- scripts/v.to.lines/v.to.lines.py | 40 +++++++------------------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/scripts/v.to.lines/v.to.lines.py b/scripts/v.to.lines/v.to.lines.py index dae697af5ab..c032565b105 100644 --- a/scripts/v.to.lines/v.to.lines.py +++ b/scripts/v.to.lines/v.to.lines.py @@ -62,15 +62,7 @@ def main(): if gs.verbosity() > 2: quiet = False - try: - in_info = gs.vector_info(input) - except CalledModuleError: - gs.fatal( - _( - "Unable to get vector map info for <{name}>. " - "The input vector map may not have a valid structure or attribute table." - ).format(name=input) - ) + in_info = gs.vector_info(input) # check for wild mixture of vector types if in_info["points"] > 0 and in_info["boundaries"] > 0: gs.fatal( @@ -96,15 +88,7 @@ def main(): gs.run_command("v.db.addtable", map=out_temp, quiet=True) input = out_temp - try: - in_info = gs.vector_info(input) - except CalledModuleError: - gs.fatal( - _( - "Unable to get vector map info for <{name}> after point processing. " - "The processed vector may not have a valid structure." - ).format(name=input) - ) + in_info = gs.vector_info(input) # process areas if in_info["areas"] == 0 and in_info["boundaries"] == 0: @@ -193,19 +177,13 @@ def main(): gs.fatal(_("Error removing centroids")) try: - try: - # TODO: fix magic numbers for layer here and there - gs.run_command( - "v.db.droptable", map=out_type, layer=1, flags="f", quiet=True - ) - except CalledModuleError: - gs.run_command( - "g.remove", flags="f", type="vector", name=remove_names, quiet=quiet - ) - gs.fatal(_("Error removing table from layer 1")) - # TODO: when this except is happening, it seems that never, so it seems wrong - except Exception: - gs.warning(_("No table for layer %d") % 1) + # TODO: fix magic numbers for layer here and there + gs.run_command("v.db.droptable", map=out_type, layer=2, flags="f", quiet=True) + except CalledModuleError: + gs.run_command( + "g.remove", flags="f", type="vector", name=remove_names, quiet=quiet + ) + gs.fatal(_("Error removing table from layer 2")) try: gs.run_command( "v.category",