From db0b125897d752f11b632e73fd66dd541fa39b98 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sat, 18 Jun 2011 18:55:27 -0400 Subject: [PATCH] specify core/main.py as an absolute path, so we don't have to run 'python earwigbot.py' from within earwigbot/, but we can also do 'python /path/to/earwigbot.py' --- earwigbot.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/earwigbot.py b/earwigbot.py index b18f1bc..5543221 100644 --- a/earwigbot.py +++ b/earwigbot.py @@ -4,7 +4,7 @@ """ EarwigBot -A thin wrapper for EarwigBot's main bot code, located in core/main.py. This +A thin wrapper for EarwigBot's main bot code, specified by bot_script. This wrapper will automatically restart the bot when it shuts down (from !restart, for example). It requests the bot's password at startup and reuses it every time the bot restarts internally, so you do not need to re-enter the password @@ -16,6 +16,7 @@ markdown format!) and the LICENSE for licensing information. from getpass import getpass from subprocess import Popen, PIPE +from os import path from sys import executable from time import sleep @@ -27,6 +28,8 @@ __license__ = "MIT License" __version__ = "0.1dev" __email__ = "ben.kurtovic@verizon.net" +bot_script = path.join(path.dirname(path.abspath(__file__)), "core", "main.py") + def main(): print "EarwigBot v{0}\n".format(__version__) @@ -37,7 +40,7 @@ def main(): key = None while 1: - bot = Popen([executable, 'core/main.py'], stdin=PIPE) + bot = Popen([executable, bot_script], stdin=PIPE) bot.communicate(key) # give the key to core.config.load() return_code = bot.wait() if return_code == 1: