mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-11-09 20:27:26 +01:00
New logfilesize.
This commit is contained in:
parent
8ee09a01b8
commit
d5c9873231
31
src/Misc.py
31
src/Misc.py
@ -241,23 +241,28 @@ class Misc(callbacks.Privmsg):
|
|||||||
Returns the size of the various logfiles in use. If given a specific
|
Returns the size of the various logfiles in use. If given a specific
|
||||||
logfile, returns only the size of that logfile.
|
logfile, returns only the size of that logfile.
|
||||||
"""
|
"""
|
||||||
filename = privmsgs.getArgs(args, required=0, optional=1)
|
filenameArg = privmsgs.getArgs(args, required=0, optional=1)
|
||||||
if filename:
|
if filenameArg:
|
||||||
if not filename.endswith('.log'):
|
if not filenameArg.endswith('.log'):
|
||||||
irc.error(msg, 'That filename doesn\'t appear to be a log.')
|
irc.error(msg, 'That filename doesn\'t appear to be a log.')
|
||||||
return
|
return
|
||||||
filenames = [filename]
|
filenameArg = os.path.basename(filenameArg)
|
||||||
|
ret = []
|
||||||
|
for (dirname, _, filenames) in os.walk(conf.logDir):
|
||||||
|
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:
|
else:
|
||||||
filenames = os.listdir(conf.logDir)
|
for filename in filenames:
|
||||||
result = []
|
stats = os.stat(os.path.join(dirname, filename))
|
||||||
for file in filenames:
|
ret.append('%s: %s' % (filename, stats.st_size))
|
||||||
if file.endswith('.log'):
|
if ret:
|
||||||
stats = os.stat(os.path.join(conf.logDir, file))
|
ret.sort()
|
||||||
result.append((file, str(stats.st_size)))
|
irc.reply(msg, utils.commaAndify(ret))
|
||||||
if result:
|
|
||||||
irc.reply(msg, ', '.join(imap(': '.join, result)))
|
|
||||||
else:
|
else:
|
||||||
irc.reply(msg, 'I couldn\'t find any logfiles.')
|
irc.error(msg, 'I couldn\'t find any logfiles.')
|
||||||
|
|
||||||
def getprefixchar(self, irc, msg, args):
|
def getprefixchar(self, irc, msg, args):
|
||||||
"""takes no arguments
|
"""takes no arguments
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user