mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-10 07:18:39 +00:00
Merge pull request #15 from elias-pschernig/master
[wmlunits] Fix error logging.
This commit is contained in:
commit
cdb68d0c8a
@ -106,6 +106,8 @@ def main(folder):
|
||||
error_kind = "wml error"
|
||||
elif "<PARSE ERROR>" in text:
|
||||
error_kind = "parse error"
|
||||
elif "<TIMEOUT ERROR>" in text:
|
||||
error_kind = "timeout"
|
||||
|
||||
source = []
|
||||
|
||||
@ -144,9 +146,9 @@ def main(folder):
|
||||
lines_count = 0
|
||||
for line in text.splitlines():
|
||||
line = line.strip()
|
||||
if line in ["<INTERNAL ERROR>", "<WML ERROR>", "<PARSE ERROR>"]:
|
||||
if line in ["<INTERNAL ERROR>", "<WML ERROR>", "<PARSE ERROR>", "<TIMEOUT ERROR>"]:
|
||||
htmlerr.write("<p>")
|
||||
elif line in ["</INTERNAL ERROR>", "</WML ERROR>", "</PARSE ERROR>"]:
|
||||
elif line in ["</INTERNAL ERROR>", "</WML ERROR>", "</PARSE ERROR>", "</TIMEOUT ERROR>"]:
|
||||
htmlerr.write("</p>")
|
||||
else:
|
||||
err_html = postprocess(line)
|
||||
|
@ -21,11 +21,12 @@ class WMLError(Exception):
|
||||
Catch this exception to retrieve the first error message from
|
||||
the parser.
|
||||
"""
|
||||
def __init__(self, parser, message):
|
||||
self.line = parser.parser_line
|
||||
self.wml_line = parser.last_wml_line
|
||||
self.message = message
|
||||
self.preprocessed = parser.preprocessed
|
||||
def __init__(self, parser = None, message = None):
|
||||
if parser:
|
||||
self.line = parser.parser_line
|
||||
self.wml_line = parser.last_wml_line
|
||||
self.message = message
|
||||
self.preprocessed = parser.preprocessed
|
||||
|
||||
def __str__(self):
|
||||
r = "WMLError:\n"
|
||||
|
@ -21,6 +21,8 @@ import unit_tree.html_output as html_output
|
||||
import unit_tree.overview
|
||||
import unit_tree.wiki_output as wiki_output
|
||||
|
||||
TIMEOUT = 5
|
||||
|
||||
def copy_images():
|
||||
print("Recolorizing pictures.")
|
||||
image_collector.copy_and_color_images(options.output)
|
||||
@ -130,19 +132,24 @@ def list_contents():
|
||||
options.data_dir,
|
||||
options.transdir)
|
||||
#print("remote", local.wesnoth)
|
||||
local.wesnoth.parser.parse_text(wml, defines)
|
||||
q.put(local.wesnoth)
|
||||
|
||||
try:
|
||||
local.wesnoth.parser.parse_text(wml, defines)
|
||||
q.put(("ok", local.wesnoth))
|
||||
except Exception as e:
|
||||
q.put(("e", e))
|
||||
|
||||
q = multiprocessing.Queue()
|
||||
p = multiprocessing.Process(target = f, args = (options, wml, defines, q))
|
||||
p.start()
|
||||
try:
|
||||
local.wesnoth = q.get(timeout = 5)
|
||||
s, local.wesnoth = q.get(timeout = TIMEOUT)
|
||||
except Queue.Empty:
|
||||
p.terminate()
|
||||
raise
|
||||
#print("local", local.wesnoth)
|
||||
#print("local", s, local.wesnoth)
|
||||
p.join()
|
||||
if s == "e":
|
||||
raise local.wesnoth
|
||||
|
||||
def get_version(addon):
|
||||
try:
|
||||
@ -222,9 +229,9 @@ def list_contents():
|
||||
sys.stdout.write("failed\n")
|
||||
except Queue.Empty as e:
|
||||
ef = open(logname, "w")
|
||||
ef.write("<PARSE ERROR>\n")
|
||||
ef.write(str(e))
|
||||
ef.write("</PARSE ERROR>\n")
|
||||
ef.write("<TIMEOUT ERROR>\n")
|
||||
ef.write("Failed to parse the WML within " + str(TIMEOUT) + " seconds.")
|
||||
ef.write("</TIMEOUT ERROR>\n")
|
||||
ef.close()
|
||||
sys.stdout.write("failed\n")
|
||||
finally:
|
||||
|
Loading…
x
Reference in New Issue
Block a user