Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions optimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import collections
import contextlib
import logging
import multiprocessing.pool
import os
import os.path
import shutil
Expand Down Expand Up @@ -173,9 +174,15 @@ def _compress_with(input_filename, output_filename, compressors):
input.
"""
with _temporary_filenames(len(compressors)) as temp_filenames:
results = []
for compressor, temp_filename in zip(compressors, temp_filenames):
results.append(_process(compressor, input_filename, temp_filename))
process_args = [
(compressor, input_filename, temp_filename)
for compressor, temp_filename in zip(compressors, temp_filenames)
]
process_unpack = lambda args: _process(*args)
results = multiprocessing.pool.ThreadPool().map(process_unpack,
process_args,
chunksize=1)

best_result = min(results)
os.rename(best_result.filename, output_filename)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
scripts=['scripts/optimage'],
setup_requires=['pytest-runner'],
install_requires=['Pillow'],
tests_require=['pytest', 'pytest-cov', 'pytest-catchlog'],
tests_require=['pytest>=3.3', 'pytest-cov'],
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Console',
Expand Down
7 changes: 0 additions & 7 deletions test_optimage_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
import subprocess

import pytest
try:
import pytest_catchlog
catchlog_available = True
except ImportError:
catchlog_available = False

import optimage

Expand Down Expand Up @@ -147,8 +142,6 @@ def mock_check_output(args, stderr=None):
assert 'Output:\ncustom error' in err


@pytest.mark.skipif(not catchlog_available,
reason='pytest_catchlog not available')
@pytest.mark.parametrize('filename, compressor', [
# Do not specify compressor as it depends on the version of the commands
# installed. In Mac I get that pngcrush is better than zopflipng, but not in
Expand Down