Skip to content

Commit

Permalink
Merge tag '0.25.4' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
felliott committed Apr 6, 2018
2 parents dd39d80 + 2ecc620 commit a9a381c
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
ChangeLog
*********

0.25.4 (2018-04-06)
===================
- Fix: When no exporter exists for the given extension, throw the "No supported exporter" error,
instead of the non-specific "Please try again later" error. This fixes a regression introduced
in v0.25.0.

0.25.3 (2018-04-03)
===================
- Fix: Add a subprocess timeout to the unoconv exporter so MFR doesn't wait forever for a process
Expand Down
11 changes: 7 additions & 4 deletions mfr/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,11 @@ def get_renderer_name(name: str) -> str:
ep_iterator = pkg_resources.iter_entry_points(group='mfr.renderers', name=name.lower())
ep_list = list(ep_iterator)

# Empty list indicates unsupported file type.
# Return a blank string and let `make_renderer()` handle it.
# Empty list indicates unsupported file type. Return '' and let `make_renderer()` handle it.
if len(ep_list) == 0:
return ''

# If file type is supported, there must be only one element in the list.
# If the file type is supported, there must be only one element in the list.
assert len(ep_list) == 1
return ep_list[0].attrs[0]

Expand All @@ -135,7 +134,11 @@ def get_exporter_name(name: str) -> str:
ep_iterator = pkg_resources.iter_entry_points(group='mfr.exporters', name=name.lower())
ep_list = list(ep_iterator)

# `make_renderer()` is called before `make_exporter()` to ensure the file type is supported
# Empty list indicates unsupported export type. Return '' and let `make_exporter()` handle it.
if len(ep_list) == 0:
return ''

# If the export type is supported, there must be only one element in the list.
assert len(ep_list) == 1
return ep_list[0].attrs[0]

Expand Down
9 changes: 6 additions & 3 deletions mfr/server/handlers/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ async def prepare(self):

self.cache_file_id = '{}.{}'.format(self.metadata.unique_key, self.format)

self.cache_file_path = await self.cache_provider.validate_path(
'/export/{}.{}'.format(self.cache_file_id, self.exporter_name)
)
if self.exporter_name:
cache_file_path_str = '/export/{}.{}'.format(self.cache_file_id, self.exporter_name)
else:
cache_file_path_str = '/export/{}'.format(self.cache_file_id)
self.cache_file_path = await self.cache_provider.validate_path(cache_file_path_str)

self.source_file_path = await self.local_cache_provider.validate_path(
'/export/{}'.format(self.source_file_id)
)
Expand Down
10 changes: 7 additions & 3 deletions mfr/server/handlers/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ async def prepare(self):
self.renderer_name = utils.get_renderer_name(self.metadata.ext)

self.cache_file_id = self.metadata.unique_key
self.cache_file_path = await self.cache_provider.validate_path(
'/render/{}.{}'.format(self.cache_file_id, self.renderer_name)
)

if self.renderer_name:
cache_file_path_str = '/export/{}.{}'.format(self.cache_file_id, self.renderer_name)
else:
cache_file_path_str = '/export/{}'.format(self.cache_file_id)
self.cache_file_path = await self.cache_provider.validate_path(cache_file_path_str)

self.source_file_path = await self.local_cache_provider.validate_path(
'/render/{}'.format(self.source_file_id)
)
Expand Down
2 changes: 1 addition & 1 deletion mfr/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.25.3'
__version__ = '0.25.4'
5 changes: 2 additions & 3 deletions tests/core/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_get_renderer_name(self):
assert mfr_utils.get_renderer_name(ep.name) == expected

def test_get_renderer_name_no_entry_point(self):
assert mfr_utils.get_renderer_name('jpg') == ''
assert mfr_utils.get_renderer_name('jpg') == '' # extensions must begin with a period


class TestGetExporterName:
Expand All @@ -36,5 +36,4 @@ def test_get_exporter_name(self):
assert mfr_utils.get_exporter_name(ep.name) == expected

def test_get_exporter_name_no_entry_point(self):
with pytest.raises(AssertionError):
mfr_utils.get_exporter_name('jpg')
assert mfr_utils.get_exporter_name('jpg') == '' # extensions must begin with a period

0 comments on commit a9a381c

Please sign in to comment.