diff --git a/.eric4project/openlp.org 2.0.e4q b/.eric4project/openlp.org 2.0.e4q
index 062599679..abc22762c 100644
--- a/.eric4project/openlp.org 2.0.e4q
+++ b/.eric4project/openlp.org 2.0.e4q
@@ -1,7 +1,7 @@
-
+
\ No newline at end of file
diff --git a/.eric4project/openlp.org 2.0.e4t b/.eric4project/openlp.org 2.0.e4t
index 70f66e1d3..30c8ab7b1 100644
--- a/.eric4project/openlp.org 2.0.e4t
+++ b/.eric4project/openlp.org 2.0.e4t
@@ -1,7 +1,7 @@
-
+
TODO: what is the tags for bridge, pre-chorus?
diff --git a/openlp/core/utils/confighelper.py b/openlp/core/utils/confighelper.py
index 363616068..ded1a3c38 100644
--- a/openlp/core/utils/confighelper.py
+++ b/openlp/core/utils/confighelper.py
@@ -25,17 +25,9 @@ class ConfigHelper(object):
Utility Helper to allow classes to find directories in a standard manner.
"""
@staticmethod
- def getConfigPath():
- if os.name == 'nt':
- import _winreg
- reg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
- key = r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
- path = get_registry_value(reg, key, "Common AppData")
- elif os.name == 'posix':
- path = os.path.join(os.getenv('HOME'), ".openlp.org")
- #if os.path.exists(path) == False :
- # raise Exception ('Configuration Directory does not Exist ')
- return path
+ def get_data_path():
+ reg = ConfigHelper.get_registry()
+ return reg.get_value('main', 'data_path')
@staticmethod
def get_data_path():
@@ -43,7 +35,7 @@ class ConfigHelper(object):
return reg.get_value('main', 'data_path')
@staticmethod
- def getSongsFile():
+ def get_songs_file():
path = ConfigHelper.get_data_path()
songfile = os.path.join(path, "songs", "songs.olp")
if os.path.exists(songfile):
@@ -66,5 +58,5 @@ class ConfigHelper(object):
reg = WinRegistry(r'\Software\openlp')
else:
from linregistry import LinRegistry
- reg = LinRegistry()
+ reg = LinRegistry(os.path.join(os.getenv('HOME'), '.openlp'))
return reg
diff --git a/openlp/core/utils/linregistry.py b/openlp/core/utils/linregistry.py
index f9b37a118..478333214 100644
--- a/openlp/core/utils/linregistry.py
+++ b/openlp/core/utils/linregistry.py
@@ -17,7 +17,8 @@ You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
"""
-
+import os
+from ConfigParser import SimpleConfigParser
from openlp.core.utils import Registry
class LinRegistry(Registry):
@@ -25,5 +26,6 @@ class LinRegistry(Registry):
The LinRegistry class is a high-level class for working with Linux and
Unix configurations.
"""
- def __init__(self):
- pass
+ def __init__(self, dir):
+ self.config = SimpleConfigParser()
+ self.config.read(os.path.join(dir, 'openlp.conf'))
diff --git a/openlp/core/utils/registry.py b/openlp/core/utils/registry.py
index 6db496908..aa8f8bb41 100644
--- a/openlp/core/utils/registry.py
+++ b/openlp/core/utils/registry.py
@@ -40,7 +40,7 @@ class Registry(object):
"""
pass
- def get_value(self, section, key):
+ def get_value(self, section, key, default=None):
"""
Get a single value from the registry.
"""
diff --git a/openlp/core/utils/winregistry.py b/openlp/core/utils/winregistry.py
index 7ea53a99e..631936395 100644
--- a/openlp/core/utils/winregistry.py
+++ b/openlp/core/utils/winregistry.py
@@ -41,8 +41,12 @@ class WinRegistry(Registry):
Check if a key/value exists.
"""
key_handle = _winreg.OpenKey(self.reg_handle, self.base_key + section)
- value, reg_type = _winreg.QueryValueEx(key_handle, key)[0]
- _winreg.CloseKey(key_handle)
+ try:
+ value, reg_type = _winreg.QueryValueEx(key_handle, key)
+ except EnvironmentError:
+ return False
+ finally:
+ _winreg.CloseKey(key_handle)
if reg_type == _winreg.REG_NONE:
return False
elif reg_type == _winreg.REG_SZ and value == '':
@@ -52,14 +56,21 @@ class WinRegistry(Registry):
else:
return True
- def get_value(self, section, key):
+ def get_value(self, section, key, default=None):
"""
Get a single value from the Windows registry.
"""
- key_handle = _winreg.OpenKey(self.reg_handle, self.base_key + section)
- value = _winreg.QueryValueEx(key_handle, key)[0]
- _winreg.CloseKey(key_handle)
- return value
+ if not self.has_value(section, key):
+ return default
+ else:
+ key_handle = _winreg.OpenKey(self.reg_handle, self.base_key + section)
+ try:
+ value = _winreg.QueryValueEx(key_handle, key)[0]
+ except EnvironmentError:
+ value = default
+ finally:
+ _winreg.CloseKey(key_handle)
+ return value
def set_value(self, section, key, value):
"""