openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #01045
[Merge] lp:~raoul-snyman/openlp/windowsfixes into lp:openlp
Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/windowsfixes into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
Moved the log file to a "better" location so that non-priviledged users can still generate debug reports, and so that openlp doesn't fail or something when starting up.
--
https://code.launchpad.net/~raoul-snyman/openlp/windowsfixes/+merge/19802
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp.pyw'
--- openlp.pyw 2010-02-06 17:12:03 +0000
+++ openlp.pyw 2010-02-21 06:40:31 +0000
@@ -35,7 +35,7 @@
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 @@
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'))
=== modified file 'openlp/core/utils/__init__.py'
--- openlp/core/utils/__init__.py 2010-02-05 19:08:47 +0000
+++ openlp/core/utils/__init__.py 2010-02-21 06:40:31 +0000
@@ -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 @@
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']
=== modified file 'openlp/core/utils/confighelper.py'
--- openlp/core/utils/confighelper.py 2009-12-31 12:52:01 +0000
+++ openlp/core/utils/confighelper.py 2010-02-21 06:40:31 +0000
@@ -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 @@
@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 @@
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__
\ No newline at end of file
+ return ConfigHelper.__registry__
+
Follow ups