Handle the case where the program isn't found.

This commit is contained in:
Jeremy Fincher 2005-01-10 06:02:51 +00:00
parent 625cfb4214
commit eaf9f809ca

View File

@ -253,7 +253,11 @@ class Unix(callbacks.Privmsg):
lines = r.readlines() lines = r.readlines()
lines = map(str.rstrip, lines) lines = map(str.rstrip, lines)
lines = filter(None, lines) lines = filter(None, lines)
irc.replies(lines, joiner=' ') if lines:
irc.replies(lines, joiner=' ')
else:
irc.error('It seems the configured fortune command was '
'not available.')
finally: finally:
w.close() w.close()
r.close() r.close()
@ -273,16 +277,23 @@ class Unix(callbacks.Privmsg):
""" """
wtfCmd = self.registryValue('wtf.command') wtfCmd = self.registryValue('wtf.command')
if wtfCmd: if wtfCmd:
def commandError():
irc.error('It seems the configured wtf command '
'was not available.')
something = something.rstrip('?') something = something.rstrip('?')
inst = popen2.Popen4([wtfCmd, something]) inst = popen2.Popen4([wtfCmd, something])
(r, w) = (inst.fromchild, inst.tochild) (r, w) = (inst.fromchild, inst.tochild)
try: try:
response = utils.normalizeWhitespace(r.readline().strip()) response = utils.normalizeWhitespace(r.readline().strip())
irc.reply(response) if response:
irc.reply(response)
else:
commandError()
finally: finally:
r.close() r.close()
w.close() w.close()
inst.wait() inst.wait()
commandError()
else: else:
irc.error('I couldn\'t find the wtf command on this system. ' irc.error('I couldn\'t find the wtf command on this system. '
'If it is installed on this system, reconfigure the ' 'If it is installed on this system, reconfigure the '