Skip to content

Commit 91e0944

Browse files
committed
Merge branch 'release/0.25.0'
2 parents 1ef0bdc + d5fa891 commit 91e0944

32 files changed

+667
-68
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ before_install:
1515

1616
install:
1717
- travis_retry pip install --upgrade pip
18-
- travis_retry pip install setuptools==30.4.0
18+
- travis_retry pip install setuptools==37.0.0
1919
- travis_retry pip install wheel==0.26.0
2020
- travis_retry pip install invoke==0.13.0
2121
- travis_retry invoke wheelhouse --develop

CHANGELOG

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

5+
0.25.0 (2018-03-28)
6+
===================
7+
- Feature: Large files can now be zoomed! Images are scaled to fit the window, but clicking on the
8+
image will show a higher-resolution version. The mousewheel or two-finger drag will zoom in up to
9+
the maximum image size of 2400x2400px (increased from 1200x1200px). The zoomed image can be panned
10+
around the display port by moving the mouse.
11+
- Feature: Refuse to render tabular files (.xls, .xlsx, .csv) larger than 10Mb. Rendering these
12+
files consumes a lot of memory and can crash MFR.
13+
- Feature: Cached files now have the renderer that generated them appended to their names. This
14+
allows DevOps to do more targeted cache-cleaning after a feature release.
15+
- Fix: Make Libreoffice download mirror url configurable in the Dockerfile. The current mirror
16+
was having difficulty serving requests for awhile. This makes it easier to switch mirrors during
17+
times of trouble. The official mirror is working again, and MFR will continue to use that.
18+
- Code: Update MFR to support setuptools versions greater than v30.4.0. MFR's `__version__`
19+
declaration has moved from `mfr.__init__` to `mfr.version`. (thanks, @johnetordoff!)
20+
521
0.24.2 (2018-02-09)
622
===================
723
- Fix: Update UNOCONV_BIN setting to reflect the default pip install path.

Dockerfile

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,18 @@ RUN usermod -d /home www-data \
4343
curl \
4444
&& rm -rf /var/lib/apt/lists/* \
4545
&& pip install -U pip \
46-
&& pip uninstall -y setuptools \
47-
&& rm -f /usr/local/lib/python3.5/site-packages/mfr-nspkg.pth \
48-
&& pip install setuptools==30.4.0 \
46+
&& pip install setuptools==37.0.0 \
4947
&& mkdir -p /code
5048

51-
ENV LIBREOFFICE_VERSION 6.0.1.1
52-
ENV LIBREOFFICE_ARCHIVE LibreOffice_6.0.1.1_Linux_x86-64_deb.tar.gz
49+
ENV LIBREOFFICE_VERSION 6.0.2.1
50+
ENV LIBREOFFICE_ARCHIVE LibreOffice_6.0.2.1_Linux_x86-64_deb.tar.gz
51+
ENV LIBREOFFICE_MIRROR_URL https://downloadarchive.documentfoundation.org/libreoffice/old/
5352
RUN apt-get update \
5453
&& apt-get install -y \
5554
curl \
5655
&& gpg --keyserver pool.sks-keyservers.net --recv-keys AFEEAEA3 \
57-
&& curl -SL "https://downloadarchive.documentfoundation.org/libreoffice/old/$LIBREOFFICE_VERSION/deb/x86_64/$LIBREOFFICE_ARCHIVE" -o $LIBREOFFICE_ARCHIVE \
58-
&& curl -SL "https://downloadarchive.documentfoundation.org/libreoffice/old/$LIBREOFFICE_VERSION/deb/x86_64/$LIBREOFFICE_ARCHIVE.asc" -o $LIBREOFFICE_ARCHIVE.asc \
56+
&& curl -SL "$LIBREOFFICE_MIRROR_URL/$LIBREOFFICE_VERSION/deb/x86_64/$LIBREOFFICE_ARCHIVE" -o $LIBREOFFICE_ARCHIVE \
57+
&& curl -SL "$LIBREOFFICE_MIRROR_URL/$LIBREOFFICE_VERSION/deb/x86_64/$LIBREOFFICE_ARCHIVE.asc" -o $LIBREOFFICE_ARCHIVE.asc \
5958
&& gpg --verify "$LIBREOFFICE_ARCHIVE.asc" \
6059
&& mkdir /tmp/libreoffice \
6160
&& tar -xvf "$LIBREOFFICE_ARCHIVE" -C /tmp/libreoffice/ --strip-components=1 \

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ After installing python3.5, create the virtual environment with the following co
4141
pip install virtualenv
4242
pip install virtualenvwrapper
4343
mkvirtualenv --python=`which python3.5` mfr
44-
pip install setuptools==30.4.0
44+
45+
pip install setuptools==37.0.0
4546
pip install invoke==0.13.0
47+
4648
invoke install
4749
invoke server
4850
```
@@ -86,8 +88,7 @@ invoke test
8688

8789
### Known issues
8890

89-
- 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
90-
`mfr-nspkg.pth` from your virtualenv directory, run `pip install setuptools==30.4.0`, then re-run `invoke install -d`.
91+
- **Updated, 2018-03-01:** *MFR has been updated to work with setuptools==37.0.0 as of MFR release v0.25. The following issue should not happen for new installs, but may occur if you downgrade to an older version.* 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 `mfr-nspkg.pth` from your virtualenv directory, run `pip install setuptools==30.4.0`, then re-run `invoke install -d`.
9192

9293
- 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`.
9394

@@ -99,7 +100,7 @@ Interested in adding support for a new provider or file format? Check out the CO
99100

100101
### License
101102

102-
Copyright 2013-2017 Center for Open Science
103+
Copyright 2013-2018 Center for Open Science
103104

104105
Licensed under the Apache License, Version 2.0 (the "License");
105106
you may not use this file except in compliance with the License.

dev-requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
-r requirements.txt
22

3-
-e git+https://github.com/centerforopenscience/aiohttpretty.git@0.0.2#egg=aiohttpretty
3+
# aiohttpretty disabled due to no usage in MFR, re-enable when needed
4+
# git+https://github.com/centerforopenscience/aiohttpretty.git@0.1.0#egg=aiohttpretty
5+
46
beautifulsoup4
57
colorlog==2.5.0
68
flake8==3.0.4

docs/conf.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# mfr documentation build configuration file.
3+
# MFR documentation build configuration file.
44
#
5-
# This file is execfile()d with the current directory set to its containing dir.
5+
# This file is generated by execfile() with the current directory set to its
6+
# containing dir.
67
#
7-
# Note that not all possible configuration values are present in this
8-
# autogenerated file.
8+
# Note that not all possible configuration values are present in this auto-
9+
# generated file.
910
#
1011
# All configuration values have a default; values that are commented out
1112
# serve to show the default.
1213

1314
import sys
1415
import os
1516

17+
from mfr.version import __version__
18+
1619
# If extensions (or modules to document with autodoc) are in another directory,
1720
# add these directories to sys.path here. If the directory is relative to the
1821
# documentation root, use os.path.abspath to make it absolute, like shown here.
1922
sys.path.insert(0, os.path.abspath('..'))
20-
import mfr # noqa
2123
sys.path.append(os.path.abspath("_themes"))
2224

2325
# -- General configuration -----------------------------------------------------
@@ -45,14 +47,14 @@
4547

4648
# General information about the project.
4749
project = u'mfr'
48-
copyright = u'2017, Center For Open Science'
50+
copyright = u'2018, Center For Open Science'
4951

5052
# The version info for the project you're documenting, acts as replacement for
5153
# |version| and |release|, also used in various other places throughout the
5254
# built documents.
5355
#
5456
# The short X.Y version.
55-
version = release = mfr.__version__
57+
version = release = __version__
5658

5759
# The language for content autogenerated by Sphinx. Refer to documentation
5860
# for a list of supported languages.

docs/install.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Install the versions of ``setuptools`` and ``invoke`` found in the requirements.
2020

2121
.. code-block:: bash
2222
23-
pip install setuptools==30.4.0
23+
pip install setuptools==37.0.0
2424
pip install invoke==0.13.0
2525
2626
Install requirements:

mfr/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
__version__ = '0.24.2'
1+
# This is a namespace package, don't put any functional code in here besides the
2+
# declare_namespace call, or it will disappear on install. See:
3+
# https://setuptools.readthedocs.io/en/latest/setuptools.html#namespace-packages
24
__import__('pkg_resources').declare_namespace(__name__)

mfr/core/remote_logging.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
import logging
44

55
import aiohttp
6-
# from geoip import geolite2
76

8-
import mfr
97
from mfr.server import settings
10-
11-
# import waterbutler
8+
from mfr.version import __version__
129
from waterbutler.core.utils import async_retry
1310

1411

@@ -22,8 +19,7 @@ async def log_analytics(request, metrics, is_error=False):
2219

2320
keen_payload = copy.deepcopy(metrics)
2421
keen_payload['meta'] = {
25-
'mfr_version': mfr.__version__,
26-
# 'wb_version': waterbutler.__version__,
22+
'mfr_version': __version__,
2723
'epoch': 1,
2824
}
2925
keen_payload.update(request)

mfr/core/utils.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pkg_resources
12
from stevedore import driver
23

34
from mfr.core import exceptions
@@ -97,6 +98,48 @@ def make_renderer(name, metadata, file_path, url, assets_url, export_url):
9798
}
9899
)
99100

101+
102+
def get_renderer_name(name: str) -> str:
103+
""" Return the name of the renderer used for a certain file extension.
104+
105+
:param str name: The name of the extension to get the renderer name for. (.jpg, .docx, etc)
106+
107+
:rtype : `str`
108+
"""
109+
110+
# `ep_iterator` is an iterable object. Must convert it to a `list` for access.
111+
# `list()` can only be called once because the iterator moves to the end after conversion.
112+
ep_iterator = pkg_resources.iter_entry_points(group='mfr.renderers', name=name.lower())
113+
ep_list = list(ep_iterator)
114+
115+
# Empty list indicates unsupported file type.
116+
# Return a blank string and let `make_renderer()` handle it.
117+
if len(ep_list) == 0:
118+
return ''
119+
120+
# If file type is supported, there must be only one element in the list.
121+
assert len(ep_list) == 1
122+
return ep_list[0].attrs[0]
123+
124+
125+
def get_exporter_name(name: str) -> str:
126+
""" Return the name of the exporter used for a certain file extension.
127+
128+
:param str name: The name of the extension to get the exporter name for. (.jpg, .docx, etc)
129+
130+
:rtype : `str`
131+
"""
132+
133+
# `ep_iterator` is an iterable object. Must convert it to a `list` for access.
134+
# `list()` can only be called once because the iterator moves to the end after conversion.
135+
ep_iterator = pkg_resources.iter_entry_points(group='mfr.exporters', name=name.lower())
136+
ep_list = list(ep_iterator)
137+
138+
# `make_renderer()` is called before `make_exporter()` to ensure the file type is supported
139+
assert len(ep_list) == 1
140+
return ep_list[0].attrs[0]
141+
142+
100143
def sizeof_fmt(num, suffix='B'):
101144
if abs(num) < 1000:
102145
return '%3.0f%s' % (num, suffix)

0 commit comments

Comments
 (0)