You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have seen a lot of errors in the past few months due to "bad" SVG files which caused errors deep during our media management commands/tasks. For instance on executing the admin sync_mobile command:
IsADirectoryError: [Errno 21] Is a directory: '/opt/geotrek-admin'
File "urllib/request.py", line 1526, in open_local_file
return addinfourl(open(localfile, 'rb'), headers, origurl)
URLError: <urlopen error [Errno 21] Is a directory: '/opt/geotrek-admin'>
File "manage.py", line 20, in <module>
execute_from_command_line(sys.argv)
File "django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "geotrek/api/management/commands/sync_mobile.py", line 519, in handle
self.sync()
File "geotrek/api/management/commands/sync_mobile.py", line 431, in sync
self.sync_medias()
File "geotrek/api/management/commands/sync_mobile.py", line 284, in sync_medias
self.sync_global_media()
File "geotrek/api/management/commands/sync_mobile.py", line 359, in sync_global_media
self.sync_pictograms(trekking_models.Practice, directory=url_media_nolang, zipfile=self.zipfile_settings,
File "geotrek/api/management/commands/sync_mobile.py", line 193, in sync_pictograms
cairosvg.svg2png(url=obj.pictogram.path, write_to=dst)
File "__init__.py", line 55, in svg2png
return surface.PNGSurface.convert(
File "cairosvg/surface.py", line 131, in convert
instance = cls(
File "cairosvg/surface.py", line 223, in __init__
self.draw(tree)
File "cairosvg/surface.py", line 469, in draw
self.draw(child)
File "cairosvg/surface.py", line 469, in draw
self.draw(child)
File "cairosvg/surface.py", line 469, in draw
self.draw(child)
File "cairosvg/surface.py", line 401, in draw
TAGS[node.tag](self, node)
File "cairosvg/image.py", line 28, in image
image_bytes = node.fetch_url(url, 'image/*')
File "cairosvg/parser.py", line 243, in fetch_url
return read_url(url, self.url_fetcher, resource_type)
File "cairosvg/url.py", line 143, in read_url
return url_fetcher(url, resource_type)
File "cairosvg/url.py", line 84, in fetch
return urlopen(Request(url, headers=HTTP_HEADERS)).read()
File "urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "urllib/request.py", line 525, in open
response = self._open(req, data)
File "urllib/request.py", line 542, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "urllib/request.py", line 502, in _call_chain
result = func(*args)
File "urllib/request.py", line 1489, in file_open
return self.open_local_file(req)
File "urllib/request.py", line 1528, in open_local_file
raise URLError(exp)
Here it failed at cairosvg.svg2png(url=obj.pictogram.path, write_to=dst) because cairosvg tries to reach for an external resource defined in the svg file. For instance it could be an image like so:
This trouble goes unnoticed at first because SVG editor/viewer applications may silently ignore this kind of missing resource issue.
It would be good to check SVG files at updload time for compatibility with Geotrek usages. It would save time for everyone, users and admin staff. We could warn the user that the svg file is invalid or try to auto-correct it.
The text was updated successfully, but these errors were encountered:
We have seen a lot of errors in the past few months due to "bad" SVG files which caused errors deep during our media management commands/tasks. For instance on executing the admin
sync_mobile
command:Here it failed at
cairosvg.svg2png(url=obj.pictogram.path, write_to=dst)
becausecairosvg
tries to reach for an external resource defined in the svg file. For instance it could be an image like so:This trouble goes unnoticed at first because SVG editor/viewer applications may silently ignore this kind of missing resource issue.
It would be good to check SVG files at updload time for compatibility with Geotrek usages. It would save time for everyone, users and admin staff. We could warn the user that the svg file is invalid or try to auto-correct it.
The text was updated successfully, but these errors were encountered: