Update gh workflow and remove logging

pull/198/head
Vinayak Mehta 2021-07-04 19:21:50 +05:30
parent ff7260a228
commit 0c20cb0be8
No known key found for this signature in database
GPG Key ID: 2DE013537A15A9A4
4 changed files with 34 additions and 15 deletions

View File

@ -7,7 +7,28 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install camelot with dependencies
run: |
make install
- name: Test with pytest
run: |
make test
test_latest:
name: Test on ${{ matrix.os }} with Python 3.9
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.9]
steps:
- uses: actions/checkout@v2

View File

@ -1,11 +1,8 @@
# -*- coding: utf-8 -*-
import logging
from .poppler_backend import PopplerBackend
from .ghostscript_backend import GhostscriptBackend
logger = logging.getLogger("camelot")
backends = {"poppler": PopplerBackend, "ghostscript": GhostscriptBackend}
@ -23,9 +20,7 @@ class ImageConversionBackend(object):
converter = backends[self.backend]()
converter.convert(pdf_path, png_path)
except Exception as e:
logger.info(
f"Image conversion backend '{self.backend}' failed with '{str(e)}'"
)
import sys
if self.use_fallback:
for fallback in self.fallbacks:
@ -35,10 +30,13 @@ class ImageConversionBackend(object):
converter = backends[fallback]()
converter.convert(pdf_path, png_path)
except Exception as e:
logger.info(
f"Image conversion backend '{fallback}' failed with '{str(e)}'"
)
raise type(e)(
str(e) + f" with image conversion backend '{fallback}'"
).with_traceback(sys.exc_info()[2])
continue
else:
logger.info(f"Image conversion backend '{fallback}' succeeded")
break
else:
raise type(e)(
str(e) + f" with image conversion backend '{self.backend}'"
).with_traceback(sys.exc_info()[2])

View File

@ -36,7 +36,7 @@ def test_lattice_contour_plot_poppler():
@pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True)
def test_lattice_contour_plot_ghostscript():
filename = os.path.join(testdir, "foo.pdf")
tables = camelot.read_pdf(filename, backend=ImageConversionBackend('ghostscript'))
tables = camelot.read_pdf(filename, backend=ImageConversionBackend("ghostscript"))
return camelot.plot(tables[0], kind="contour")
@ -57,7 +57,7 @@ def test_line_plot_poppler():
@pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True)
def test_line_plot_ghostscript():
filename = os.path.join(testdir, "foo.pdf")
tables = camelot.read_pdf(filename, backend=ImageConversionBackend('ghostscript'))
tables = camelot.read_pdf(filename, backend=ImageConversionBackend("ghostscript"))
return camelot.plot(tables[0], kind="line")
@ -71,7 +71,7 @@ def test_joint_plot_poppler():
@pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True)
def test_joint_plot_ghostscript():
filename = os.path.join(testdir, "foo.pdf")
tables = camelot.read_pdf(filename, backend=ImageConversionBackend('ghostscript'))
tables = camelot.read_pdf(filename, backend=ImageConversionBackend("ghostscript"))
return camelot.plot(tables[0], kind="joint")
@ -85,5 +85,5 @@ def test_grid_plot_poppler():
@pytest.mark.mpl_image_compare(baseline_dir="files/baseline_plots", remove_text=True)
def test_grid_plot_ghostscript():
filename = os.path.join(testdir, "foo.pdf")
tables = camelot.read_pdf(filename, backend=ImageConversionBackend('ghostscript'))
tables = camelot.read_pdf(filename, backend=ImageConversionBackend("ghostscript"))
return camelot.plot(tables[0], kind="grid")