Skip to content

Commit

Permalink
Merge pull request #185 from geopython/termy-windows
Browse files Browse the repository at this point in the history
make console examples both Linux/Mac and Windows
  • Loading branch information
doublebyte1 authored Nov 17, 2024
2 parents 19cd59c + 81818d7 commit f6211c0
Show file tree
Hide file tree
Showing 13 changed files with 1,287 additions and 668 deletions.
47 changes: 34 additions & 13 deletions workshop/content/docs/advanced/cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@ state, therefore being able to scale without risks.

A [Docker image](https://hub.docker.com/r/geopython/pygeoapi) is available for pygeoapi. You can run the image locally as:

<div class="termy">
```bash
docker run -p 5000:80 geopython/pygeoapi:latest
```
</div>
=== "Linux/Mac"

<div class="termy">
```bash
docker run -p 5000:80 geopython/pygeoapi:latest
```
</div>

=== "Windows (PowerShell)"

<div class="termy">
```bash
docker run -p 5000:80 geopython/pygeoapi:latest
```
</div>

!!! question "Review the pygeoapi Dockerfile"

Expand All @@ -36,7 +46,7 @@ In a typical configuration one would override the default pygeoapi configuration
```
</div>

=== "Windows"
=== "Windows (PowerShell)"

<div class="termy">
```bash
Expand All @@ -58,13 +68,24 @@ match the public endpoint of the service (domain, path and port).
By default the pygeoapi Docker image will run from the `root` path `/`. If you need to run from a sub-path and have all internal URLs correct you can
set the `SCRIPT_NAME` environment variable.

<div class="termy">
```bash
docker run -p 5000:80 -e SCRIPT_NAME='/mypygeoapi' \
-v $(pwd)/my.config.yml:/pygeoapi/local.config.yml -it geopython/pygeoapi
# browse to http://localhost:5000/mypygeoapi
```
</div>
=== "Linux/Mac"

<div class="termy">
```bash
docker run -p 5000:80 -e SCRIPT_NAME='/mypygeoapi' \
-v $(pwd)/my.config.yml:/pygeoapi/local.config.yml -it geopython/pygeoapi
# browse to http://localhost:5000/mypygeoapi
```
</div>

=== "Windows (PowerShell)"

<div class="termy">
```bash
docker run -p 5000:80 -e SCRIPT_NAME='/mypygeoapi' -v ${pwd}/my.config.yml:/pygeoapi/local.config.yml -it geopython/pygeoapi
# browse to http://localhost:5000/mypygeoapi
```
</div>

# Summary

Expand Down
40 changes: 30 additions & 10 deletions workshop/content/docs/advanced/i18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,39 @@ Most of the translatable text strings exist within the Jinja2 HTML templates. Te

Babel provides a utility which extracts all keys to be translated from the templates into a single `.pot` file.

<div class="termy">
```bash
pybabel extract -F babel-mapping.ini -o locale/messages.pot ./
```
</div>
=== "Linux/Mac"

<div class="termy">
```bash
pybabel extract -F babel-mapping.ini -o locale/messages.pot ./
```
</div>

=== "Windows (PowerShell)"

<div class="termy">
```bash
pybabel extract -F babel-mapping.ini -o locale/messages.pot ./
```
</div>

The resulting `.pot` file is used to create or update existing `.po` files, which exist for each language, containing the actual translations.

<div class="termy">
```bash
pybabel init -d locale -l it -i locale/messages.pot
```
</div>
=== "Linux/Mac"

<div class="termy">
```bash
pybabel init -d locale -l it -i locale/messages.pot
```
</div>

=== "Windows (PowerShell)"

<div class="termy">
```bash
pybabel init -d locale -l it -i locale/messages.pot
```
</div>

The `.po` files are stored in pygeoapi's source code repository on GitHub. You can create a Pull Request to add or update your favourite languages. `.po` files can also be added to translation software such as [transifex.com](https://transifex.com).

Expand Down
20 changes: 15 additions & 5 deletions workshop/content/docs/advanced/inspire.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,21 @@ recommendation and the relevant Good Practices.
Download the zipfile 'inspire-records.zip' from the repository. Expand the zipfile. The `/tests` folder contains a script
[load_tinydb_records.py](https://github.com/geopython/pygeoapi/blob/master/tests/load_tinydb_records.py). The script has 2 parameters:

<div class="termy">
```bash
python3 load_tinydb_records.py <path/to/xml-files> <output.db>
```
</div>
=== "Linux/Mac"

<div class="termy">
```bash
python3 load_tinydb_records.py <path/to/xml-files> <output.db>
```
</div>

=== "Windows (PowerShell)"

<div class="termy">
```bash
python3 load_tinydb_records.py <path/to/xml-files> <output.db>
```
</div>

Now configure [TinyDB as a provider for OGC API - Records](https://docs.pygeoapi.io/en/latest/data-publishing/ogcapi-records.html#tinydbcatalogue). Restart the service and verify the result. Verify also the XML output of some of the records.

Expand Down
77 changes: 56 additions & 21 deletions workshop/content/docs/publishing/first.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,54 @@ To test:

1. In a terminal shell navigate to the workshop folder and type:

<div class="termy">
```bash
cd workshop/exercises
docker compose up
```
</div>
=== "Linux/Mac"

<div class="termy">
```bash
cd workshop/exercises
docker compose up
```
</div>

=== "Windows (PowerShell)"

<div class="termy">
```bash
cd workshop/exercises
docker compose up
```
</div>

1. Open <http://localhost:5000> in your browser, verify some collections
1. Close by typing `CTRL-C`

!!! note

You may also run the Docker container in the background (detached) as follows:

<div class="termy">
```bash
docker compose up -d
docker ps # verify that the pygeoapi container is running
# visit http://localhost:5000 in your browser, verify some collections
docker logs --follow pygeoapi # view logs
docker compose stop
```
</div>

=== "Linux/Mac"

<div class="termy">
```bash
docker compose up -d
docker ps # verify that the pygeoapi container is running
# visit http://localhost:5000 in your browser, verify some collections
docker logs --follow pygeoapi # view logs
docker compose stop
```
</div>

=== "Windows (PowerShell)"

<div class="termy">
```bash
docker compose up -d
docker ps # verify that the pygeoapi container is running
# visit http://localhost:5000 in your browser, verify some collections
docker logs --follow pygeoapi # view logs
docker compose stop
```
</div>
## Publish first dataset

You are now ready to publish your first dataset.
Expand Down Expand Up @@ -169,11 +194,21 @@ Set the logging level to `DEBUG` and indicate a path to a log file.
On Docker, set the path of the logfile to the mounted folder, so you can easily access it from your host system. You can also view the console logs from
your Docker container as follows:

<div class="termy">
```bash
docker logs --follow pygeoapi
```
</div>
=== "Linux/Mac"

<div class="termy">
```bash
docker logs --follow pygeoapi
```
</div>

=== "Windows (PowerShell)"

<div class="termy">
```bash
docker logs --follow pygeoapi
```
</div>

!!! tip

Expand Down
123 changes: 87 additions & 36 deletions workshop/content/docs/publishing/ogcapi-coverages.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,22 @@ Save the configuration and restart Docker Compose. Navigate to <http://localhost
- Verify you have a recent GDAL installed, else use GDAL from OSGeoLive
- Run `gdalinfo` on the command line to verify a connection to OGC API - Coverages:

<div class="termy">
```
gdalinfo OGCAPI:https://maps.ecere.com/ogcapi/collections/SRTM_ViewFinderPanorama
```
</div>
=== "Linux/Mac"

<div class="termy">
```
gdalinfo OGCAPI:https://maps.ecere.com/ogcapi/collections/SRTM_ViewFinderPanorama
```
</div>

=== "Windows (PowerShell)"

<div class="termy">
```
gdalinfo OGCAPI:https://maps.ecere.com/ogcapi/collections/SRTM_ViewFinderPanorama
```
</div>


### OWSLib

Expand All @@ -88,37 +99,77 @@ Save the configuration and restart Docker Compose. Navigate to <http://localhost

If you do not have Python installed, consider running this exercise in a Docker container. See the [Setup Chapter](../setup.md#using-docker-for-python-clients).

<div class="termy">
```bash
pip3 install owslib
```
</div>

<div class="termy">
```python
>>> from owslib.ogcapi.coverages import Coverages
>>> SERVICE_URL = 'https://demo.pygeoapi.io/master/'
>>> w = Coverages(SERVICE_URL)
>>> w.url
'https://demo.pygeoapi.io/master/'
>>> gdps = w.collection('gdps-temperature')
>>> gdps['id']
'gdps-temperature'
>>> gdps['title']
'Global Deterministic Prediction System sample'
>>> gdps['description']
'Global Deterministic Prediction System sample'
>>> schema = w.collection_schema('gdps-temperature')
>>> len(schema['field'])
1
>>> schema['properties']['1']['title']
'Temperature [C]'
>>> schema['properties']['1']['x-ogc-unit']
'[C]'
>>> schema['properties']['1']['type']
'number'
```
</div>
=== "Linux/Mac"
<div class="termy">
```bash
pip3 install owslib
```
</div>

=== "Windows (PowerShell)"
<div class="termy">
```bash
pip3 install owslib
```
</div>

Then start a Python console session with: `python3` (stop the session by typing `exit()`).

=== "Linux/Mac"

<div class="termy">
```python
>>> from owslib.ogcapi.coverages import Coverages
>>> SERVICE_URL = 'https://demo.pygeoapi.io/master/'
>>> w = Coverages(SERVICE_URL)
>>> w.url
'https://demo.pygeoapi.io/master/'
>>> gdps = w.collection('gdps-temperature')
>>> gdps['id']
'gdps-temperature'
>>> gdps['title']
'Global Deterministic Prediction System sample'
>>> gdps['description']
'Global Deterministic Prediction System sample'
>>> schema = w.collection_schema('gdps-temperature')
>>> len(schema['field'])
1
>>> schema['properties']['1']['title']
'Temperature [C]'
>>> schema['properties']['1']['x-ogc-unit']
'[C]'
>>> schema['properties']['1']['type']
'number'
```
</div>

=== "Windows (PowerShell)"

<div class="termy">
```python
>>> from owslib.ogcapi.coverages import Coverages
>>> SERVICE_URL = 'https://demo.pygeoapi.io/master/'
>>> w = Coverages(SERVICE_URL)
>>> w.url
'https://demo.pygeoapi.io/master/'
>>> gdps = w.collection('gdps-temperature')
>>> gdps['id']
'gdps-temperature'
>>> gdps['title']
'Global Deterministic Prediction System sample'
>>> gdps['description']
'Global Deterministic Prediction System sample'
>>> schema = w.collection_schema('gdps-temperature')
>>> len(schema['field'])
1
>>> schema['properties']['1']['title']
'Temperature [C]'
>>> schema['properties']['1']['x-ogc-unit']
'[C]'
>>> schema['properties']['1']['type']
'number'
```
</div>

!!! note

Expand Down
Loading

0 comments on commit f6211c0

Please sign in to comment.