Moved kernel over to Http as per the wishes of the kernel.org folx0rs.

This commit is contained in:
Jeremy Fincher 2003-08-30 02:33:28 +00:00
parent 8f40c90e0b
commit 7911d0f0a3
2 changed files with 21 additions and 23 deletions

View File

@ -447,7 +447,7 @@ class FunCommands(callbacks.Privmsg):
""" """
(user, system, childUser, childSystem, elapsed) = os.times() (user, system, childUser, childSystem, elapsed) = os.times()
timeRunning = time.time() - world.startedAt timeRunning = time.time() - world.startedAt
threads = threading.activeCount() activeThreads = threading.activeCount()
response ='I have taken %s seconds of user time and %s seconds of '\ response ='I have taken %s seconds of user time and %s seconds of '\
'system time, for a total of %s seconds of CPU time. My '\ 'system time, for a total of %s seconds of CPU time. My '\
'children have taken %s seconds of user time and %s seconds'\ 'children have taken %s seconds of user time and %s seconds'\
@ -460,7 +460,7 @@ class FunCommands(callbacks.Privmsg):
(user+system+childUser+childSystem)/timeRunning, (user+system+childUser+childSystem)/timeRunning,
world.threadsSpawned, world.threadsSpawned,
world.threadsSpawned == 1 and 'thread' or 'threads', world.threadsSpawned == 1 and 'thread' or 'threads',
threads, world.commandsProcessed, activeThreads, world.commandsProcessed,
world.commandProcessed == 1 and 'command' or 'commands') world.commandProcessed == 1 and 'command' or 'commands')
irc.reply(msg, response) irc.reply(msg, response)
@ -774,27 +774,6 @@ class FunCommands(callbacks.Privmsg):
irc.error(msg, 'Host not found.') irc.error(msg, 'Host not found.')
dns = privmsgs.thread(dns) dns = privmsgs.thread(dns)
def kernel(self, irc, msg, args):
"""takes no arguments"""
try:
conn = telnetlib.Telnet('kernel.org', 79)
conn.write('\n')
text = conn.read_all()
except socket.error, e:
irc.error(msg, e.args[1])
return
stable = 'unkown'
beta = 'unknown'
for line in text.splitlines():
(name, version) = line.split(':')
if 'latest stable' in name:
stable = version.strip()
elif 'latest beta' in name:
beta = version.strip()
irc.reply(msg, 'The latest stable kernel is %s; ' \
'the latest beta kernel is %s.' % (stable, beta))
kernel = privmsgs.thread(kernel)
Class = FunCommands Class = FunCommands

View File

@ -473,6 +473,25 @@ class Http(callbacks.Privmsg):
language = random.sample(babelfish.available_languages, 1)[0] language = random.sample(babelfish.available_languages, 1)[0]
irc.reply(msg, language) irc.reply(msg, language)
def kernel(self, irc, msg, args):
"""takes no arguments
Returns information about the current version of the Linux kernel.
"""
try:
fd = urllib2.urlopen('http://www.kernel.org/kdist/finger_banner')
except urllib2.URLError:
irc.error(msg, 'Couldn\'t connect to kernel.org.')
return
for line in fd:
(name, version) = line.split(':')
if 'latest stable' in name:
stable = version.strip()
elif 'latest beta' in name:
beta = version.strip()
irc.reply(msg, 'The latest stable kernel is %s; ' \
'the latest beta kernel is %s.' % (stable, beta))
Class = Http Class = Http
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: