Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,28 @@ jobs:
- name: Install Requirements 📦
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt
pip3 install -r requirements.txt
pip3 install -r requirements-dev.txt

- name: Setup GHC App and init DB 🗃️
run: |
paver setup
echo -e "admin\ntest\ntest\nyou@example.com\nyou@example.com" | python GeoHealthCheck/models.py create
invoke setup
echo -e "admin\ntest\ntest\nyou@example.com\nyou@example.com" | python3 GeoHealthCheck/models.py create

- name: Flake8 - Verify Coding Conventions ⚙️
run: flake8

- name: Load Fixtures Test Data ⚙️
run: python GeoHealthCheck/models.py load tests/data/fixtures.json y
run: python3 GeoHealthCheck/models.py load tests/data/fixtures.json y

- name: Run Probes ⚙️
run: python GeoHealthCheck/healthcheck.py
run: python3 GeoHealthCheck/healthcheck.py

- name: Run Unit Tests ⚙️
run: python tests/run_tests.py
run: python3 tests/run_tests.py

- name: Build Docs 📖
run: cd docs && make html

- name: Cleanup 💯
run: python GeoHealthCheck/models.py drop
run: python3 GeoHealthCheck/models.py drop
2 changes: 1 addition & 1 deletion GeoHealthCheck/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#
# =================================================================

from util import read
from .util import read


def get_package_version(file_):
Expand Down
4 changes: 2 additions & 2 deletions GeoHealthCheck/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# Usage:
#
# $ python manage.py --help
# $ python3 manage.py --help
# usage: manage.py [-h] {shell,db,runserver} ...
#
# positional arguments:
Expand All @@ -19,7 +19,7 @@
# -h, --help show this help message and exit
#
# For DB management:
# $ python manage.py db --help
# $ python3 manage.py db --help
# usage: Perform database migrations
#
# positional arguments:
Expand Down
10 changes: 5 additions & 5 deletions GeoHealthCheck/migrations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ and Flask-Script.
Users should be able to upgrade existing installs via:

# In top dir of installation
paver upgrade
invoke upgrade

The `versions` dir contains the various upgrades. These were
initially created using the Alembic `autogenerate` facility
Expand All @@ -20,12 +20,12 @@ for various DB management tasks related to migrations and upgrading.
Whenever a change in the database schema or table content
conventions has changed a new migration should be created via the command.

python manage.py db migrate
python3 manage.py db migrate

Where `migrate` is an alias for `revision --autogenerate`.
Alternatively if the autogeneration does not work, create an empty migration:

python manage.py db revision
python3 manage.py db revision

In both cases this will create a new revision and a `<revision_number>_.py` file
under `versions/` to upgrade
Expand All @@ -37,9 +37,9 @@ to check various DB metadata.

Subsequently the upgrade can be performed using:

python manage.py db upgrade
python3 manage.py db upgrade
# or the equivalent (for users)
paver upgrade
invoke upgrade

## Revisions

Expand Down
2 changes: 1 addition & 1 deletion GeoHealthCheck/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ def db_commit():

elif sys.argv[1] == 'run':
print('NOTICE: models.py no longer here.')
print('Use: python healthcheck.py or upcoming cli.py')
print('Use: python3 healthcheck.py or upcoming cli.py')
elif sys.argv[1] == 'flush':
flush_runs()

Expand Down
5 changes: 3 additions & 2 deletions GeoHealthCheck/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
from urllib.parse import urlparse
from gettext import translation
from passlib.hash import pbkdf2_sha256
from factory import Factory
from init import App

from GeoHealthCheck.factory import Factory
from GeoHealthCheck.init import App

from jinja2 import Environment, FileSystemLoader

Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ virtualenv GeoHealthCheck && cd $_
. bin/activate
git clone https://github.com/geopython/GeoHealthCheck.git
cd GeoHealthCheck
pip install Paver
pip3 install Invoke
# setup installation
paver setup
invoke setup
# generate secret key
paver create_secret_key
invoke create_secret_key
# setup local configuration (overrides GeoHealthCheck/config_main.py)
vi instance/config_site.py
# edit at least secret key:
# - SECRET_KEY # copy/paste result string from paver create_secret_key
# - SECRET_KEY # copy/paste result string from `invoke create_secret_key`

# Optional: edit other settings or leave defaults
# - SQLALCHEMY_DATABASE_URI
Expand All @@ -37,32 +37,32 @@ vi instance/config_site.py
# - GHC_MAP (or use default settings)

# setup database and superuser account interactively
paver create
invoke create

# start webserver with healthcheck runner daemon inside
# (default is 0.0.0.0:8000)
python GeoHealthCheck/app.py
python3 GeoHealthCheck/app.py
# or start webserver on another port
python GeoHealthCheck/app.py 0.0.0.0:8881
python3 GeoHealthCheck/app.py 0.0.0.0:8881
# or start webserver on another IP
python GeoHealthCheck/app.py 192.168.0.105:8001
python3 GeoHealthCheck/app.py 192.168.0.105:8001

# OR start webserver and separate runner daemon (scheduler) process
vi instance/config_site.py
# GHC_RUNNER_IN_WEBAPP = False
python GeoHealthCheck/scheduler.py &
python GeoHealthCheck/app.py
python3 GeoHealthCheck/scheduler.py &
python3 GeoHealthCheck/app.py

# next: use a real webserver or preferably Docker for production

# other commands
#
# drop database
python GeoHealthCheck/models.py drop
python3 GeoHealthCheck/models.py drop

# load data in database (WARN: deletes existing data!)
# See example data .json files in tests/data
python GeoHealthCheck/models.py load <.json data file> [y/n]
python3 GeoHealthCheck/models.py load <.json data file> [y/n]

```

Expand Down
6 changes: 3 additions & 3 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ docker exec -it docker_geohealthcheck_1 bash
source /venv/bin/activate .
cd /GeoHealthCheck/

# next can use Paver commands e.g. DB upgrade
paver upgrade
# next can use Invoke commands e.g. DB upgrade
invoke upgrade

etc
```

NB: database upgrades (`paver upgrade`)
NB: database upgrades (`invoke upgrade`)
are always performed automatically when running GHC via Docker.
2 changes: 1 addition & 1 deletion docker/scripts/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function create_db() {
pushd /GeoHealthCheck/ || exit 1
source bin/activate

paver create -u ${ADMIN_NAME} -p ${ADMIN_PWD} -e ${ADMIN_EMAIL}
invoke create -u ${ADMIN_NAME} -p ${ADMIN_PWD} -e ${ADMIN_EMAIL}
popd || exit 1
}

Expand Down
2 changes: 1 addition & 1 deletion docker/scripts/cron-jobs-hourly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ then
cp -ar /plugins/* /GeoHealthCheck/GeoHealthCheck/plugins/
fi

python /GeoHealthCheck/GeoHealthCheck/healthcheck.py
python3 /GeoHealthCheck/GeoHealthCheck/healthcheck.py
4 changes: 2 additions & 2 deletions docker/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ source bin/activate


# Docker-specific deps
pip install --no-cache-dir -r docker/scripts/requirements.txt
pip3 install --no-cache-dir -r docker/scripts/requirements.txt

# Sets up GHC itself
paver setup
invoke setup
mv /config_site.py /GeoHealthCheck/instance/config_site.py

# Copy possible Plugins into app tree
Expand Down
2 changes: 1 addition & 1 deletion docker/scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Paver==1.3.4
invoke==3.0.3
2 changes: 1 addition & 1 deletion docker/scripts/run-runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export PYTHONPATH=/GeoHealthCheck/GeoHealthCheck:$PYTHONPATH

cd /GeoHealthCheck
source bin/activate
paver runner_daemon
invoke runner_daemon

echo "END /run-runner.sh"
2 changes: 1 addition & 1 deletion docker/scripts/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ export PYTHONPATH=/GeoHealthCheck/GeoHealthCheck:$PYTHONPATH

cd /GeoHealthCheck
source bin/activate
paver run_tests
invoke run_tests

echo "END /run-tests.sh"
4 changes: 2 additions & 2 deletions docker/scripts/run-web.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pushd /GeoHealthCheck || exit 1

source bin/activate

paver upgrade
invoke upgrade

# SCRIPT_NAME should not have value '/'
[ "${SCRIPT_NAME}" = '/' ] && export SCRIPT_NAME="" && echo "make SCRIPT_NAME empty from /"
Expand All @@ -31,6 +31,6 @@ exec gunicorn --pythonpath /GeoHealthCheck/lib/python3.12/site-packages/ --worke
GeoHealthCheck.app:APP

# Built-in Flask server, deprecated
# python /GeoHealthCheck/GeoHealthCheck/app.py ${HOST}:${PORT}
# python3 /GeoHealthCheck/GeoHealthCheck/app.py ${HOST}:${PORT}

echo "END /run-web.sh"
15 changes: 7 additions & 8 deletions docs/admin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ To create the database execute the following:

Open a command line, (if needed activate your virtualenv), and do ::

python GeoHealthCheck/models.py create
python3 GeoHealthCheck/models.py create

drop db
.......
Expand All @@ -30,7 +30,7 @@ To delete the database execute the following, however you will loose all your in

Open a command line, (if needed activate your virtualenv), and do ::

python GeoHealthCheck/models.py drop
python3 GeoHealthCheck/models.py drop

Note: you need to create a Database again before you can start GHC again.

Expand All @@ -39,7 +39,7 @@ load data

To load a JSON data file, do (WARN: deletes existing data!) ::

python GeoHealthCheck/models.py load <datafile.json> [y/n]
python3 GeoHealthCheck/models.py load <datafile.json> [y/n]

Hint: see `tests/data` for example JSON data files.

Expand Down Expand Up @@ -75,10 +75,10 @@ a password is forgotten and somehow the email-based reset is not available nor w
In that case, password-hashes can be created from the command-line using the Python library `passlib <https://passlib.readthedocs.io/en/stable/>`_
within an interactive Python-shell as follows: ::

$ pip install passlib
$ pip3 install passlib
# or in Debian/Ubuntu: apt-get install python-passlib

python
python3
>>> from passlib.hash import pbkdf2_sha256
>>>
>>> hash = pbkdf2_sha256.hash("mynewpassword")
Expand All @@ -93,10 +93,9 @@ Or more compact within the root dir of your GHC installation: ::
>>> create_hash('mynewpassword')
'$pbkdf2-sha256$29000$8X4PAUAIAcC4V2rNea9Vqg$XnMx1SfEiBzBAMOQOOC7uxCcyzVuKaHENLj3IfXvfu0'

Or even more compact within the root dir of your GHC installation via Paver: ::
Or even more compact within the root dir of your GHC installation via Invoke: ::

$ paver create_hash -p mypass
---> pavement.create_hash
$ invoke create_hash -p mypass
Copy/paste the entire token below for example to set password
$pbkdf2-sha256$29000$FkJoTYnxPqc0pjQG4HxP6Q$C3SZb8jqtM7zKS1DSLcouc/CL9XMI9cL5xT6DRTOEd4

Expand Down
14 changes: 7 additions & 7 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The configuration options are:

- **SQLALCHEMY_DATABASE_URI**: the database configuration. See the SQLAlchemy documentation for more info
- **SQLALCHEMY_ENGINE_OPTION_PRE_PING**: DB Disconnect Handling, emitting a test statement on the SQL connection at the start of each connection pool checkout (default: ``False``)
- **SECRET_KEY**: secret key to set when enabling authentication. Use the output of ``paver create_secret_key`` to set this value
- **SECRET_KEY**: secret key to set when enabling authentication. Use the output of ``invoke create_secret_key`` to set this value
- **GHC_RETENTION_DAYS**: the number of days to keep Run history
- **GHC_PROBE_HTTP_TIMEOUT_SECS**: stop waiting for the first byte of a Probe response after the given number of seconds
- **GHC_MINIMAL_RUN_FREQUENCY_MINS**: minimal run frequency for Resource that can be set in web UI
Expand Down Expand Up @@ -51,7 +51,7 @@ The configuration options are:
Example on overriding the configuration with an environment variable: ::

export GHC_SETTINGS=/tmp/my_GHC_settings.py
paver run_tests
invoke run_tests

As an example: the `my_GHC_settings.py` file can contain a single line to define a test database: ::

Expand Down Expand Up @@ -94,9 +94,9 @@ Scheduling via Cron

Edit the file ``jobs.cron`` so that the paths reflect the path to the virtualenv.
Set the first argument to the desired monitoring time step. If finished editing,
copy the command line calls e.g. ``/YOURvirtualenv/bin_or_SCRIPTSonwindows/python /path/to/GeoHealthCheck/GeoHealthCheck/healthcheck.py run``
copy the command line calls e.g. ``/YOURvirtualenv/bin_or_SCRIPTSonwindows/python3 /path/to/GeoHealthCheck/GeoHealthCheck/healthcheck.py run``
to the commandline to test if they work sucessfully.
On Windows - do not forget to include the ''.exe.'' file extension to the python executable.
On Windows - do not forget to include the ''.exe.'' file extension to the python3 executable.
For documentation how to create cron jobs see your operating system: on \*NIX systems e.g. ``crontab -e`` and on
windows e.g. the `nssm <https://nssm.cc/>`_.

Expand All @@ -111,7 +111,7 @@ This is the preferred mode as each `Resource` can have its own schedule (configu
via Dashboard) and `cron` has dependencies on local environment.
Later versions may phase out cron-scheduling completely.

The **GHC Runner** can be run via the command `paver runner_daemon` or can run internally within
The **GHC Runner** can be run via the command `invoke runner_daemon` or can run internally within
the **GHC Webapp** by setting the config variable **GHC_RUNNER_IN_WEBAPP** to `True` (the default).
NB it is still possible to run GHC as in the pre-v0.5.0 mode using cron-jobs: just run the
**GHC Webapp** with **GHC_RUNNER_IN_WEBAPP** set to `False` and have your cron-jobs scheduled.
Expand Down Expand Up @@ -153,7 +153,7 @@ Compiling Language Files
........................

At runtime compiled versions, `.mo` files, of the language-files are used.
Easiest to compile is via: `paver compile_translations` in the project root dir.
Easiest to compile is via: `invoke compile_translations` in the project root dir.
This basically calls `pybabel compile` with the proper options.
Now you can e.g. test your new translations by starting GHC.

Expand All @@ -175,7 +175,7 @@ Missing translations will have `msgstr ""` like in this excerpt: ::

Next all empty `msgstr` can be filled.

Updating is easiest using the command `paver update_translations` within the root dir of the project.
Updating is easiest using the command `invoke update_translations` within the root dir of the project.
This will basically call `pybabel extract` followed by `pybabel update` with the proper parameters.

Customizing the Score Matrix
Expand Down
Loading
Loading