From d1a4de676e2e6b701c8c5846cc3ad3b5886c2af1 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sun, 6 Nov 2022 00:43:34 +0200 Subject: [PATCH] - if PikePDF module is not available then show an error but run the app (currently, for Python 3.11 is the only module not available) --- CHANGELOG.md | 4 ++++ appPlugins/ToolPDF.py | 13 ++++++++++++- requirements.txt | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c052e976..10c0810f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ CHANGELOG for FlatCAM Evo beta ================================================= +6.11.2022 + +- if PikePDF module is not available then show an error but run the app (currently, for Python 3.11 is the only module not available) + 19.10.2022 - added a hack so the Gerber files from Allegro 17.2 (which do not follow the Gerber specifications) can be loaded diff --git a/appPlugins/ToolPDF.py b/appPlugins/ToolPDF.py index 4049ed40..b3f90c26 100644 --- a/appPlugins/ToolPDF.py +++ b/appPlugins/ToolPDF.py @@ -7,9 +7,15 @@ from appTool import * from appParsers.ParsePDF import PdfParser -from pikepdf import Pdf, parse_content_stream + from camlib import grace +HAS_PIKE_MODULE = True +try: + from pikepdf import Pdf, parse_content_stream +except ModuleNotFoundError: + HAS_PIKE_MODULE = False + fcTranslate.apply_language('strings') if '_' not in builtins.__dict__: _ = gettext.gettext @@ -96,6 +102,11 @@ class ToolPDF(AppTool): self.app.inform.emit('[ERROR_NOTCL] %s' % _("File no longer available.")) return + if HAS_PIKE_MODULE is False: + self.app.inform.emit('[ERROR_NOTCL] %s' % _("Failed.")) + self.app.log.error("PikePDF module is not available.") + return + short_name = filename.split('/')[-1].split('\\')[-1] self.parsing_promises.append(short_name) diff --git a/requirements.txt b/requirements.txt index c06ac446..09a17d32 100644 --- a/requirements.txt +++ b/requirements.txt @@ -40,7 +40,7 @@ pyopengl pyqt6>=6.1.0 freetype-py vispy>=0.9.0 -pyqtdarktheme +pyqtdarktheme=1.1.1 gdal rasterio