mirror of
https://github.com/evennia/evennia.git
synced 2026-04-03 06:27:17 +02:00
Fix batchprocessor IOError. Resolve #1814.
This commit is contained in:
parent
e3af3f148b
commit
ea93431bd5
2 changed files with 26 additions and 10 deletions
|
|
@ -260,9 +260,13 @@ class CmdBatchCommands(_COMMAND_DEFAULT_CLASS):
|
|||
caller.msg(_UTF8_ERROR % (python_path, err))
|
||||
return
|
||||
except IOError as err:
|
||||
string = "'%s' not found.\nYou have to supply the python path\n" \
|
||||
"using one of the defined batch-file directories\n (%s)."
|
||||
caller.msg(string % (python_path, ", ".join(settings.BASE_BATCHPROCESS_PATHS)))
|
||||
if err:
|
||||
err = "{}\n".format(str(err))
|
||||
else:
|
||||
err = ""
|
||||
string = "%s'%s' could not load. You have to supply python paths " \
|
||||
"from one of the defined batch-file directories\n (%s)."
|
||||
caller.msg(string % (err, python_path, ", ".join(settings.BASE_BATCHPROCESS_PATHS)))
|
||||
return
|
||||
if not commands:
|
||||
caller.msg("File %s seems empty of valid commands." % python_path)
|
||||
|
|
@ -288,7 +292,8 @@ class CmdBatchCommands(_COMMAND_DEFAULT_CLASS):
|
|||
caller.msg("\nBatch-command processor - Interactive mode for %s ..." % python_path)
|
||||
show_curr(caller)
|
||||
else:
|
||||
caller.msg("Running Batch-command processor - Automatic mode for %s (this might take some time) ..."
|
||||
caller.msg("Running Batch-command processor - Automatic mode "
|
||||
"for %s (this might take some time) ..."
|
||||
% python_path)
|
||||
|
||||
procpool = False
|
||||
|
|
@ -370,10 +375,14 @@ class CmdBatchCode(_COMMAND_DEFAULT_CLASS):
|
|||
except UnicodeDecodeError as err:
|
||||
caller.msg(_UTF8_ERROR % (python_path, err))
|
||||
return
|
||||
except IOError:
|
||||
string = "'%s' not found.\nYou have to supply the python path\n" \
|
||||
except IOError as err:
|
||||
if err:
|
||||
err = "{}\n".format(str(err))
|
||||
else:
|
||||
err = ""
|
||||
string = "%s'%s' could not load. You have to supply python paths " \
|
||||
"from one of the defined batch-file directories\n (%s)."
|
||||
caller.msg(string % (python_path, ", ".join(settings.BASE_BATCHPROCESS_PATHS)))
|
||||
caller.msg(string % (err, python_path, ", ".join(settings.BASE_BATCHPROCESS_PATHS)))
|
||||
return
|
||||
if not codes:
|
||||
caller.msg("File %s seems empty of functional code." % python_path)
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ def read_batchfile(pythonpath, file_ending='.py'):
|
|||
# find all possible absolute paths
|
||||
abspaths = utils.pypath_to_realpath(pythonpath, file_ending, settings.BASE_BATCHPROCESS_PATHS)
|
||||
if not abspaths:
|
||||
raise IOError
|
||||
raise IOError("Absolute batchcmd paths could not be found.")
|
||||
text = None
|
||||
decoderr = []
|
||||
for abspath in abspaths:
|
||||
|
|
@ -273,7 +273,11 @@ class BatchCommandProcessor(object):
|
|||
|
||||
def replace_insert(match):
|
||||
"""Map replace entries"""
|
||||
return "\n#\n".join(self.parse_file(match.group(1)))
|
||||
try:
|
||||
path = match.group(1)
|
||||
return "\n#\n".join(self.parse_file(path))
|
||||
except IOError as err:
|
||||
raise IOError("#INSERT {} failed.".format(path))
|
||||
|
||||
text = _RE_INSERT.sub(replace_insert, text)
|
||||
commands = _RE_CMD_SPLIT.split(text)
|
||||
|
|
@ -339,7 +343,10 @@ class BatchCodeProcessor(object):
|
|||
def replace_insert(match):
|
||||
"""Run parse_file on the import before sub:ing it into this file"""
|
||||
path = match.group(1)
|
||||
return "# batchcode insert (%s):" % path + "\n".join(self.parse_file(path))
|
||||
try:
|
||||
return "# batchcode insert (%s):" % path + "\n".join(self.parse_file(path))
|
||||
except IOError as err:
|
||||
raise IOError("#INSERT {} failed.".format(path))
|
||||
|
||||
# process and then insert code from all #INSERTS
|
||||
text = _RE_INSERT.sub(replace_insert, text)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue