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() qApp.restoreOverrideCursor()
if stderr or p.returncode != 0: if stderr or p.returncode != 0:
err = "ERROR on export" + "\n" \ err_type = "ERROR" if p.returncode != 0 else "WARNING"
+ "Return code" + ": %d\n" % (p.returncode) \ err = "%s on export\n" % err_type \
+ "Command and parameters" + ":\n%s\n" % (p.args) \ + "Return code: %d\n" % p.returncode \
+ "Stderr content" + ":\n" + stderr.decode("utf-8") + "Command and parameters:\n%s\n" % p.args \
+ "Stderr content:\n" + stderr.decode("utf-8")
if p.returncode != 0:
LOGGER.error(err) LOGGER.error(err)
QMessageBox.critical(mainWindow().dialog, qApp.translate("Export", "Error"), err) QMessageBox.critical(mainWindow().dialog, qApp.translate("Export", "Error"), err)
else:
LOGGER.warning(err)
return None return None
return stdout.decode("utf-8") return stdout.decode("utf-8")

View file

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