From 61d6e029b1d8c066029e93d785d8a8039ec069bd Mon Sep 17 00:00:00 2001 From: James Vega Date: Sat, 19 Jun 2004 18:57:42 +0000 Subject: [PATCH] Move creation of userdata.conf to scripts/supybot just to ensure that we're not trying to create it before the directories exist. --- scripts/supybot | 21 ++++++++++++++------- src/conf.py | 15 +++------------ 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/scripts/supybot b/scripts/supybot index e8109282b..29fac5006 100755 --- a/scripts/supybot +++ b/scripts/supybot @@ -159,7 +159,7 @@ if __name__ == '__main__': parser.add_option('', '--debug', action='store_true', dest='debug', help='Determines whether some extra debugging stuff will' 'be logged in this script.') - + (options, args) = parser.parse_args() if os.name == 'posix': @@ -191,7 +191,7 @@ if __name__ == '__main__': choose a different nick.""") nick = questions.something("""What nick would you like your bot to use?""") - + ### # Server. ### @@ -209,7 +209,7 @@ if __name__ == '__main__': while not checkServer(server): server = questions.something("""What server would you like your bot to connect to?""") - + ### # Channels. ### @@ -237,7 +237,7 @@ if __name__ == '__main__': instance, if you want to join #supybot with no keyword and #secret with a keyword of 'foo', you would type '#supybot #secret,foo' without the quotes. """ % server) - + ### # Filename. ### @@ -343,6 +343,14 @@ if __name__ == '__main__': if not os.path.exists(conf.supybot.directories.data()): os.mkdir(conf.supybot.directories.data()) + userdataFilename = os.path.join(supybot.directories.conf(),'userdata.conf') + # Let's open this now since we've got our directories setup. + if not os.path.exists(userdataFilename): + fd = file(userdataFilename, 'w') + fd.write('\n') + fd.close() + registry.open(userdataFilename) + import irclib import ircmsgs import drivers @@ -353,7 +361,7 @@ if __name__ == '__main__': callback = Owner.Class() irc.addCallback(callback) driver = drivers.newDriver(server, irc) - + if options.debug: for (name, module) in sys.modules.iteritems(): if hasattr(module, '__file__') and hasattr(module, '__revision__'): @@ -406,7 +414,7 @@ if __name__ == '__main__': atexit.register(removePidFile) except EnvironmentError, e: log.error('Error opening pid file %s: %s', pidFile, e) - + if options.profile: import hotshot profiler = hotshot.Profile('%s-%i.prof' % (nick, time.time())) @@ -415,5 +423,4 @@ if __name__ == '__main__': main() - # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: diff --git a/src/conf.py b/src/conf.py index 01a54fa1f..6a1db16f0 100644 --- a/src/conf.py +++ b/src/conf.py @@ -232,7 +232,7 @@ class IP(registry.String): self.error() else: registry.String.setValue(self, v) - + registerGlobalValue(supybot, 'externalIP', IP('', """A string that is the external IP of the bot. If this is the empty string, the bot will attempt to find out its IP dynamically (though @@ -266,7 +266,7 @@ registerChannelValue(supybot.reply, 'bracketSyntax', class ValidBrackets(registry.OnlySomeStrings): validStrings = ('', '[]', '<>', '{}', '()') - + registerChannelValue(supybot.reply, 'brackets', ValidBrackets('[]', """Supybot allows you to specify what brackets are used for your nested commands. Valid sets of brackets include [], <>, and {} @@ -571,7 +571,7 @@ class SocketTimeout(registry.PositiveInteger): self.error() registry.PositiveInteger.setValue(self, v) socket.setdefaulttimeout(self.value) - + registerGlobalValue(supybot, 'defaultSocketTimeout', SocketTimeout(10, """Determines what the default timeout for socket objects will be. This means that *all* sockets will timeout when this many seconds @@ -596,13 +596,4 @@ registerGlobalValue(supybot.debug, 'flushVeryOften', flush all flushers *very* often. Useful for debugging when you don't know what's breaking or when, but think that it might be logged.""")) -# Let's open this now since we've got our directories setup. -userdataFilename = os.path.join(supybot.directories.conf(), 'userdata.conf') -if not os.path.exists(userdataFilename): - fd = file(userdataFilename, 'w') - fd.write('\n') - fd.close() -registry.open(userdataFilename) - - # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: