Don't use global variable profiledir

Rather than setting a global threadutil/profiledir variable, we make
set_profiledir a class function that sets the class variable profiledir.

While touching theprofiledir code, add warning to the user if the
profile directory existed before.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
Sebastian Spaeth
2011-09-29 16:02:51 +02:00
parent 8970a1500b
commit 642880b404
2 changed files with 23 additions and 20 deletions

View File

@ -1,6 +1,5 @@
# OfflineIMAP initialization code
# Copyright (C) 2002-2007 John Goerzen
# <jgoerzen@complete.org>
# Copyright (C) 2002-2011 John Goerzen & contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -157,11 +156,14 @@ class OfflineImap:
if not options.singlethreading:
logging.warn("Profile mode: Forcing to singlethreaded.")
options.singlethreading = True
profiledir = options.profiledir
os.mkdir(profiledir)
threadutil.setprofiledir(profiledir)
if os.path.exists(options.profiledir):
logging.warn("Profile mode: Directory '%s' already exists!" %
options.profiledir)
else:
os.mkdir(options.profiledir)
threadutil.ExitNotifyThread.set_profiledir(options.profiledir)
logging.warn("Profile mode: Potentially large data will be "
"created in '%s'" % profiledir)
"created in '%s'" % options.profiledir)
#override a config value
if options.configoverride: