Bug#935887: python3-mapproxy: Change default template_dir and fix capabilities for Python >= 3.6.7

Marek Lukács marek.lukacs at gmail.com
Tue Aug 27 11:39:21 BST 2019


On Tue, Aug 27, 2019 at 12:23 PM Bas Couwenberg <sebastic at xs4all.nl> wrote:

> Control: tags -1 + moreinfo
> Control: tags -1 - d-i
>
> On 2019-08-27 11:52, Marek Lukács wrote:
> > MapProxy does not work on Python 3.7 installs. I figured out two
> > issues,
> > one related to Debian installation (directory structure) and other to
> > upstream known issue:
> >
> > 1. Directory structure
> >
> > Debian moves templates into /usr/share/python3-mapproxy/, but default
> > template_dir variable is not changed, so Python looks for templates
> > instead in /usr/lib/python3/dist-packages/mapproxy/.
> >
> > How to fix:
> > change default directory in
> > /usr/lib/python3/dist-packages/mapproxy/config/defaults.py
>
> What is the actual issue you experience?
>

Not working, failing with error:

fatal error in demo for /demo/?
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/mapproxy/wsgiapp.py", line 193, in
__call__
    resp = self.handlers[handler_name].handle(req)
  File "/usr/lib/python3/dist-packages/mapproxy/service/demo.py", line 121,
in handle
    demo = self._render_template('demo/demo.html')
  File "/usr/lib/python3/dist-packages/mapproxy/service/demo.py", line 161,
in _render_template
    template = get_template(template, default_inherit="demo/static.html")
  File "/usr/lib/python3/dist-packages/mapproxy/template.py", line 36, in
__call__
    default_inherit=default_inherit, get_template=self)
  File
"/usr/lib/python3/dist-packages/mapproxy/util/ext/tempita/__init__.py",
line 135, in from_filename
    f = open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory:
'/usr/lib/python3/dist-packages/mapproxy/service/templates/demo/demo.html'
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/mapproxy/wsgiapp.py", line 193, in
__call__
    resp = self.handlers[handler_name].handle(req)
  File "/usr/lib/python3/dist-packages/mapproxy/service/demo.py", line 121,
in handle
    demo = self._render_template('demo/demo.html')
  File "/usr/lib/python3/dist-packages/mapproxy/service/demo.py", line 161,
in _render_template
    template = get_template(template, default_inherit="demo/static.html")
  File "/usr/lib/python3/dist-packages/mapproxy/template.py", line 36, in
__call__
    default_inherit=default_inherit, get_template=self)
  File
"/usr/lib/python3/dist-packages/mapproxy/util/ext/tempita/__init__.py",
line 135, in from_filename
    f = open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory:
'/usr/lib/python3/dist-packages/mapproxy/service/templates/demo/demo.html'


> Do you have custom templates?
>

No


> The directories moved to /usr/share/python3-mapproxy are symlinked fro
> /usr/lib/python3/dist-packages/mapproxy:
>
>   lrwxrwxrwx root/root         0 2019-08-06 13:00
> ./usr/lib/python3/dist-packages/mapproxy/service/templates ->
> ../../../../../share/python3-mapproxy/service/templates
>   lrwxrwxrwx root/root         0 2019-08-06 13:00
> ./usr/lib/python3/dist-packages/mapproxy/test/schemas ->
> ../../../../../share/python3-mapproxy/test/schemas
>   lrwxrwxrwx root/root         0 2019-08-06 13:00
> ./usr/lib/python3/dist-packages/mapproxy/test/system/fixture/cache_data
> ->
> ../../../../../../../share/python3-mapproxy/test/system/fixture/cache_data
>
> As long as custom templates are installed in
> /usr/share/python3-mapproxy/service/templates they should work.
>

Do not have symlink in my case. Symlink can fix the issue as well.


> How can I reproduce your issue with with templates?
>

On Debian Buster install package python3-mapproxy, configure services and
start it. It will not work, as on Debian Buster (at least in my case) there
is no symlink to templates in dist-packages.


> > 2. Upstream code is not compatible with Python 3.7
> >
> > Tempia does not correctly parses function signature with recent Python
> > versions. Likely introduced with changes in Python tokenizer package
> > with 3.6.7. Use keyword args as workaround.
> >
> > This is already known bug in upstream:
> >
> https://github.com/mapproxy/mapproxy/commit/81c84d47bbc77da324c36ca718fbca7dde1c1c66
> >
> > How to fix:
> > Patch according to commit
> >
> https://github.com/mapproxy/mapproxy/commit/81c84d47bbc77da324c36ca718fbca7dde1c1c66
>
> We can cherry-pick this commit and include it as a patch, as a new
> mapproxy releases will likely take some time.
>
> How can I reproduce the issue you experience with Python 3.7?
>

Just install python3-mapproxy package, configure mapproxy and request for
XML capabilities. It will result in error:

TypeError: Extra position arguments: True at line 169 column 3 in file
/usr/share/python3-mapproxy/service/templates/wms111capabilities.xml
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/mapproxy/wsgiapp.py", line 193, in
__call__
    resp = self.handlers[handler_name].handle(req)
  File "/usr/lib/python3/dist-packages/mapproxy/service/ows.py", line 38,
in handle
    return self.services[service].handle(req)
  File "/usr/lib/python3/dist-packages/mapproxy/service/base.py", line 30,
in handle
    return handler(parsed_req)
  File "/usr/lib/python3/dist-packages/mapproxy/service/wms.py", line 196,
in capabilities
    ).render(map_request)
  File "/usr/lib/python3/dist-packages/mapproxy/service/wms.py", line 516,
in render
    return self._render_template(_map_request.capabilities_template)
  File "/usr/lib/python3/dist-packages/mapproxy/service/wms.py", line 531,
in _render_template
    inspire_md=inspire_md,
  File
"/usr/lib/python3/dist-packages/mapproxy/util/ext/tempita/__init__.py",
line 167, in substitute
    result, defs, inherit = self._interpret(ns)
  File
"/usr/lib/python3/dist-packages/mapproxy/util/ext/tempita/__init__.py",
line 178, in _interpret
    self._interpret_codes(self._parsed, ns, out=parts, defs=defs)
  File
"/usr/lib/python3/dist-packages/mapproxy/util/ext/tempita/__init__.py",
line 206, in _interpret_codes
    self._interpret_code(item, ns, out, defs)
  File
"/usr/lib/python3/dist-packages/mapproxy/util/ext/tempita/__init__.py",
line 226, in _interpret_code
    base = self._eval(parts[0], ns, pos)
  File
"/usr/lib/python3/dist-packages/mapproxy/util/ext/tempita/__init__.py",
line 301, in _eval
    reraise((exc_info[0], e, exc_info[2]))
  File "/usr/lib/python3/dist-packages/mapproxy/util/py.py", line 40, in
reraise
    raise exc.with_traceback(tb)
  File
"/usr/lib/python3/dist-packages/mapproxy/util/ext/tempita/__init__.py",
line 288, in _eval
    value = eval(code, self.default_namespace, ns)
  File "<string>", line 1, in <module>
  File
"/usr/lib/python3/dist-packages/mapproxy/util/ext/tempita/__init__.py",
line 519, in __call__
    values = self._parse_signature(args, kw)
  File
"/usr/lib/python3/dist-packages/mapproxy/util/ext/tempita/__init__.py",
line 562, in _parse_signature
    % ', '.join(repr(v) for v in args))
TypeError: Extra position arguments: True at line 169 column 3 in file
/usr/share/python3-mapproxy/service/templates/wms111capabilities.xml

Do you need to prepare sample configuration for you? I can do simple copy
of my configuration with for example single layer/service.

Regards,

Marek


> Kind Regards,
>
> Bas
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20190827/e98b4c27/attachment-0001.html>


More information about the Pkg-grass-devel mailing list