Ver a proveniência

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'

tags/v0.1^2
Ben Kurtovic há 13 anos
ascendente
cometimento
db0b125897
1 ficheiros alterados com 5 adições e 2 eliminações
  1. +5
    -2
      earwigbot.py

+ 5
- 2
earwigbot.py Ver ficheiro

@@ -4,7 +4,7 @@
""" """
EarwigBot 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, 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 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 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 getpass import getpass
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from os import path
from sys import executable from sys import executable
from time import sleep from time import sleep


@@ -27,6 +28,8 @@ __license__ = "MIT License"
__version__ = "0.1dev" __version__ = "0.1dev"
__email__ = "ben.kurtovic@verizon.net" __email__ = "ben.kurtovic@verizon.net"


bot_script = path.join(path.dirname(path.abspath(__file__)), "core", "main.py")

def main(): def main():
print "EarwigBot v{0}\n".format(__version__) print "EarwigBot v{0}\n".format(__version__)


@@ -37,7 +40,7 @@ def main():
key = None key = None


while 1: 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() bot.communicate(key) # give the key to core.config.load()
return_code = bot.wait() return_code = bot.wait()
if return_code == 1: if return_code == 1:


Carregando…
Cancelar
Guardar