Skip to content

Commit fdacfc3

Browse files
committed
Merge branch 'release/0.20.0'
2 parents 35e4c7d + 0c81857 commit fdacfc3

File tree

14 files changed

+88
-12
lines changed

14 files changed

+88
-12
lines changed

CHANGELOG

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22
ChangeLog
33
*********
44

5+
0.20.0 (2017-03-01)
6+
===================
7+
- The "(thanks, @johnetordoff!)" release
8+
- Feature: The tabular spreadsheet renderer now recognizes date fields as dates and will format
9+
them as such. (thanks, @johnetordoff!)
10+
- Feature: Don't even try to render tabular files larger than 100Mb. Neither the server nor the
11+
browser wants that. (thanks, @johnetordoff!)
12+
- Feature: Render a better error message when encountering a csv file with a single field larger
13+
than ~128kb. The underlying library can't handle that, so it's polite to let the user know.
14+
(thanks, @johnetordoff!)
15+
- Feature: MFR will now render .m4v files using the <video> tag. (thanks, @johnetordoff!)
16+
- Fix: Improve tooltip language on 3d object-renderer. (thanks, @johnetordoff!)
17+
- Code: Start depending on upstream xlrd instead of our own fork. (thanks, @johnetordoff!)
18+
519
0.19.1 (2017-02-21)
620
===================
721
- Fix: explicitly depend on IPython to fix ipynb rendering. nbconvert and nbformat have an

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ invoke test
8787
- Running `invoke install -d` with setuptools v31 or greater can break MFR. The symptom error message is: `"AttributeError: module 'mfr' has no attribute '__version__'".` If you encounter this, you will need to remove the file
8888
`mfr-nspkg.pth` from your virtualenv directory, run `pip install setuptools==30.4.0`, then re-run `invoke install -d`.
8989

90-
- The error `def create_default_context(purpose=ssl.Purpose.SERVER_AUTH, *, cafile=None, capath=None, cadata=None): SyntaxError: invalid syntax` can be fixed by restarting your virtual environment. The problem should not reoccur.
90+
- The error `def create_default_context(purpose=ssl.Purpose.SERVER_AUTH, *, cafile=None, capath=None, cadata=None): SyntaxError: invalid syntax` is caused by inadvertently running the wrong version of Python. This can be caused by hashing the alias `inv`. To fix this run the command `hash -d inv` then run `inv server`.
9191

9292
- `invoke $command` results in `'$command' did not receive all required positional arguments!`: this error message occurs when trying to run MFR v0.19.0+ with `invoke<0.13.0`. Run `pip install invoke==0.13.0`, then retry your command.
9393

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
# General information about the project.
4747
project = u'mfr'
48-
copyright = u'2017'
48+
copyright = u'2017, Center For Open Science'
4949

5050
# The version info for the project you're documenting, acts as replacement for
5151
# |version| and |release|, also used in various other places throughout the

docs/license.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Licence
1+
License
22
=======
33

44
.. include:: ../LICENSE

mfr/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = '0.19.1'
1+
__version__ = '0.20.0'
22
__import__('pkg_resources').declare_namespace(__name__)

mfr/core/exceptions.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,23 @@ def __init__(self, message, *args, metadata_url: str='', response: str='', **kwa
145145
'response': self.response
146146
}])
147147

148+
class TooBigToRenderError(ProviderError):
149+
"""If the user tries to render a file larger than a server specified maximum, throw a
150+
TooBigToRenderError.
151+
"""
152+
153+
__TYPE = 'too_big_to_render'
154+
155+
def __init__(self, message, *args, requested_size: int=None, maximum_size: int=None,
156+
code: int=400, **kwargs):
157+
super().__init__(message, *args, code=code, **kwargs)
158+
self.requested_size = requested_size
159+
self.maximum_size = maximum_size
160+
self.attr_stack.append([self.__TYPE, {
161+
'requested_size': self.requested_size,
162+
'maximum_size': self.maximum_size,
163+
}])
164+
148165

149166
class DriverManagerError(PluginError):
150167

mfr/core/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,10 @@ def make_renderer(name, metadata, file_path, url, assets_url, export_url):
9696
'export_url': export_url,
9797
}
9898
)
99+
100+
def sizeof_fmt(num, suffix='B'):
101+
for unit in ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z']:
102+
if abs(num) < 1000.0:
103+
return '%3.1f%s%s' % (num, unit, suffix)
104+
num /= 1000.0
105+
return '%.1f%s%s' % (num, 'Y', suffix)

mfr/extensions/jsc3d/templates/viewer.mako

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
<canvas id="mfrViewer" tabindex="-1"></canvas>
1111
<a style="position: absolute; top: 10px; right: 10px; cursor: pointer;"
1212
data-toggle="popover" data-trigger="hover" data-placement="left" data-html="true"
13-
data-content="Drag mouse to rotate<br>Drag mouse with ctrl pressed to pan<br>Drag mouse with shift pressed to zoom">
13+
data-content="<p><b> Rotate:</b> Click and drag</p>
14+
<p><b> Pan:</b> Ctrl + click and drag</p>
15+
<p><b> Zoom:</b> Shift + click and drag up/down</p>">
1416
<img src="${base}/images/question-circle.png">
1517
</a>
1618

mfr/extensions/tabular/libs/stdlib_tools.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import re
22
import csv
33

4-
from mfr.extensions.tabular.exceptions import EmptyTableError
4+
from mfr.extensions.tabular.exceptions import EmptyTableError, TabularRendererError
55
from mfr.extensions.tabular import utilities
66

77

@@ -36,7 +36,19 @@ def csv_stdlib(fp):
3636
'name': fieldname,
3737
'sortable': True,
3838
})
39-
rows = [row for row in reader]
39+
40+
try:
41+
rows = [row for row in reader]
42+
except csv.Error as e:
43+
if any("field larger than field limit" in errorMsg for errorMsg in e.args):
44+
raise TabularRendererError(
45+
'This file contains a field too large to render. '
46+
'Please download and view it locally.',
47+
code=400,
48+
extension='csv',
49+
) from e
50+
else:
51+
raise TabularRendererError('csv.Error: {}'.format(e), extension='csv') from e
4052

4153
if not columns and not rows:
4254
raise EmptyTableError('Table empty or corrupt.', extension='csv')

mfr/extensions/tabular/libs/xlrd_tools.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,16 @@ def xlsx_xlrd(fp):
3434
for index, value in enumerate(fields)
3535
]
3636

37-
data = [
38-
dict(zip(fields, sheet.row_values(row_index)))
39-
for row_index in range(1, sheet.nrows)
40-
]
37+
data = []
38+
for i in range(1, sheet.nrows):
39+
row = []
40+
for cell in sheet.row(i):
41+
if cell.ctype == xlrd.XL_CELL_DATE:
42+
value = xlrd.xldate.xldate_as_datetime(cell.value, wb.datemode).isoformat()
43+
else:
44+
value = cell.value
45+
row.append(value)
46+
data.append(dict(zip(fields, row)))
4147

4248
header = header_population(fields)
4349
sheets[sheet.name] = (header, data)

0 commit comments

Comments
 (0)