Fixed a bunch of small issues. The RedButton example hasn't been working for a while, should be ok again now - also cleaned it up a bit.
This commit is contained in:
parent
1d93d8295f
commit
334c0b1d08
10 changed files with 87 additions and 94 deletions
|
|
@ -163,29 +163,30 @@ def read_batchfile(pythonpath, file_ending='.py'):
|
|||
"""
|
||||
|
||||
# open the file
|
||||
|
||||
if pythonpath and not (pythonpath.startswith('src.') or
|
||||
pythonpath.startswith('game.')):
|
||||
pythonpath = "%s.%s" % (settings.BASE_BATCHPROCESS_PATH,
|
||||
pythonpath)
|
||||
abspath = utils.pypath_to_realpath(pythonpath, file_ending)
|
||||
|
||||
if pythonpath and not (pythonpath.startswith('src.') or pythonpath.startswith('game.')):
|
||||
abspaths = []
|
||||
for basepath in settings.BASE_BATCHPROCESS_PATHS:
|
||||
abspaths.append(utils.pypath_to_realpath("%s.%s" % (basepath, pythonpath), file_ending))
|
||||
else:
|
||||
abspaths = [pythonpath]
|
||||
fobj = None
|
||||
for file_encoding in ENCODINGS:
|
||||
# try different encodings, in order
|
||||
err = None
|
||||
try:
|
||||
# we read the file directly into unicode.
|
||||
fobj = codecs.open(abspath, 'r', encoding=file_encoding)
|
||||
except IOError:
|
||||
# try again without the appended file ending
|
||||
abspath2 = utils.pypath_to_realpath(pythonpath, None)
|
||||
try:
|
||||
load_errors = []
|
||||
for abspath in abspaths:
|
||||
# try different paths, until we get a match
|
||||
try:
|
||||
# we read the file directly into unicode.
|
||||
fobj = codecs.open(abspath, 'r', encoding=file_encoding)
|
||||
except IOError:
|
||||
string = "Could not open batchfile '%s', nor '%s'."
|
||||
logger.log_errmsg(string % (abspath2, abspath))
|
||||
return None
|
||||
|
||||
except IOError:
|
||||
load_errors.append("Could not open batchfile '%s'." % abspath)
|
||||
continue
|
||||
break
|
||||
if not fobj:
|
||||
continue
|
||||
|
||||
load_errors = []
|
||||
err =None
|
||||
# We have successfully found and opened the file. Now actually
|
||||
# try to decode it using the given protocol.
|
||||
try:
|
||||
|
|
@ -208,6 +209,8 @@ def read_batchfile(pythonpath, file_ending='.py'):
|
|||
continue
|
||||
# if we get here, the encoding worked. Stop iteration.
|
||||
break
|
||||
if load_errors:
|
||||
logger.log_errmsg("\n".join(load_errors))
|
||||
if err:
|
||||
return err
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -104,8 +104,8 @@ def reload_modules():
|
|||
if unsafe_dir_modified or unsafe_mod_modified:
|
||||
|
||||
if unsafe_mod_modified:
|
||||
string += "\n {rModules containing Script classes with a timer component"
|
||||
string += "\n and which has already spawned instances cannot be reloaded safely.{n"
|
||||
string += "\n {rModules containing Script classes with a timer component{n"
|
||||
string += "\n {rand which has already spawned instances cannot be reloaded safely.{n"
|
||||
string += "\n {rThese module(s) can only be reloaded by server reboot:{n\n %s\n"
|
||||
string = string % ", ".join(unsafe_dir_modified + unsafe_mod_modified)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue