mirror of https://github.com/Mikaela/Limnoria.git
Robustified\!
This commit is contained in:
parent
a7c7cc2841
commit
5e3fae4dbb
|
@ -66,19 +66,31 @@ def main():
|
||||||
import schedule
|
import schedule
|
||||||
schedule.addPeriodicEvent(world.upkeep, 300)
|
schedule.addPeriodicEvent(world.upkeep, 300)
|
||||||
world.startedAt = started
|
world.startedAt = started
|
||||||
try:
|
|
||||||
while world.ircs:
|
while world.ircs:
|
||||||
|
try:
|
||||||
drivers.run()
|
drivers.run()
|
||||||
log.info('No more Irc objects, exiting.')
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
log.info('Exiting due to Ctrl-C.')
|
log.info('Exiting due to Ctrl-C.')
|
||||||
now = time.time()
|
now = time.time()
|
||||||
log.info('Total uptime: %s.', utils.timeElapsed(now - world.startedAt))
|
seconds = now - world.startedAt
|
||||||
|
log.info('Total uptime: %s.', utils.timeElapsed(seconds))
|
||||||
(user, system, _, _, _) = os.times()
|
(user, system, _, _, _) = os.times()
|
||||||
log.info('Total CPU time taken: %s seconds.', user+system)
|
log.info('Total CPU time taken: %s seconds.', user+system)
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
except:
|
except:
|
||||||
|
try: # Ok, now we're *REALLY* paranoid!
|
||||||
log.exception('Exception raised out of drivers.run:')
|
log.exception('Exception raised out of drivers.run:')
|
||||||
|
except Exception, e:
|
||||||
|
print 'Exception raised in log.exception. This is *really*'
|
||||||
|
print 'bad. Hopefully it won\'t happen again, but tell us'
|
||||||
|
print 'about it anyway, this is a significant problem.'
|
||||||
|
print 'Anyway, here\'s the exception: %s'% utils.exnToString(e)
|
||||||
|
except:
|
||||||
|
print 'Man, this really sucks. Not only did log.exception'
|
||||||
|
print 'raise an exception, but freaking-a, it was a string'
|
||||||
|
print 'exception. People who raise string exceptions should'
|
||||||
|
print 'die a slow, painful death.'
|
||||||
|
log.info('No more Irc objects, exiting.')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
###
|
###
|
||||||
|
|
|
@ -74,6 +74,10 @@ def loadPluginModule(name, ignoreDeprecation=False):
|
||||||
try:
|
try:
|
||||||
index = loweredFiles.index(name.lower()+'.py')
|
index = loweredFiles.index(name.lower()+'.py')
|
||||||
name = os.path.splitext(files[index])[0]
|
name = os.path.splitext(files[index])[0]
|
||||||
|
if name in sys.modules:
|
||||||
|
m = sys.modules[name]
|
||||||
|
if not hasattr(m, 'Class'):
|
||||||
|
raise ImportError, 'Module is not a plugin.'
|
||||||
except ValueError: # We'd rather raise the ImportError, so we'll let go...
|
except ValueError: # We'd rather raise the ImportError, so we'll let go...
|
||||||
pass
|
pass
|
||||||
moduleInfo = imp.find_module(name, pluginDirs)
|
moduleInfo = imp.find_module(name, pluginDirs)
|
||||||
|
@ -335,7 +339,7 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
||||||
if name in str(e):
|
if name in str(e):
|
||||||
irc.error('No plugin %s exists.' % name)
|
irc.error('No plugin %s exists.' % name)
|
||||||
else:
|
else:
|
||||||
irc.error(utils.exnToString(e))
|
irc.error(str(e))
|
||||||
return
|
return
|
||||||
loadPluginClass(irc, module)
|
loadPluginClass(irc, module)
|
||||||
conf.registerPlugin(name, True)
|
conf.registerPlugin(name, True)
|
||||||
|
|
Loading…
Reference in New Issue