Head r710

This commit is contained in:
Jon Tibble 2010-02-21 13:21:44 +00:00
commit 5715819e83
4 changed files with 48 additions and 37 deletions

View File

@ -35,7 +35,7 @@ from PyQt4 import QtCore, QtGui
from openlp.core.lib import Receiver, str_to_bool
from openlp.core.resources import qInitResources
from openlp.core.ui import MainWindow, SplashScreen, ScreenList
from openlp.core.utils import ConfigHelper
from openlp.core.utils import get_config_directory, ConfigHelper
log = logging.getLogger()
@ -158,7 +158,7 @@ def main():
parser.add_option("-s", "--style", dest="style",
help="Set the Qt4 style (passed directly to Qt4).")
# Set up logging
filename = u'openlp.log'
filename = os.path.join(get_config_directory(), u'openlp.log')
logfile = FileHandler(filename, u'w')
logfile.setFormatter(logging.Formatter(
u'%(asctime)s %(name)-15s %(levelname)-8s %(message)s'))

View File

@ -22,17 +22,12 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
import os
import logging
import urllib2
from datetime import datetime
from registry import Registry
from confighelper import ConfigHelper
log = logging.getLogger(__name__)
__all__ = ['Registry', 'ConfigHelper']
log = logging.getLogger(__name__)
def check_latest_version(config, current_version):
@ -54,3 +49,40 @@ def check_latest_version(config, current_version):
if hasattr(e, u'reason'):
log.exception(u'Reason for failure: %s', e.reason)
return version_string
def get_config_directory():
path = u''
if os.name == u'nt':
path = os.path.join(os.getenv(u'APPDATA'), u'openlp')
elif os.name == u'mac':
path = os.path.join(os.getenv(u'HOME'), u'Library',
u'Application Support', u'openlp')
else:
try:
from xdg import BaseDirectory
path = os.path.join(BaseDirectory.xdg_config_home, u'openlp')
except ImportError:
path = os.path.join(os.getenv(u'HOME'), u'.openlp')
return path
def get_data_directory():
path = u''
if os.name == u'nt':
# ask OS for path to application data, set on Windows XP and Vista
path = os.path.join(os.getenv(u'APPDATA'), u'openlp', u'data')
elif os.name == u'mac':
path = os.path.join(os.getenv(u'HOME'), u'Library',
u'Application Support', u'openlp', u'Data')
else:
try:
from xdg import BaseDirectory
path = os.path.join(BaseDirectory.xdg_data_home, u'openlp')
except ImportError:
path = os.path.join(os.getenv(u'HOME'), u'.openlp', u'data')
return path
from registry import Registry
from confighelper import ConfigHelper
__all__ = [u'Registry', u'ConfigHelper', u'get_config_directory',
u'get_data_directory', u'check_latest_version']

View File

@ -24,6 +24,8 @@
###############################################################################
import os
from openlp.core.utils import get_data_directory, get_config_directory
from openlp.core.utils.registry import Registry
class ConfigHelper(object):
@ -34,20 +36,7 @@ class ConfigHelper(object):
@staticmethod
def get_data_path():
if os.name == u'nt':
# ask OS for path to application data, set on Windows XP and Vista
path = os.path.join(os.getenv(u'APPDATA'), u'openlp', u'data')
elif os.name == u'mac':
path = os.path.join(os.getenv(u'HOME'), u'Library',
u'Application Support', u'openlp', u'Data')
else:
try:
from xdg import BaseDirectory
path = os.path.join(BaseDirectory.xdg_data_home, u'openlp')
except ImportError:
path = os.path.join(os.getenv(u'HOME'), u'.openlp', u'data')
#reg = ConfigHelper.get_registry()
#path = ConfigHelper.get_config(u'main', 'data path', path)
path = get_data_directory()
if not os.path.exists(path):
os.makedirs(path)
return path
@ -81,17 +70,7 @@ class ConfigHelper(object):
current operating system, and returns an instantiation of that class.
"""
if ConfigHelper.__registry__ is None:
config_path = u''
if os.name == u'nt':
config_path = os.path.join(os.getenv(u'APPDATA'), u'openlp')
elif os.name == u'mac':
config_path = os.path.join(os.getenv(u'HOME'), u'Library',
u'Application Support', u'openlp')
else:
try:
from xdg import BaseDirectory
config_path = os.path.join(BaseDirectory.xdg_config_home, u'openlp')
except ImportError:
config_path = os.path.join(os.getenv(u'HOME'), u'.openlp')
config_path = get_config_directory()
ConfigHelper.__registry__ = Registry(config_path)
return ConfigHelper.__registry__
return ConfigHelper.__registry__

View File

@ -1 +1 @@
1.9.0-709
1.9.0-710