Delegated export stderr output without exit code zero to warnings and fixed one crash during loading

Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
This commit is contained in:
TheJackiMonster 2021-11-27 23:03:31 +01:00
parent 5355c26333
commit 08e8714f1d
No known key found for this signature in database
GPG key ID: D850A5F772E880F9
2 changed files with 23 additions and 14 deletions

View file

@ -99,12 +99,16 @@ class pandocExporter(basicExporter):
qApp.restoreOverrideCursor()
if stderr or p.returncode != 0:
err = "ERROR on export" + "\n" \
+ "Return code" + ": %d\n" % (p.returncode) \
+ "Command and parameters" + ":\n%s\n" % (p.args) \
+ "Stderr content" + ":\n" + stderr.decode("utf-8")
LOGGER.error(err)
QMessageBox.critical(mainWindow().dialog, qApp.translate("Export", "Error"), err)
err_type = "ERROR" if p.returncode != 0 else "WARNING"
err = "%s on export\n" % err_type \
+ "Return code: %d\n" % p.returncode \
+ "Command and parameters:\n%s\n" % p.args \
+ "Stderr content:\n" + stderr.decode("utf-8")
if p.returncode != 0:
LOGGER.error(err)
QMessageBox.critical(mainWindow().dialog, qApp.translate("Export", "Error"), err)
else:
LOGGER.warning(err)
return None
return stdout.decode("utf-8")

View file

@ -897,13 +897,13 @@ def addTextItems(mdl, odict, parent=None):
@param odict: OrderedDict
@return: nothing
"""
if parent == None:
if parent is None:
parent = mdl.rootItem
for k in odict:
# In case k is a folder:
if type(odict[k]) == OrderedDict and "folder.txt" in odict[k]:
if (type(odict[k]) == OrderedDict) and ("folder.txt" in odict[k]):
# Adds folder
LOGGER.debug("{}* Adds {} to {} (folder)".format(" " * parent.level(), k, parent.title()))
@ -913,13 +913,18 @@ def addTextItems(mdl, odict, parent=None):
# Read content
addTextItems(mdl, odict[k], parent=item)
# k is not a folder
elif type(odict[k]) == str and k != "folder.txt" and not ":lastPath" in k:
LOGGER.debug("{}* Adds {} to {} (file)".format(" " * parent.level(), k, parent.title()))
item = outlineFromMMD(odict[k], parent=parent)
item._lastPath = odict[k + ":lastPath"]
if (":lastPath" in k) or (k == "folder.txt"):
continue
elif not ":lastPath" in k and k != "folder.txt":
# k is not a folder
if type(odict[k]) == str:
try:
LOGGER.debug("{}* Adds {} to {} (file)".format(" " * parent.level(), k, parent.title()))
item = outlineFromMMD(odict[k], parent=parent)
item._lastPath = odict[k + ":lastPath"]
except KeyError:
LOGGER.error("Failed to add file " + str(k))
else:
LOGGER.debug("Strange things in file %s".format(k))