Move creation of userdata.conf to scripts/supybot just to ensure that we're

not trying to create it before the directories exist.
This commit is contained in:
James Vega 2004-06-19 18:57:42 +00:00
parent 18138da1c0
commit 61d6e029b1
2 changed files with 17 additions and 19 deletions

View File

@ -159,7 +159,7 @@ if __name__ == '__main__':
parser.add_option('', '--debug', action='store_true', dest='debug', parser.add_option('', '--debug', action='store_true', dest='debug',
help='Determines whether some extra debugging stuff will' help='Determines whether some extra debugging stuff will'
'be logged in this script.') 'be logged in this script.')
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
if os.name == 'posix': if os.name == 'posix':
@ -191,7 +191,7 @@ if __name__ == '__main__':
choose a different nick.""") choose a different nick.""")
nick = questions.something("""What nick would you like your nick = questions.something("""What nick would you like your
bot to use?""") bot to use?""")
### ###
# Server. # Server.
### ###
@ -209,7 +209,7 @@ if __name__ == '__main__':
while not checkServer(server): while not checkServer(server):
server = questions.something("""What server would you like server = questions.something("""What server would you like
your bot to connect to?""") your bot to connect to?""")
### ###
# Channels. # Channels.
### ###
@ -237,7 +237,7 @@ if __name__ == '__main__':
instance, if you want to join #supybot with no keyword and instance, if you want to join #supybot with no keyword and
#secret with a keyword of 'foo', you would type '#supybot #secret with a keyword of 'foo', you would type '#supybot
#secret,foo' without the quotes. """ % server) #secret,foo' without the quotes. """ % server)
### ###
# Filename. # Filename.
### ###
@ -343,6 +343,14 @@ if __name__ == '__main__':
if not os.path.exists(conf.supybot.directories.data()): if not os.path.exists(conf.supybot.directories.data()):
os.mkdir(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 irclib
import ircmsgs import ircmsgs
import drivers import drivers
@ -353,7 +361,7 @@ if __name__ == '__main__':
callback = Owner.Class() callback = Owner.Class()
irc.addCallback(callback) irc.addCallback(callback)
driver = drivers.newDriver(server, irc) driver = drivers.newDriver(server, irc)
if options.debug: if options.debug:
for (name, module) in sys.modules.iteritems(): for (name, module) in sys.modules.iteritems():
if hasattr(module, '__file__') and hasattr(module, '__revision__'): if hasattr(module, '__file__') and hasattr(module, '__revision__'):
@ -406,7 +414,7 @@ if __name__ == '__main__':
atexit.register(removePidFile) atexit.register(removePidFile)
except EnvironmentError, e: except EnvironmentError, e:
log.error('Error opening pid file %s: %s', pidFile, e) log.error('Error opening pid file %s: %s', pidFile, e)
if options.profile: if options.profile:
import hotshot import hotshot
profiler = hotshot.Profile('%s-%i.prof' % (nick, time.time())) profiler = hotshot.Profile('%s-%i.prof' % (nick, time.time()))
@ -415,5 +423,4 @@ if __name__ == '__main__':
main() main()
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:

View File

@ -232,7 +232,7 @@ class IP(registry.String):
self.error() self.error()
else: else:
registry.String.setValue(self, v) registry.String.setValue(self, v)
registerGlobalValue(supybot, 'externalIP', registerGlobalValue(supybot, 'externalIP',
IP('', """A string that is the external IP of the bot. If this is the empty 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 string, the bot will attempt to find out its IP dynamically (though
@ -266,7 +266,7 @@ registerChannelValue(supybot.reply, 'bracketSyntax',
class ValidBrackets(registry.OnlySomeStrings): class ValidBrackets(registry.OnlySomeStrings):
validStrings = ('', '[]', '<>', '{}', '()') validStrings = ('', '[]', '<>', '{}', '()')
registerChannelValue(supybot.reply, 'brackets', registerChannelValue(supybot.reply, 'brackets',
ValidBrackets('[]', """Supybot allows you to specify what brackets are used ValidBrackets('[]', """Supybot allows you to specify what brackets are used
for your nested commands. Valid sets of brackets include [], <>, and {} for your nested commands. Valid sets of brackets include [], <>, and {}
@ -571,7 +571,7 @@ class SocketTimeout(registry.PositiveInteger):
self.error() self.error()
registry.PositiveInteger.setValue(self, v) registry.PositiveInteger.setValue(self, v)
socket.setdefaulttimeout(self.value) socket.setdefaulttimeout(self.value)
registerGlobalValue(supybot, 'defaultSocketTimeout', registerGlobalValue(supybot, 'defaultSocketTimeout',
SocketTimeout(10, """Determines what the default timeout for socket objects SocketTimeout(10, """Determines what the default timeout for socket objects
will be. This means that *all* sockets will timeout when this many seconds 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 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.""")) 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: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: