Skip to content

Commit dd39d80

Browse files
committed
Merge tag '0.25.3' into develop
2 parents 1e6ecd6 + 68ede65 commit dd39d80

File tree

6 files changed

+27
-5
lines changed

6 files changed

+27
-5
lines changed

CHANGELOG

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

5+
0.25.3 (2018-04-03)
6+
===================
7+
- Fix: Add a subprocess timeout to the unoconv exporter so MFR doesn't wait forever for a process
8+
that might not complete.
9+
- Feature: Add user-agent to tornado access logs to help identify spiders.
10+
511
0.25.2 (2018-03-29)
612
===================
713
- Fix: Release memory consumed during csv-rendering process and force a garbage-collect cycle to

mfr/extensions/unoconv/export.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ class UnoconvExporter(extension.BaseExporter):
1111

1212
def export(self):
1313
try:
14-
subprocess.check_call([
14+
subprocess.run([
1515
settings.UNOCONV_BIN,
1616
'-n',
1717
'-c', 'socket,host={},port={};urp;StarOffice.ComponentContext'.format(settings.ADDRESS, settings.PORT),
1818
'-f', self.format,
1919
'-o', self.output_file_path,
2020
'-vvv',
2121
self.source_file_path
22-
])
22+
], check=True, timeout=settings.UNOCONV_TIMEOUT)
2323
except subprocess.CalledProcessError as err:
2424
name, extension = os.path.splitext(os.path.split(self.source_file_path)[-1])
2525
raise exceptions.SubprocessError(

mfr/extensions/unoconv/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
config = settings.child('UNOCONV_EXTENSION_CONFIG')
77

88
UNOCONV_BIN = config.get('UNOCONV_BIN', '/usr/local/bin/unoconv')
9+
UNOCONV_TIMEOUT = int(config.get('UNOCONV_TIMEOUT', 60))
910

1011
ADDRESS = config.get('SERVER', os.environ.get('UNOCONV_PORT_2002_TCP_ADDR', '127.0.0.1'))
1112
PORT = config.get('PORT', os.environ.get('UNOCONV_PORT_2002_TCP_PORT', '2002'))

mfr/server/app.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import time
12
import signal
23
import asyncio
34
import logging
@@ -19,6 +20,7 @@
1920
from mfr.version import __version__
2021

2122
logger = logging.getLogger(__name__)
23+
access_logger = logging.getLogger('tornado.access')
2224

2325

2426
def sig_handler(sig, frame):
@@ -33,6 +35,16 @@ def stop_loop():
3335
io_loop.add_callback_from_signal(stop_loop)
3436

3537

38+
def almost_apache_style_log(handler):
39+
'''without status code and body length'''
40+
req = handler.request
41+
access_logger.info('%s - - [%s +0800] "%s %s %s" - - "%s" "%s"' %
42+
(req.remote_ip, time.strftime("%d/%b/%Y:%X"), req.method,
43+
req.uri,
44+
req.version, getattr(req, 'referer', '-'),
45+
req.headers['User-Agent']))
46+
47+
3648
def make_app(debug):
3749
app = tornado.web.Application(
3850
[
@@ -45,6 +57,7 @@ def make_app(debug):
4557
(r'/status', StatusHandler),
4658
],
4759
debug=debug,
60+
log_function=almost_apache_style_log,
4861
)
4962
app.sentry_client = AsyncSentryClient(settings.SENTRY_DSN, release=__version__)
5063
return app

mfr/server/handlers/core.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,10 @@ def log_exception(self, typ, value, tb):
203203
list(value.args))
204204
tornado.web.gen_log.warning(format, *args)
205205
else:
206-
tornado.web.app_log.error("Uncaught exception %s\n", self._request_summary(),
207-
exc_info=(typ, value, tb))
206+
tornado.web.app_log.error("[User-Agent: %s] Uncaught exception %s\n",
207+
self.request.headers.get('User-Agent', '*none found*'),
208+
self._request_summary(),
209+
exc_info=(typ, value, tb))
208210

209211
def on_finish(self):
210212
if self.request.method not in self.ALLOWED_METHODS:

mfr/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.25.2'
1+
__version__ = '0.25.3'

0 commit comments

Comments
 (0)