Skip to content

Commit

Permalink
Continue update
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Oct 9, 2024
1 parent e0525fb commit 2f4f2df
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 33 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ WORKDIR /opt/c2cgeoportal/admin
RUN --mount=type=cache,target=/var/cache,sharing=locked \
--mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/tmp \
npm install --omit=optional \
npm install --omit=optional --ignore-scripts \
&& rm -rf /tmp/angular \
&& git clone --branch=v1.7.x --depth=1 --single-branch https://github.com/angular/angular.js.git /tmp/angular \
&& mv /tmp/angular/src/ngLocale/ /opt/angular-locale/ \
Expand Down Expand Up @@ -208,7 +208,7 @@ RUN chmod ugo+rw /etc/xdg
# hadolint ignore=DL3016,SC2046
RUN --mount=type=cache,target=/var/cache,sharing=locked \
--mount=type=cache,target=/root/.cache \
npm install --omit=dev --omit=optional
npm install --omit=dev --omit=optional --ignore-scripts

COPY bin/eval-templates bin/wait-db bin/list4vrt bin/azure /usr/bin/
COPY --from=tools-cleaned /opt/c2cgeoportal /opt/c2cgeoportal
Expand Down
4 changes: 3 additions & 1 deletion admin/c2cgeoportal_admin/schemas/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
from c2cgeoportal_commons.models.main import Interface


def interfaces_schema_node(prop: InstrumentedAttribute[Any]) -> colander.SequenceSchema:
def interfaces_schema_node(
prop: InstrumentedAttribute[Any], # pylint: disable=unsubscriptable-object
) -> colander.SequenceSchema:
"""Get the serializable representation of an interface."""
return colander.SequenceSchema(
GeoFormManyToManySchemaNode(Interface, None),
Expand Down
4 changes: 3 additions & 1 deletion admin/c2cgeoportal_admin/schemas/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
from c2cgeoportal_commons.models.main import Role


def roles_schema_node(prop: InstrumentedAttribute[Any]) -> colander.SequenceSchema:
def roles_schema_node(
prop: InstrumentedAttribute[Any], # pylint: disable=unsubscriptable-object
) -> colander.SequenceSchema:
"""Get the schema of all the items."""
return colander.SequenceSchema(
GeoFormManyToManySchemaNode(Role, None),
Expand Down
76 changes: 47 additions & 29 deletions scripts/updated_version
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@

import argparse
import json
import re
import subprocess

from packaging.version import Version


def output(cmd: list[str]) -> bytes:
try:
Expand All @@ -49,8 +50,8 @@ def _get_postgresql_version(deb_versions: dict[str, str]) -> str:
return max(deb_version.values())


def get_versions(
version: str, old_version: float
def _get_versions(
version: str, old_version: Version
) -> tuple[list[tuple[str, str]], dict[str, str], dict[str, str]]:
deb_versions = {
e.split("==")[0]: e.split("==")[1]
Expand Down Expand Up @@ -143,7 +144,7 @@ def get_versions(
("Postgres", _get_postgresql_version(deb_versions)),
]

if old_version >= 2.6:
if old_version >= Version("2.6.0"):
major_versions += (
(
"GDAL",
Expand Down Expand Up @@ -201,29 +202,48 @@ def get_versions(
.split("\n")
if e and len(e.split("==")) == 2 and e[0] not in ("#", "-")
},
{
e: v["version"]
for e, v in json.loads(
output(
[
"docker",
"run",
"--rm",
"--entrypoint=",
f"camptocamp/geomapfish-tools:{version}",
"npm",
"list",
"--global",
"--json",
"--depth=0",
]
)
)["dependencies"].items()
if "version" in v and e != "ngeo"
},
{e: v["version"] for e, v in _get_npm_versions(version).items() if "version" in v and e != "ngeo"},
)


def _get_npm_versions(version_str: str) -> dict[str, dict[str, str]]:
version = Version("999!9" if version_str == "latest" else version_str)
if version >= Version("2.9.0"):
return json.loads(
output(
[
"docker",
"run",
"--rm",
"--entrypoint=",
"--workdir=/opt/c2cgeoportal/geoportal",
f"camptocamp/geomapfish-tools:{version_str}",
"npm",
"list",
"--json",
"--depth=0",
]
)
)["dependencies"]
else:
return json.loads(
output(
[
"docker",
"run",
"--rm",
"--entrypoint=",
f"camptocamp/geomapfish-tools:{version_str}",
"npm",
"list",
"--global",
"--json",
"--depth=0",
]
)
)["dependencies"]


def print_package_update(package_old: dict[str, str], package_new: dict[str, str]) -> None:
print("New packages:")
for name, version in package_new.items():
Expand Down Expand Up @@ -260,11 +280,9 @@ def main() -> None:
parser.add_argument("new_version", metavar="NEW", help="The new GeoMapFish version")
args = parser.parse_args()

old_major_version = 3.0
if re.match(r".*\.\d\.\d$", args.old_version):
old_major_version = float(args.old_version[:3])
main_old, python_old, npm_old = get_versions(args.old_version, old_major_version)
main_new, python_new, npm_new = get_versions(args.new_version, old_major_version)
old_major_version = Version("999!9" if args.old_version == "latest" else args.old_version)
main_old, python_old, npm_old = _get_versions(args.old_version, old_major_version)
main_new, python_new, npm_new = _get_versions(args.new_version, old_major_version)

print("Main versions updates")
print("-------------------")
Expand Down

0 comments on commit 2f4f2df

Please sign in to comment.