supybot-botchk: Directly execute supybot instead of running it in sh

Signed-off-by: James McCoy <jamessan@users.sourceforge.net>
This commit is contained in:
James McCoy 2013-08-23 21:35:35 -04:00
parent 960e1da61c
commit c73ead8aef
2 changed files with 9 additions and 14 deletions

View File

@ -10,6 +10,8 @@ Factoids' config variable supybot.plugins.Factoids.factoidPrefix has been
replaced by supybot.plugins.Factoids.format, which allows the user to replaced by supybot.plugins.Factoids.format, which allows the user to
determine exactly how replies to Factoid queries are formatted. determine exactly how replies to Factoid queries are formatted.
supybot-botchk no longer runs supybot inside an instance of /bin/sh.
Version 0.83.4.1 Version 0.83.4.1

View File

@ -122,21 +122,14 @@ if __name__ == '__main__':
debug('pidfile (%s) is not writable: %s' % (options.pidfile, e)) debug('pidfile (%s) is not writable: %s' % (options.pidfile, e))
sys.exit(-1) sys.exit(-1)
debug('Bot not found, starting.') debug('Bot not found, starting.')
home = os.environ['HOME'] cmdline = [options.supybot, '--daemon', options.conffile]
inst = subprocess.Popen('sh', close_fds=True, stderr=subprocess.STDOUT, inst = subprocess.Popen(cmdline, close_fds=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE) stderr=subprocess.STDOUT,
for filename in ('.login', '.bash_profile', '.profile', '.bashrc'): stdin=None, stdout=subprocess.PIPE)
filename = os.path.join(home, filename) debug('Output from supybot: %r' % inst.stdout.read())
if os.path.exists(filename):
debug('Found %s, sourcing.' % filename)
inst.stdin.write('source %s' % filename + os.linesep)
cmdline = '%s --daemon %s' % (options.supybot, options.conffile)
debug('Sending cmdline to sh process.')
inst.stdin.write(cmdline + os.linesep)
inst.stdin.close()
debug('Received from sh process: %r' % inst.stdout.read())
ret = inst.wait() ret = inst.wait()
debug('Bot started, command line %r returned %s.' % (cmdline, ret)) debug('Bot started, command line %r returned %s.' % (' '.join(cmdline),
ret))
sys.exit(ret) sys.exit(ret)
else: else:
sys.exit(0) sys.exit(0)