mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-06 09:34:05 +01:00
Moved logfilesize to Status.
This commit is contained in:
parent
58e40a81bc
commit
a9ab89664c
@ -41,6 +41,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import sets
|
import sets
|
||||||
import time
|
import time
|
||||||
|
import os.path
|
||||||
import threading
|
import threading
|
||||||
from itertools import islice, ifilter, imap
|
from itertools import islice, ifilter, imap
|
||||||
|
|
||||||
@ -215,6 +216,36 @@ class Status(callbacks.Privmsg):
|
|||||||
"""
|
"""
|
||||||
irc.reply(irc.server)
|
irc.reply(irc.server)
|
||||||
|
|
||||||
|
def logfile(self, irc, msg, args):
|
||||||
|
"""[<logfile>]
|
||||||
|
|
||||||
|
Returns the size of the various logfiles in use. If given a specific
|
||||||
|
logfile, returns only the size of that logfile.
|
||||||
|
"""
|
||||||
|
filenameArg = privmsgs.getArgs(args, required=0, optional=1)
|
||||||
|
if filenameArg:
|
||||||
|
if not filenameArg.endswith('.log'):
|
||||||
|
irc.error('That filename doesn\'t appear to be a log.')
|
||||||
|
return
|
||||||
|
filenameArg = os.path.basename(filenameArg)
|
||||||
|
ret = []
|
||||||
|
dirname = conf.supybot.directories.log()
|
||||||
|
for (dirname,_,filenames) in os.walk(dirname):
|
||||||
|
if filenameArg:
|
||||||
|
if filenameArg in filenames:
|
||||||
|
filename = os.path.join(dirname, filenameArg)
|
||||||
|
stats = os.stat(filename)
|
||||||
|
ret.append('%s: %s' % (filename, stats.st_size))
|
||||||
|
else:
|
||||||
|
for filename in filenames:
|
||||||
|
stats = os.stat(os.path.join(dirname, filename))
|
||||||
|
ret.append('%s: %s' % (filename, stats.st_size))
|
||||||
|
if ret:
|
||||||
|
ret.sort()
|
||||||
|
irc.reply(utils.commaAndify(ret))
|
||||||
|
else:
|
||||||
|
irc.error('I couldn\'t find any logfiles.')
|
||||||
|
|
||||||
|
|
||||||
Class = Status
|
Class = Status
|
||||||
|
|
||||||
|
30
src/Misc.py
30
src/Misc.py
@ -322,36 +322,6 @@ class Misc(callbacks.Privmsg):
|
|||||||
"""
|
"""
|
||||||
irc.reply('My source is at http://supybot.sf.net/')
|
irc.reply('My source is at http://supybot.sf.net/')
|
||||||
|
|
||||||
def logfilesize(self, irc, msg, args):
|
|
||||||
"""[<logfile>]
|
|
||||||
|
|
||||||
Returns the size of the various logfiles in use. If given a specific
|
|
||||||
logfile, returns only the size of that logfile.
|
|
||||||
"""
|
|
||||||
filenameArg = privmsgs.getArgs(args, required=0, optional=1)
|
|
||||||
if filenameArg:
|
|
||||||
if not filenameArg.endswith('.log'):
|
|
||||||
irc.error('That filename doesn\'t appear to be a log.')
|
|
||||||
return
|
|
||||||
filenameArg = os.path.basename(filenameArg)
|
|
||||||
ret = []
|
|
||||||
dirname = conf.supybot.directories.log()
|
|
||||||
for (dirname,_,filenames) in os.walk(dirname):
|
|
||||||
if filenameArg:
|
|
||||||
if filenameArg in filenames:
|
|
||||||
filename = os.path.join(dirname, filenameArg)
|
|
||||||
stats = os.stat(filename)
|
|
||||||
ret.append('%s: %s' % (filename, stats.st_size))
|
|
||||||
else:
|
|
||||||
for filename in filenames:
|
|
||||||
stats = os.stat(os.path.join(dirname, filename))
|
|
||||||
ret.append('%s: %s' % (filename, stats.st_size))
|
|
||||||
if ret:
|
|
||||||
ret.sort()
|
|
||||||
irc.reply(utils.commaAndify(ret))
|
|
||||||
else:
|
|
||||||
irc.error('I couldn\'t find any logfiles.')
|
|
||||||
|
|
||||||
def plugin(self, irc, msg, args):
|
def plugin(self, irc, msg, args):
|
||||||
"""<command>
|
"""<command>
|
||||||
|
|
||||||
|
@ -123,12 +123,6 @@ class MiscTestCase(ChannelPluginTestCase):
|
|||||||
def testSource(self):
|
def testSource(self):
|
||||||
self.assertNotError('source')
|
self.assertNotError('source')
|
||||||
|
|
||||||
def testLogfilesize(self):
|
|
||||||
self.feedMsg('foo bar baz')
|
|
||||||
self.feedMsg('bar baz quux')
|
|
||||||
self.assertNotError('upkeep')
|
|
||||||
self.assertNotError('logfilesize')
|
|
||||||
|
|
||||||
def testPlugin(self):
|
def testPlugin(self):
|
||||||
self.assertResponse('plugin plugin', 'Misc')
|
self.assertResponse('plugin plugin', 'Misc')
|
||||||
|
|
||||||
|
@ -37,10 +37,10 @@ import supybot.world as world
|
|||||||
|
|
||||||
class StatusTestCase(PluginTestCase, PluginDocumentation):
|
class StatusTestCase(PluginTestCase, PluginDocumentation):
|
||||||
plugins = ('Status',)
|
plugins = ('Status',)
|
||||||
def testNetstats(self):
|
def testNet(self):
|
||||||
self.assertNotError('net')
|
self.assertNotError('net')
|
||||||
|
|
||||||
def testCpustats(self):
|
def testCpu(self):
|
||||||
m = self.assertNotError('status cpu')
|
m = self.assertNotError('status cpu')
|
||||||
self.failIf('kB kB' in m.args[1])
|
self.failIf('kB kB' in m.args[1])
|
||||||
self.failIf('None' in m.args[1], 'None in cpu output: %r.' % m)
|
self.failIf('None' in m.args[1], 'None in cpu output: %r.' % m)
|
||||||
@ -48,16 +48,29 @@ class StatusTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
if sys.platform.startswith(s):
|
if sys.platform.startswith(s):
|
||||||
self.failUnless('kB' in m.args[1],
|
self.failUnless('kB' in m.args[1],
|
||||||
'No memory string on supported platform.')
|
'No memory string on supported platform.')
|
||||||
|
try:
|
||||||
|
original = conf.supybot.plugins.Status.cpu.get('children')()
|
||||||
|
conf.supybot.plugins.Status.cpu.get('children').setValue(False)
|
||||||
|
self.assertNotRegexp('cpu', 'children')
|
||||||
|
finally:
|
||||||
|
conf.supybot.plugins.Status.cpu.get('children').setValue(original)
|
||||||
|
|
||||||
|
|
||||||
def testUptime(self):
|
def testUptime(self):
|
||||||
self.assertNotError('uptime')
|
self.assertNotError('uptime')
|
||||||
|
|
||||||
def testCmdstats(self):
|
def testCmd(self):
|
||||||
self.assertNotError('cmd')
|
self.assertNotError('cmd')
|
||||||
|
|
||||||
def testCommands(self):
|
def testCommands(self):
|
||||||
self.assertNotError('commands')
|
self.assertNotError('commands')
|
||||||
|
|
||||||
|
def testLogfilesize(self):
|
||||||
|
self.feedMsg('list')
|
||||||
|
self.feedMsg('list Status')
|
||||||
|
self.assertNotError('upkeep')
|
||||||
|
self.assertNotError('logfile')
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user