Skip to content

Commit

Permalink
Merge branch 'master' into 95-migrate-to-sqlalchemy-20-api
Browse files Browse the repository at this point in the history
  • Loading branch information
smsearcy committed May 6, 2024
2 parents 6aad35d + 075a97e commit 5f9c1e1
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 44 deletions.
7 changes: 4 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ MESH_INFO_MAP_LATITUDE=37.405
MESH_INFO_MAP_LONGITUDE=-98.525
MESH_INFO_MAP_ZOOM=5
MESH_INFO_LOG_LEVEL="INFO"
MESH_INFO_DATA_DIR="/var/lib/mesh-info"
MESH_INFO_DB_URL="postgresql+psycopg2://postgres:postgres@localhost:5432/postgres"
MESH_INFO_ENV="development"
MESH_INFO_MAP_TILE_URL=""
MESH_INFO_MAP_TILE_ATTRIBUTION=""
#MESH_INFO_DATA_DIR="/var/lib/mesh-info"
#MESH_INFO_DB_URL="postgresql+psycopg2://postgres:postgres@localhost:5432/postgres"
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.10.1
hooks:
- id: black

Expand Down
9 changes: 7 additions & 2 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ If you followed the :doc:`installation instructions <installation>` then it shou
Example
-------

.. note::

The Tile URL below requires registering with Stadia Maps: https://stadiamaps.com/stamen/onboarding/create-account

.. code-block:: ini
MESH_INFO_LOCAL_NODE="10.1.1.1"
MESH_INFO_MAP_LATITUDE="37.405"
MESH_INFO_MAP_LONGITUDE="-98.525"
MESH_INFO_MAP_ZOOM="5"
MESH_INFO_LOG_LEVEL=INFO
MESH_INFO_MAP_TILE_URL="https://tiles.stadiamaps.com/tiles/stamen_terrain/{z}/{x}/{y}{r}.png"
MESH_INFO_MAP_TILE_ATTRIBUTION='&copy; <a href="https://stadiamaps.com/" target="_blank">Stadia Maps</a> <a href="https://stamen.com/" target="_blank">&copy; Stamen Design</a> &copy; <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a> &copy; <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a>'
MESH_INFO_DB_URL="postgresql+psycopg2://postgres:password@localhost:5432/postgres"
Expand Down Expand Up @@ -43,6 +49,7 @@ MESH_INFO_COLLECTOR_WORKERS
MESH_INFO_DB_URL
Override the default SQLite database by pointing to a PostgreSQL server
(or changing the default location).
Default is SQLite database ``mesh-info.db`` in the data directory.

MESH_INFO_ENVIRONMENT
Either ``production`` or ``development``.
Expand Down Expand Up @@ -73,7 +80,6 @@ MESH_INFO_MAP_MAX_ZOOM
MESH_INFO_MAP_TILE_ATTRIBUTION
The attribution to display on the map.
Passed to Leaflet's `tileLayer()`_.
Default is appropriate for the default tile server.

.. warning::

Expand All @@ -84,7 +90,6 @@ MESH_INFO_MAP_TILE_ATTRIBUTION
MESH_INFO_MAP_TILE_URL
The template URL for the tile server.
Passed to Leaflet's `tileLayer()`_.
Default is ``//stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.jpg``

MESH_INFO_MAP_ZOOM
Default zoom level.
Expand Down
15 changes: 5 additions & 10 deletions meshinfo/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@
logger = structlog.get_logger()

FOLDER_NAME = "mesh-info"
_DEFAULT_TILE_URL = "//stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.jpg"
_DEFAULT_TILE_ATTRIBUTION = (
"Map tiles by <a href='http://stamen.com'>Stamen Design</a>, "
"under <a href='http://creativecommons.org/licenses/by/3.0'>CC BY 3.0</a>. "
"Data by <a href='http://openstreetmap.org'>OpenStreetMap</a>, "
"under <a href='http://www.openstreetmap.org/copyright'>ODbL</a>."
)


class Environment(enum.Enum):
Expand Down Expand Up @@ -75,8 +68,8 @@ class Map:
longitude: float = environ.var(default=-1.58, converter=float)
zoom: int = environ.var(default=3, converter=int)
max_zoom: int = environ.var(default=18, converter=int)
tile_url: str = environ.var(default=_DEFAULT_TILE_URL)
tile_attribution: str = environ.var(default=_DEFAULT_TILE_ATTRIBUTION)
tile_url: str = environ.var(default="")
tile_attribution: str = environ.var(default="")

@environ.config
class Web:
Expand Down Expand Up @@ -166,7 +159,9 @@ def configure(
# configure logging
configure_logging(app_config.log_level)

logger.debug("Application configuration", **attrs.asdict(app_config))
logger.debug(
"Application configuration", **attrs.asdict(app_config) # type: ignore
)

# configure Pyramid application
config = Configurator(settings=settings)
Expand Down
3 changes: 0 additions & 3 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
[mypy-appdirs.*]
ignore_missing_imports = True

[mypy-environ.*]
ignore_missing_imports = True

[mypy-hupper.*]
ignore_missing_imports = True

Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ classifiers = [
dependencies = [
"aiohttp ~= 3.8",
"alembic ~= 1.8",
"attrs ~= 22.1",
"environ-config ~= 22.1",
"gunicorn ~= 20.1",
"attrs ~= 23.1",
"environ-config ~= 23.2",
"gunicorn ~= 22.0",
"pendulum ~= 2.1",
"platformdirs ~= 2.0",
"psycopg2 ~= 2.9",
Expand All @@ -34,7 +34,7 @@ dependencies = [
"python-dotenv ~= 0.20",
"rich ~= 13.3",
"rrdtool",
"structlog ~= 22.3",
"structlog ~= 23.2",
"sqlalchemy ~= 1.4",
"transaction ~= 3.0",
"zope.sqlalchemy ~= 3.0",
Expand All @@ -55,7 +55,7 @@ tests = [
"WebTest",
"flake8-bugbear",
"flake8",
"mypy",
"mypy ~= 1.5.1",
"pytest-asyncio",
"pytest-cov",
"pytest-mock",
Expand Down
38 changes: 19 additions & 19 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,30 @@
#
# pip-compile --output-file=requirements.txt --resolver=backtracking pyproject.toml
#
aiohttp==3.8.4
aiohttp==3.8.6
# via mesh-info (pyproject.toml)
aiosignal==1.3.1
# via aiohttp
alembic==1.11.1
alembic==1.12.1
# via mesh-info (pyproject.toml)
async-timeout==4.0.2
async-timeout==4.0.3
# via aiohttp
attrs==22.2.0
attrs==23.1.0
# via
# aiohttp
# environ-config
# mesh-info (pyproject.toml)
charset-normalizer==3.1.0
charset-normalizer==3.3.1
# via aiohttp
environ-config==22.1.0
environ-config==23.2.0
# via mesh-info (pyproject.toml)
frozenlist==1.3.3
frozenlist==1.4.0
# via
# aiohttp
# aiosignal
greenlet==2.0.2
greenlet==3.0.1
# via sqlalchemy
gunicorn==20.1.0
gunicorn==22.0.0
# via mesh-info (pyproject.toml)
hupper==1.12
# via pyramid
Expand All @@ -50,8 +50,8 @@ multidict==6.0.4
# via
# aiohttp
# yarl
packaging==23.1
# via zope-sqlalchemy
packaging==23.2
# via gunicorn
pastedeploy==3.0.1
# via plaster-pastedeploy
pendulum==2.1.2
Expand All @@ -64,11 +64,11 @@ plaster-pastedeploy==1.0.1
# via pyramid
platformdirs==2.6.2
# via mesh-info (pyproject.toml)
psycopg2==2.9.6
psycopg2==2.9.9
# via mesh-info (pyproject.toml)
pygments==2.15.1
pygments==2.16.1
# via rich
pyramid==2.0.1
pyramid==2.0.2
# via
# mesh-info (pyproject.toml)
# pyramid-jinja2
Expand All @@ -89,18 +89,18 @@ python-dotenv==0.21.1
# via mesh-info (pyproject.toml)
pytzdata==2020.1
# via pendulum
rich==13.4.2
rich==13.6.0
# via mesh-info (pyproject.toml)
rrdtool==0.1.16
# via mesh-info (pyproject.toml)
six==1.16.0
# via python-dateutil
sqlalchemy==1.4.48
sqlalchemy==1.4.50
# via
# alembic
# mesh-info (pyproject.toml)
# zope-sqlalchemy
structlog==22.3.0
structlog==23.2.0
# via mesh-info (pyproject.toml)
transaction==3.1.0
# via
Expand All @@ -109,7 +109,7 @@ transaction==3.1.0
# zope-sqlalchemy
translationstring==1.4
# via pyramid
typing-extensions==4.6.3
typing-extensions==4.8.0
# via alembic
venusian==3.0.0
# via pyramid
Expand All @@ -123,7 +123,7 @@ zope-deprecation==5.0
# via
# pyramid
# pyramid-jinja2
zope-interface==6.0
zope-interface==6.1
# via
# pyramid
# pyramid-retry
Expand Down

0 comments on commit 5f9c1e1

Please sign in to comment.