Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

g.download.project: Fix string formatting error when download already exists #5339

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

echoix
Copy link
Member

@echoix echoix commented Mar 8, 2025

When trying to test locally for #5338, I stumbled across an error on Windows, but couldn't see it. The translated string contained both named placeholders and empty placeholder, but used keyword arguments. I don't know why I never noticed on Linux, but on Windows, there was no indication of what was happening.

d:\repos\grass_repo\grass\vector\v.univar>grass85 --tmp-project XY --exec g.download.project url=https://grass.osgeo.org/sampledata/north_carolina/nc_spm_full_v2alpha2.tar.gz path=%USERPROFILE%
WARNING: Concurrent mapset locking is not supported on Windows
Traceback (most recent call last):
  File "C:\OSGeo4W\apps\grass\grass85/scripts/g.download.project.py", line 153, in <module>
    main(*gs.parser())
  File "C:\OSGeo4W\apps\grass\grass85/scripts/g.download.project.py", line 107, in main
    ).format(name=name, directory=database)
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
IndexError: Replacement index 0 out of range for positional args tuple
Appuyez sur une touche pour continuer...

After this fix:

d:\repos\grass_repo\grass\vector\v.univar>grass85 --tmp-project XY --exec g.download.project url=https://grass.osgeo.org/sampledata/north_carolina/nc_spm_full_v2alpha2.tar.gz path=%USERPROFILE%
WARNING: Concurrent mapset locking is not supported on Windows
ERROR: Project named <nc_spm_full_v2alpha2> already exists in
       <C:\Users\E-C>, download canceled
Appuyez sur une touche pour continuer...

@echoix echoix requested a review from petrasovaa March 8, 2025 23:54
@github-actions github-actions bot added Python Related code is in Python module general labels Mar 8, 2025
@echoix
Copy link
Member Author

echoix commented Mar 9, 2025

I've skimmed through the 2789 results in python files for {} (grass and grass-addons), and I didn't find any other similar cases. I've also searched for the regex \{\}.*(.|[\n])+?\.format\(.*=.*\), and didn't find any similar case (that regex was able to find the error from this PR, when it wasn't a false positive match).

@echoix echoix enabled auto-merge (squash) March 9, 2025 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
general module Python Related code is in Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant