- 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)

This commit is contained in:
Marius Stanciu
2022-11-06 00:43:34 +02:00
committed by Marius
parent 6509089dc4
commit d1a4de676e
3 changed files with 17 additions and 2 deletions

View File

@@ -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)