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

gdal_calc incorrectly reports requiring no arguments for the --debug option #11312

Open
ughur-a opened this issue Nov 20, 2024 · 4 comments
Open

Comments

@ughur-a
Copy link

ughur-a commented Nov 20, 2024

What is the bug?

the help page gdal_calc lists a --debug option, but says that it requires no arguments. In reality however, it seems to require a int value passed - the more sensible options being 0, 1 (but true and false also work)

Steps to reproduce the issue

gdal_calc --debug

returns ERROR 1: --debug option given without debug level.


Passing --debug before another option results in a cryptic error message:

gdal_calc.bat --calc "A+B" --format SAGA --type Float32 -A foo --A_band 1 -B bar --B_band 1 --debug --outfile baz

returns: gdal_calc.py: error: argument --B_band: invalid int value: 'baz'

Versions and provenance

OS: Windows 11
GDAL version: GDAL 3.9.3, released 2024/10/07 (the newest available version)
Source of the GDAL binary: OSGeo4W

Additional context

No response

@jratike80
Copy link
Collaborator

In the beginning of this Python script I read
debug: bool = False
Thus, it requires a standard Python boolean value True or False, but a few other alternatives work as well https://www.w3schools.com/python/python_booleans.asp.

@ughur-a
Copy link
Author

ughur-a commented Nov 20, 2024

Yes, I've seen that as well. But from I've gathered the, the arguments to the function are not the raw arguments passed to the command line - rather, the command line arguments first get parsed by GDALArgumentParser (see here), and it then passes the result to the actual function. And I guess GDALArgumentParser is the one that expects ints

@jratike80
Copy link
Collaborator

Interesting, --quiet is configured in the same way but gdal_calc --quiet does not complain.

parser.add_argument(
            "--debug",
            dest="debug",
            action="store_true",
            help="print debugging information",
        )
        parser.add_argument(
            "--quiet",
            dest="quiet",
            action="store_true",
            help="suppress progress messages"

@rouault
Copy link
Member

rouault commented Nov 20, 2024

Interesting, --quiet is configured in the same way but gdal_calc --quiet does not complain.

--debug is handled by generic GDAL parsing argument code, before the rest of gdal_calc has a chance to see it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants