mirror of
https://github.com/progval/Limnoria.git
synced 2025-04-27 13:31:08 -05:00
supybot-plugin-doc: Add an error() to handle logging errors and exiting
Signed-off-by: James Vega <jamessan@users.sourceforge.net>
This commit is contained in:
parent
b3d97ea03e
commit
38f338ea48
@ -31,17 +31,23 @@
|
|||||||
###
|
###
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
import supybot
|
import supybot
|
||||||
|
|
||||||
|
def error(s):
|
||||||
|
sys.stderr.write('%s\n' % s)
|
||||||
|
sys.exit(-1)
|
||||||
|
|
||||||
# We need to do this before we import conf.
|
# We need to do this before we import conf.
|
||||||
if not os.path.exists('doc-conf'):
|
if not os.path.exists('doc-conf'):
|
||||||
os.mkdir('doc-conf')
|
os.mkdir('doc-conf')
|
||||||
|
|
||||||
registryFilename = os.path.join('doc-conf', 'doc.conf')
|
registryFilename = os.path.join('doc-conf', 'doc.conf')
|
||||||
fd = file(registryFilename, 'w')
|
try:
|
||||||
fd.write("""
|
fd = file(registryFilename, 'w')
|
||||||
|
fd.write("""
|
||||||
supybot.directories.data: doc-data
|
supybot.directories.data: doc-data
|
||||||
supybot.directories.conf: doc-conf
|
supybot.directories.conf: doc-conf
|
||||||
supybot.directories.log: doc-logs
|
supybot.directories.log: doc-logs
|
||||||
@ -51,7 +57,9 @@ supybot.log.format: %(levelname)s %(message)s
|
|||||||
supybot.log.plugins.individualLogfiles: False
|
supybot.log.plugins.individualLogfiles: False
|
||||||
supybot.databases: sqlite anydbm cdb flat pickle
|
supybot.databases: sqlite anydbm cdb flat pickle
|
||||||
""")
|
""")
|
||||||
fd.close()
|
fd.close()
|
||||||
|
except EnvironmentError, e:
|
||||||
|
error('Unable to open %s for writing.' % registryFilename)
|
||||||
|
|
||||||
import supybot.registry as registry
|
import supybot.registry as registry
|
||||||
registry.open(registryFilename)
|
registry.open(registryFilename)
|
||||||
@ -60,7 +68,6 @@ import supybot.log as log
|
|||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
conf.supybot.flush.setValue(False)
|
conf.supybot.flush.setValue(False)
|
||||||
|
|
||||||
import sys
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
@ -159,8 +166,7 @@ def genDoc(m, options):
|
|||||||
try:
|
try:
|
||||||
fd = file(path, 'w')
|
fd = file(path, 'w')
|
||||||
except EnvironmentError, e:
|
except EnvironmentError, e:
|
||||||
sys.stderr.write('Unable to open %s for writing.' % path)
|
error('Unable to open %s for writing.' % path)
|
||||||
sys.exit(-1)
|
|
||||||
try:
|
try:
|
||||||
fd.write(Plugin.renderSTX())
|
fd.write(Plugin.renderSTX())
|
||||||
finally:
|
finally:
|
||||||
@ -207,10 +213,10 @@ if __name__ == '__main__':
|
|||||||
try:
|
try:
|
||||||
pluginModule = plugin.loadPluginModule(pluginName)
|
pluginModule = plugin.loadPluginModule(pluginName)
|
||||||
except ImportError, e:
|
except ImportError, e:
|
||||||
sys.stderr.write('Failed to load plugin %s: %s\n' % (pluginName,e))
|
s = 'Failed to load plugin %s: %s\n' \
|
||||||
sys.stderr.write('(pluginDirs: %s)' %
|
'%s(pluginDirs: %s)' % (pluginName, e, s,
|
||||||
conf.supybot.directories.plugins())
|
conf.supybot.directories.plugins())
|
||||||
sys.exit(-1)
|
error(s)
|
||||||
plugins.add(pluginModule)
|
plugins.add(pluginModule)
|
||||||
|
|
||||||
for Plugin in plugins:
|
for Plugin in plugins:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user