mirror of https://github.com/Mikaela/Limnoria.git
Added revision command for finding out the revision of supybot's files.
This commit is contained in:
parent
210809ab99
commit
86524fa148
|
@ -1,3 +1,7 @@
|
||||||
|
* Added revision command for finding out the revision of the files
|
||||||
|
in a running bot; also added __revision__ strings with $Id$ values
|
||||||
|
so CVS would be happy to keep such information for us :)
|
||||||
|
|
||||||
* Fixed bug #848475 -- bad error message from regexp-expecting
|
* Fixed bug #848475 -- bad error message from regexp-expecting
|
||||||
commands.
|
commands.
|
||||||
|
|
||||||
|
|
36
src/Misc.py
36
src/Misc.py
|
@ -191,12 +191,46 @@ class Misc(callbacks.Privmsg):
|
||||||
"""
|
"""
|
||||||
irc.reply(msg, conf.version)
|
irc.reply(msg, conf.version)
|
||||||
|
|
||||||
|
def revision(self, irc, msg, args):
|
||||||
|
"""[<module>]
|
||||||
|
|
||||||
|
Gives the latest revision of <module>. If <module> isn't given, gives
|
||||||
|
the revision of all supybot modules.
|
||||||
|
"""
|
||||||
|
name = privmsgs.getArgs(args, required=0, optional=1)
|
||||||
|
if name:
|
||||||
|
try:
|
||||||
|
module = sys.modules[name]
|
||||||
|
except KeyError:
|
||||||
|
irc.error(msg, 'I couldn\'t find a module named %s' % name)
|
||||||
|
return
|
||||||
|
if hasattr(module, '__revision__'):
|
||||||
|
irc.reply(msg, module.__revision__)
|
||||||
|
else:
|
||||||
|
irc.error(msg, 'Module %s has no __revision__.' % name)
|
||||||
|
else:
|
||||||
|
def getVersion(s):
|
||||||
|
return s.split(None, 3)[2]
|
||||||
|
names = {}
|
||||||
|
dirs = map(os.path.abspath, conf.pluginDirs)
|
||||||
|
for (name, module) in sys.modules.iteritems():
|
||||||
|
if hasattr(module, '__revision__'):
|
||||||
|
if 'supybot' in module.__file__:
|
||||||
|
names[name] = getVersion(module.__revision__)
|
||||||
|
else:
|
||||||
|
for dir in dirs:
|
||||||
|
if dir in module.__file__:
|
||||||
|
names[name] = getVersion(module.__revision__)
|
||||||
|
break
|
||||||
|
L = ['%s: %s' % (k, v) for (k, v) in names.items()]
|
||||||
|
irc.reply(msg, utils.commaAndify(L))
|
||||||
|
|
||||||
def source(self, irc, msg, args):
|
def source(self, irc, msg, args):
|
||||||
"""takes no arguments
|
"""takes no arguments
|
||||||
|
|
||||||
Returns a URL saying where to get SupyBot.
|
Returns a URL saying where to get SupyBot.
|
||||||
"""
|
"""
|
||||||
irc.reply(msg, 'My source is at http://www.sf.net/projects/supybot/')
|
irc.reply(msg, 'My source is at http://supybot.sf.net/')
|
||||||
|
|
||||||
def logfilesize(self, irc, msg, args):
|
def logfilesize(self, irc, msg, args):
|
||||||
"""[<logfile>]
|
"""[<logfile>]
|
||||||
|
|
|
@ -151,6 +151,10 @@ class MiscTestCase(ChannelPluginTestCase, PluginDocumentation):
|
||||||
self.assertNotError('apropos f')
|
self.assertNotError('apropos f')
|
||||||
self.assertError('apropos asldkfjasdlkfja')
|
self.assertError('apropos asldkfjasdlkfja')
|
||||||
|
|
||||||
|
def testRevision(self):
|
||||||
|
self.assertNotError('revision Misc')
|
||||||
|
self.assertNotError('revision')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
|
Loading…
Reference in New Issue