Skip to content

Commit

Permalink
g.download.location: Print target path in error message (OSGeo#4155)
Browse files Browse the repository at this point in the history
* g.download.location: print target path in error message

To be less obscure in case the target location directory already exists:

```
ERROR: Location named <nc_spm_full_v2alpha2> already exists, download
       canceled
```

this PR improves the error message to include the path:

```
g.download.location url=https://grass.osgeo.org/sampledata/north_carolina/nc_spm_full_v2alpha2.tar.gz path=$HOME
ERROR: Location named <nc_spm_full_v2alpha2> already exists in
       </home/mneteler/nc_spm_full_v2alpha2>, download canceled
```

This is esp. relevant for scripted usage when the command isn't invoked directly by the user.

In addition, section  of **EXAMPLES** added.

* fix message format

Co-authored-by: Vaclav Petras <[email protected]>

* database -> project

Co-authored-by: Veronica Andreo <[email protected]>

---------

Co-authored-by: Vaclav Petras <[email protected]>
Co-authored-by: Veronica Andreo <[email protected]>
  • Loading branch information
3 people authored Aug 19, 2024
1 parent 309b417 commit a4257a1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
21 changes: 21 additions & 0 deletions scripts/g.download.location/g.download.location.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@ <h2>DESCRIPTION</h2>
The first directory which is a project is used.
Other projects or any other files are ignored.

<h2>EXAMPLES</h2>

<h3>Download the full GRASS GIS sample project within a running session</h3>

Download and unpack the full North Carolina sample project into the user's
HOME directory:

<div class="code"><pre>
g.download.location url=https://grass.osgeo.org/sampledata/north_carolina/nc_spm_full_v2alpha2.tar.gz path=$HOME
</pre></div>

<h3>Download the full GRASS GIS sample project in a temporary session</h3>

In a temporary session, download and unpack the full North Carolina sample project
into the user's HOME directory:

<div class="code"><pre>
grass --tmp-location XY --exec g.download.location url=https://grass.osgeo.org/sampledata/north_carolina/nc_spm_full_v2alpha2.tar.gz path=$HOME
</pre></div>


<h2>SEE ALSO</h2>

<em>
Expand Down
4 changes: 3 additions & 1 deletion scripts/g.download.location/g.download.location.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ def main(options, unused_flags):

if destination.exists():
gs.fatal(
_("Location named <{}> already exists, download canceled").format(name)
_(
"Location named <{name}> already exists in <{directory}>, download canceled"
).format(name=name, directory=database)
)

gs.message(_("Downloading and extracting..."))
Expand Down

0 comments on commit a4257a1

Please sign in to comment.