mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 20:59:27 +01:00
supybot-wizard: do not pollute the CWD before paths to directories are known.
This commit is contained in:
parent
2caf8e4072
commit
59ed253a0e
@ -260,11 +260,8 @@ def main():
|
||||
i18n.conf = fakeConf
|
||||
i18n.currentLocale = language
|
||||
i18n.reloadLocales()
|
||||
import supybot.log as log
|
||||
log._stdoutHandler.setLevel(100) # *Nothing* gets through this!
|
||||
import supybot.conf as conf
|
||||
i18n.import_conf() # It imports the real conf module
|
||||
import supybot.plugin as plugin
|
||||
|
||||
### Directories.
|
||||
# We set these variables in cache because otherwise conf and log will
|
||||
@ -284,6 +281,8 @@ def main():
|
||||
make a directory named "logs" right here.""")
|
||||
(logDir, basedir) = getDirectoryName('logs')
|
||||
conf.supybot.directories.log.setValue(logDir)
|
||||
import supybot.log as log
|
||||
log._stdoutHandler.setLevel(100) # *Nothing* gets through this!
|
||||
|
||||
# conf.supybot.directories.data
|
||||
output("""Your bot will need to put various data somewhere. Things
|
||||
@ -310,6 +309,23 @@ def main():
|
||||
(backupDir, basedir) = getDirectoryName('backup', basedir=basedir)
|
||||
conf.supybot.directories.backup.setValue(backupDir)
|
||||
|
||||
# conf.supybot.directories.data.tmp
|
||||
output("""Your bot needs a directory to put temporary files (used
|
||||
mainly to atomically update its configuration files).""")
|
||||
(tmpDir, basedir) = getDirectoryName('tmp', basedir=basedir)
|
||||
conf.supybot.directories.data.tmp.setValue(tmpDir)
|
||||
|
||||
# conf.supybot.directories.data.web
|
||||
output("""Your bot needs a directory to put files related to the web
|
||||
server (templates, CSS).""")
|
||||
(webDir, basedir) = getDirectoryName('web', basedir=basedir)
|
||||
conf.supybot.directories.data.web.setValue(webDir)
|
||||
|
||||
|
||||
# imports callbacks, which imports ircdb, which requires
|
||||
# directories.conf
|
||||
import supybot.plugin as plugin
|
||||
|
||||
# pluginDirs
|
||||
output("""Your bot will also need to know where to find its plugins at.
|
||||
Of course, it already knows where the plugins that it came with are,
|
||||
@ -330,22 +346,33 @@ def main():
|
||||
the various log, config, and data files.""")
|
||||
basedir = something("""Where would you like to create these
|
||||
directories?""", default=os.curdir)
|
||||
|
||||
# conf.supybot.directories.log
|
||||
(logDir, basedir) = getDirectoryName('logs',
|
||||
basedir=basedir, prompt=False)
|
||||
conf.supybot.directories.log.setValue(logDir)
|
||||
|
||||
# conf.supybot.directories.data
|
||||
(dataDir, basedir) = getDirectoryName('data',
|
||||
basedir=basedir, prompt=False)
|
||||
conf.supybot.directories.data.setValue(dataDir)
|
||||
(tmpDir, basedir) = getDirectoryName('tmp',
|
||||
basedir=basedir, prompt=False)
|
||||
conf.supybot.directories.data.tmp.setValue(tmpDir)
|
||||
(webDir, basedir) = getDirectoryName('web',
|
||||
basedir=basedir, prompt=False)
|
||||
conf.supybot.directories.data.web.setValue(webDir)
|
||||
|
||||
# conf.supybot.directories.conf
|
||||
(confDir, basedir) = getDirectoryName('conf',
|
||||
basedir=basedir, prompt=False)
|
||||
conf.supybot.directories.conf.setValue(confDir)
|
||||
|
||||
# conf.supybot.directories.backup
|
||||
(backupDir, basedir) = getDirectoryName('backup',
|
||||
basedir=basedir, prompt=False)
|
||||
conf.supybot.directories.backup.setValue(backupDir)
|
||||
|
||||
# pluginDirs
|
||||
pluginDirs = conf.supybot.directories.plugins()
|
||||
(pluginDir, _) = getDirectoryName('plugins',
|
||||
@ -354,6 +381,10 @@ def main():
|
||||
pluginDirs.append(pluginDir)
|
||||
conf.supybot.directories.plugins.setValue(pluginDirs)
|
||||
|
||||
import supybot.log as log
|
||||
log._stdoutHandler.setLevel(100) # *Nothing* gets through this!
|
||||
import supybot.plugin as plugin
|
||||
|
||||
output("Good! We're done with the directory stuff.")
|
||||
|
||||
###
|
||||
@ -719,8 +750,12 @@ def main():
|
||||
# We're going to need to do a darcs predist thing here.
|
||||
#conf.supybot.debug.generated.setValue('...')
|
||||
|
||||
if advanced:
|
||||
basedir = '.'
|
||||
filename = os.path.join(basedir, '%s.conf')
|
||||
|
||||
filename = something("""In which file would you like to save
|
||||
this config?""", default='%s.conf' % nick)
|
||||
this config?""", default=filename % nick)
|
||||
if not filename.endswith('.conf'):
|
||||
filename += '.conf'
|
||||
registry.close(conf.supybot, os.path.expanduser(filename))
|
||||
|
13
src/conf.py
13
src/conf.py
@ -870,6 +870,9 @@ registerGlobalValue(supybot.directories, 'backup',
|
||||
Directory('backup', _("""Determines what directory backup data is put
|
||||
into. Set it to /dev/null to disable backup (it is a special value,
|
||||
so it also works on Windows and systems without /dev/null).""")))
|
||||
registerGlobalValue(supybot.directories, 'log',
|
||||
Directory('logs', """Determines what directory the bot will store its
|
||||
logfiles in."""))
|
||||
registerGlobalValue(supybot.directories.data, 'tmp',
|
||||
DataFilenameDirectory('tmp', _("""Determines what directory temporary files
|
||||
are put into.""")))
|
||||
@ -877,8 +880,14 @@ registerGlobalValue(supybot.directories.data, 'web',
|
||||
DataFilenameDirectory('web', _("""Determines what directory files of the
|
||||
web server (templates, custom images, ...) are put into.""")))
|
||||
|
||||
utils.file.AtomicFile.default.tmpDir = supybot.directories.data.tmp
|
||||
utils.file.AtomicFile.default.backupDir = supybot.directories.backup
|
||||
def _update_tmp():
|
||||
utils.file.AtomicFile.default.tmpDir = supybot.directories.data.tmp
|
||||
supybot.directories.data.tmp.addCallback(_update_tmp)
|
||||
_update_tmp()
|
||||
def _update_backup():
|
||||
utils.file.AtomicFile.default.backupDir = supybot.directories.backup
|
||||
supybot.directories.backup.addCallback(_update_backup)
|
||||
_update_backup()
|
||||
|
||||
registerGlobalValue(supybot.directories, 'plugins',
|
||||
registry.CommaSeparatedListOfStrings([], _("""Determines what directories
|
||||
|
@ -178,10 +178,6 @@ class ColorizedFormatter(Formatter):
|
||||
else:
|
||||
return Formatter.format(self, record, *args, **kwargs)
|
||||
|
||||
conf.registerGlobalValue(conf.supybot.directories, 'log',
|
||||
conf.Directory('logs', """Determines what directory the bot will store its
|
||||
logfiles in."""))
|
||||
|
||||
_logDir = conf.supybot.directories.log()
|
||||
if not os.path.exists(_logDir):
|
||||
os.mkdir(_logDir, 0o755)
|
||||
|
Loading…
Reference in New Issue
Block a user