bots: Allow symlinks in bot paths provided to run.py.

run.py requires that the location of the provided bot matches the location
of run.py.  However, run.py previously failed in the case where the location
included a symlink.
This commit is contained in:
Elliott Jin 2017-05-22 15:42:40 -07:00 committed by Tim Abbott
parent f124531a88
commit 9b20750456

View file

@ -13,7 +13,7 @@ sys.path.insert(0, our_dir)
from bot_lib import run_message_handler_for_bot from bot_lib import run_message_handler_for_bot
def get_lib_module(bots_fn): def get_lib_module(bots_fn):
bots_fn = os.path.abspath(bots_fn) bots_fn = os.path.realpath(bots_fn)
if not os.path.dirname(bots_fn).startswith(os.path.join(our_dir, 'bots')): if not os.path.dirname(bots_fn).startswith(os.path.join(our_dir, 'bots')):
print('Sorry, we will only import code from contrib_bots/bots.') print('Sorry, we will only import code from contrib_bots/bots.')
sys.exit(1) sys.exit(1)